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/orparseFile()for loading templates from disk - Rely on the
rootconfiguration 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()orparseFile()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()orparseFile()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
rootboundary 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()andparseFile()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.

