/

CVE-2026-115355

Severity:

HIGH RISK

(7.5)

Path Traversal (CWE-22) in Mistune Include Directive

CVE-2026-115355

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Read and Cross-Site Scripting

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

Mistune before 3.3.0 contains a path traversal vulnerability in its Include directive, allowing attackers to read files outside the intended include directory when supplied paths are not safely constrained. Included file contents and error messages may also be rendered without adequate escaping, enabling cross-site scripting even when escape=True is configured.

Mistune before 3.3.0 contains a path traversal vulnerability in its Include directive, allowing attackers to read files outside the intended include directory when supplied paths are not safely constrained. Included file contents and error messages may also be rendered without adequate escaping, enabling cross-site scripting even when escape=True is configured.

Affected context

The vulnerability occurs in applications that use Mistune's Include directive to incorporate local files into rendered Markdown or HTML and allow attacker-influenced include paths or document content. Risk increases when the process can access sensitive files, when rendered output is displayed in a browser, or when escaping is assumed to cover included content and error messages.

The vulnerability occurs in applications that use Mistune's Include directive to incorporate local files into rendered Markdown or HTML and allow attacker-influenced include paths or document content. Risk increases when the process can access sensitive files, when rendered output is displayed in a browser, or when escaping is assumed to cover included content and error messages.

Exploit preconditions

  • Attack surface: Markdown or document processing that enables Mistune's Include directive
  • Required access: Ability to submit or influence content containing an include reference, or otherwise control an include path
  • Trigger point: Resolution and rendering of the Include directive
  • Why exploitation is possible: Insufficient path confinement can allow traversal outside the intended directory, while unescaped included data or errors can reach browser-rendered output
  • Attack surface: Markdown or document processing that enables Mistune's Include directive
  • Required access: Ability to submit or influence content containing an include reference, or otherwise control an include path
  • Trigger point: Resolution and rendering of the Include directive
  • Why exploitation is possible: Insufficient path confinement can allow traversal outside the intended directory, while unescaped included data or errors can reach browser-rendered output

Why this happens

The primary flaw is improper limitation of a user-influenced file path, mapping to CWE-22: Improper Limitation of a Pathname to a Restricted Directory. The include resolver does not reliably enforce that the resolved path remains within its permitted base directory. Separately, output generated from included file contents and error messages may bypass the configured escaping behavior, creating a cross-site scripting condition when rendered in a browser.

The primary flaw is improper limitation of a user-influenced file path, mapping to CWE-22: Improper Limitation of a Pathname to a Restricted Directory. The include resolver does not reliably enforce that the resolved path remains within its permitted base directory. Separately, output generated from included file contents and error messages may bypass the configured escaping behavior, creating a cross-site scripting condition when rendered in a browser.

Potential impact

  • Attackers may read sensitive files accessible to the Mistune process
  • Exposed files may disclose credentials, configuration data, or source code
  • Malicious content may execute script in a victim's browser context
  • Session data or user actions may be exposed through cross-site scripting
  • Downstream systems may process or store unintended file contents
  • Attackers may read sensitive files accessible to the Mistune process
  • Exposed files may disclose credentials, configuration data, or source code
  • Malicious content may execute script in a victim's browser context
  • Session data or user actions may be exposed through cross-site scripting
  • Downstream systems may process or store unintended file contents

General mitigation guidance

Mitigation generally focuses on enforcing a strict trust boundary around include paths and ensuring every rendered data source is safely encoded for its output context.

Common defensive patterns include:

  • Resolve include paths canonically and verify they remain within an explicitly permitted directory
  • Prefer an allowlist of permitted files or logical document identifiers over filesystem paths
  • Reject traversal, absolute paths, symlink escapes, and unexpected path forms
  • Apply context-appropriate output encoding to included content and error messages
  • Avoid exposing detailed filesystem errors to untrusted users
  • Run document processing with least-privilege filesystem access
  • Treat the escape setting as insufficient unless all rendering paths consistently honor it

Mitigation generally focuses on enforcing a strict trust boundary around include paths and ensuring every rendered data source is safely encoded for its output context.

Common defensive patterns include:

  • Resolve include paths canonically and verify they remain within an explicitly permitted directory
  • Prefer an allowlist of permitted files or logical document identifiers over filesystem paths
  • Reject traversal, absolute paths, symlink escapes, and unexpected path forms
  • Apply context-appropriate output encoding to included content and error messages
  • Avoid exposing detailed filesystem errors to untrusted users
  • Run document processing with least-privilege filesystem access
  • Treat the escape setting as insufficient unless all rendering paths consistently honor it

How teams detect issues like this

Detection can include:

  • Static analysis rules for filesystem reads based on user-influenced paths
  • Code review checks for path joining without canonicalization and containment validation
  • Tests covering traversal sequences, absolute paths, symlinked files, and encoding behavior
  • Review of Markdown configurations that enable local file inclusion
  • Dynamic testing for unintended file disclosure and unescaped output in rendered documents
  • Policy enforcement that restricts document processors from reading outside approved directories

Automated security scanning and code review tools may help identify unsafe path handling and incomplete output encoding.

Detection can include:

  • Static analysis rules for filesystem reads based on user-influenced paths
  • Code review checks for path joining without canonicalization and containment validation
  • Tests covering traversal sequences, absolute paths, symlinked files, and encoding behavior
  • Review of Markdown configurations that enable local file inclusion
  • Dynamic testing for unintended file disclosure and unescaped output in rendered documents
  • Policy enforcement that restricts document processors from reading outside approved directories

Automated security scanning and code review tools may help identify unsafe path handling and incomplete output encoding.

Sources

SourceLink
github.comgithub.com/lepture/mistune/security/advisories/GHSA-h7ww-273w-6cm8
vulncheck.comvulncheck.com/advisories/mistune-before-3.3.0-path-traversal-and-xss-via-include-directive

Frequently asked

questions

It can be remotely exploitable when an application accepts attacker-controlled Markdown or include references and processes them on a server with access to sensitive files. The exact scope depends on how documents and rendered output are exposed.

An attacker generally needs the ability to submit or influence content processed by Mistune, or to control an include path. They do not necessarily need local operating-system access.

Constrain includes to an approved directory or file allowlist, validate canonical resolved paths before reading, and apply reliable context-specific output encoding to all included content and errors.

Treat file paths and document content as untrusted, use least-privilege process permissions, test traversal and browser-rendering edge cases, and enforce security review rules for file inclusion and output encoding.

It can be remotely exploitable when an application accepts attacker-controlled Markdown or include references and processes them on a server with access to sensitive files. The exact scope depends on how documents and rendered output are exposed.

An attacker generally needs the ability to submit or influence content processed by Mistune, or to control an include path. They do not necessarily need local operating-system access.

Constrain includes to an approved directory or file allowlist, validate canonical resolved paths before reading, and apply reliable context-specific output encoding to all included content and errors.

Treat file paths and document content as untrusted, use least-privilege process permissions, test traversal and browser-rendering edge cases, and enforce security review rules for file inclusion and output encoding.

Find out what's already
exploitable in your codebase.