/

CVE-2026-45017

Severity:

HIGH RISK

(7.5)

Path Traversal / Arbitrary File Inclusion (CWE-22) in Python Liquid FileSystem Loaders

CVE-2026-45017

Analyzed

Vulnerability type

Category:

Path Traversal / Arbitrary File Access

CWE:

CWE-22

Impact:

Arbitrary File Read via Template Inclusion

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

Python Liquid's FileSystemLoader and CachingFileSystemLoader can be abused to load templates from arbitrary absolute paths outside the intended search directories.

Malicious template authors who can use {% include %} or {% render %} tags may cause the application to read and render files elsewhere on the filesystem, as long as the files contain valid Liquid markup and are readable by the process.

Affected context

This vulnerability appears in Python Liquid deployments that:

  • Use the built-in FileSystemLoader or CachingFileSystemLoader
  • Allow untrusted or partially trusted users to author or influence template content
  • Enable the {% include %} and/or {% render %} tags in those templates

The risk materializes when template resolution does not restrict absolute paths, allowing the engine to reach beyond the configured template directories to any readable file that also parses as Liquid markup.

Exploit preconditions

  • Attack surface: Template rendering interface (web views, email templates, CMS pages, or other Liquid-based templating features).
  • Required access: Ability to create, upload, edit, or otherwise control Liquid templates or fragments that are rendered by the application.
  • Trigger point: Use of {% include %} or {% render %} with an absolute path that points to a file outside the configured template search paths.
  • Why exploitation is possible: The loaders accept absolute paths without enforcing that resolved files reside under approved directories, effectively bypassing the intended template root and enabling path traversal-like behavior.

Why this happens

The core issue is a lack of path normalization and enforcement of directory boundaries when resolving template paths.

Python Liquid's FileSystemLoader and CachingFileSystemLoader trust the path provided by templates and, when given an absolute path, do not verify that it lies within the configured search paths.

This behavior corresponds to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where path resolution logic fails to constrain file access to a safe subset of the filesystem.

Potential impact

  • Attackers could read and render arbitrary files that:
  • Are accessible to the application's OS user, and
  • Contain syntactically valid Liquid markup.
  • Exposure of sensitive configuration templates or internal template snippets that were not meant to be reachable from untrusted templates.
  • Leakage of application logic or proprietary template content that might aid further attacks (such as discovering variable names, data flows, or hidden template endpoints).
  • Abuse of unexpected files as templates, potentially causing logic errors or denial-of-service conditions if large or complex files are repeatedly processed as Liquid templates.

General mitigation guidance

Mitigation focuses on enforcing strict, invariant boundaries around which files may be treated as templates and minimizing who can control template content.

Common defensive patterns include:

  • Ensuring template loaders perform robust path canonicalization (e.g., resolving symlinks and dot segments) and reject:
  • Absolute paths, and
  • Paths that resolve outside configured template roots.
  • Using loader implementations that are explicitly designed to sandbox template resolution to a fixed directory tree.
  • Restricting or disabling dynamic template inclusion capabilities ({% include %}, {% render %}) for untrusted template authors, or providing only a curated set of allowed partial names.
  • Segregating templates from any other sensitive files on disk, placing them under a dedicated directory with tightly controlled contents and permissions.
  • Reducing the privileges of the application OS user so that even if path constraints fail, the process has limited visibility into sensitive filesystem locations.

How teams detect issues like this

Detection generally combines code-centric review with runtime observation:

  • Static analysis and code review:
  • Search for use of Python Liquid's FileSystemLoader or CachingFileSystemLoader, especially where templates can be supplied or edited by users.
  • Check whether custom loader wrappers enforce path normalization and directory constraints.
  • Review usages of {% include %} and {% render %} to ensure only whitelisted template names or relative paths are allowed.
  • Configuration and policy checks:
  • Enforce internal guidelines that disallow absolute template paths and mandate validation around template resolution.
  • Validate that template roots are isolated directories, not overlapping with configuration or source code paths.
  • Runtime monitoring:
  • Log template load attempts and alert on any absolute path usage or unexpected directories.
  • Use file access monitoring or application security tooling to flag Liquid-driven reads from non-template directories.

Sources

SourceLink
github.comgithub.com/jg-rp/liquid/security/advisories/GHSA-8p4x-wr7x-3788

Frequently asked

questions

It can be, if an attacker can control Liquid templates that the application renders. In typical web or CMS scenarios where end users can edit templates or content interpreted as Liquid, exploitation can occur over the network via normal application interfaces.

The attacker must be able to introduce or modify Liquid template content that is rendered with Python Liquid using the FileSystemLoader or CachingFileSystemLoader. Direct shell access is not required; control over templates and the ability to use {% include %} or {% render %} is sufficient.

The safest pattern is to strictly sandbox template resolution:

  • Disallow absolute paths in template includes and renders.
  • Ensure all resolved paths are canonicalized and verified to live under predefined template directories.
  • Where feasible, expose only named, whitelisted templates rather than allowing arbitrary path strings in include/render tags.

  • Treat template loaders as security boundaries and design them to enforce directory constraints by default.
  • Avoid granting untrusted users direct control over low-level include paths; instead, offer higher-level abstractions or component names.
  • Incorporate secure coding reviews, static analysis rules, and configuration policies that flag unrestricted file-based template loading.
  • Regularly test templating subsystems with security-focused test cases, including attempts to reference absolute or out-of-root paths.
Find out what's already
exploitable in your codebase.