/

CVE-2026-39859

Severity:

HIGH RISK

(7.5)

Path Traversal in LiquidJS Template File Loading

CVE-2026-39859

Analyzed

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Read on Server

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

LiquidJS, a JavaScript template engine compatible with Shopify and GitHub Pages, contains a path traversal flaw in how it handles top-level file loading via renderFile() and parseFile().

When the engine is configured with a root directory (such as an empty temporary directory), the documented root constraint is not enforced for some file loads, allowing retrieval of arbitrary file contents on the server.

Affected context

This vulnerability arises in applications using LiquidJS (prior to 10.25.3) that:

  • Use renderFile() and/or parseFile() for loading templates from disk
  • Rely on the root configuration option to constrain which files can be accessed
  • Potentially accept or derive template names/paths from user input or untrusted sources

In these contexts, top-level file loads are not correctly restricted to the configured root directory, enabling access to files outside the intended template tree.

Exploit preconditions

  • Attack surface: Server-side endpoints or features that trigger LiquidJS renderFile() or parseFile() with variable file names.
  • Required access: Ability to influence or control the file path argument passed to these LiquidJS APIs (e.g., via HTTP parameters, template selection fields, or indirect configuration).
  • Trigger point: Invocation of renderFile() or parseFile() for a template whose path includes traversal or absolute path patterns, while a root directory is configured.
  • Why exploitation is possible: The implementation does not enforce the documented root boundary for top-level file loads, allowing paths that escape the intended directory and resolve to arbitrary files readable by the process.

Why this happens

The underlying bug falls under CWE-22: Path Traversal, where insufficient validation or canonicalization of file paths allows access outside the expected directory.

LiquidJS documents that the root option constrains which files can be loaded by renderFile() and parseFile(), but certain code paths skip or misapply this restriction. As a result, path values are resolved directly against the filesystem instead of being normalized and checked against the configured root. This mismatch between documentation and enforcement, combined with the lack of robust path normalization and boundary checks, enables traversal to arbitrary files accessible to the server process.

Potential impact

  • Reading arbitrary files on the server that are accessible to the application's filesystem permissions
  • Exposure of configuration files, API keys, and other secrets stored on disk
  • Disclosure of source code and business logic, aiding further vulnerability discovery
  • Potential leakage of user data or logs containing sensitive information
  • Increased ability to chain with other vulnerabilities (e.g., using leaked credentials to escalate compromise)

General mitigation guidance

Effective mitigation focuses on strict path handling and trust minimization for template paths:

  • Enforce canonicalization and normalization of all file paths before use, verifying that the resolved path is within an allowed root directory.
  • Treat any file name or template identifier influenced by users as untrusted input; constrain it to a vetted whitelist or a limited pattern set rather than allowing arbitrary paths.
  • Use a well-defined, application-controlled mapping from logical template names to physical files, avoiding direct exposure of filesystem paths in application interfaces.
  • Run the template rendering environment with least-privilege filesystem permissions, limiting which directories and files are readable.
  • Consider isolating template files into a dedicated directory or container volume that contains no secrets or sensitive configuration.

How teams detect issues like this

Organizations can identify this class of issue using several complementary techniques:

  • Static analysis and code search: Look for calls to renderFile() and parseFile() where the path argument is derived from request data, query parameters, headers, or other uncontrolled input, and verify that no robust root-boundary and normalization checks are present.
  • Code review checklists: Include explicit review items for server-side template engines, confirming that any documented root or base directory constraints are actually enforced in code and not assumed.
  • Dynamic testing and fuzzing: During security testing, attempt to supply template names containing ../, absolute paths, or known sensitive file names and observe whether responses include file content.
  • Policy enforcement: Integrate automated tools or linters into CI pipelines to flag unrestricted file system access patterns and to enforce that sensitive directories (e.g., config, keys) are not readable by template-rendering components.

Sources

SourceLink
github.comgithub.com/harttle/liquidjs/security/advisories/GHSA-v273-448j-v4qj

Frequently asked

questions

Yes, if an attacker can influence the template file name or path passed into renderFile() or parseFile() over a network-facing interface, they may remotely read arbitrary files accessible to the server process.

The attacker needs the ability to control or significantly influence the file identifier used by LiquidJS to load templates. This often occurs through HTTP parameters, URL segments, or indirectly via features like user-selectable themes or templated content.

Apply strict path validation so that all file loads are resolved relative to a vetted root directory, verify the canonical path stays within that boundary, and avoid using user-supplied paths directly. Where possible, map logical template IDs to fixed file paths rather than exposing raw filesystem semantics.

Design file-loading logic under the assumption that all external inputs are untrusted, enforce strong root directory constraints with canonicalization, and include path traversal checks as a standard part of secure code review. Additionally, minimize the sensitivity of files reachable by template engines by separating secrets and configuration from template directories and using least-privilege filesystem permissions.

Find out what's already
exploitable in your codebase.