GitHub Advisoryadvisory · PyPI

GHSA-r4rv-85jg-w4mf Mistune: Arbitrary File Read via Include directive path traversal

MEDIUM Published 2026-07-20 Modified 2026-07-20 Official page ↗
Aliases
CVE-2026-59924
Ecosystem
PyPI
Packages
mistune
Severity
Moderate
CVSS vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N
Weaknesses
CWE-22
Reviewed
2026-07-20

Affected packages

• PyPI mistune: < 3.3.0 → fixed in 3.3.0

Description

Summary A path traversal issue exists in mistune's `Include` directive when markdown files are processed using `md.read()`. A crafted include path can cause files outside the intended markdown directory to be accessed. Details The issue occurs in the `Include.parse()` method where user-supplied paths are joined and normalized without verifying that the resulting path remains within an expected directory. ```python relpath = self.parse_title(m) dest = os.path.join(os.path.dirname(source_file), relpath) dest = os.path.normpath(dest) ``` Because the final path is not restricted to a trusted base directory, path traversal sequences such as `../` may reference files outside the intended location. Proof of Concept Create a markdown file: ```markdown .. include:: ../../../example.txt ``` Process it using: ```python import mistune from mistune.directives import RSTDirective, Include md = mistune.create_markdown( plugins=[RSTDirective([Include()])] ) result, state = md.read("test.md") print(result) ``` Impact Applications that process untrusted markdown files with the `Include` directive enabled may allow unintended file access. The impact depends on how the feature is used and what files are accessible to the running process. Recommended Fix Validate the resolved path and ensure it remains within an allowed directory before opening the file.

Related

Alias · CVE (1)

  • CVE-2026-59924 Mistune is a Python Markdown parser with renderers and plugins. vulnerability

Weakness · CWE (1)

  • CWE-22 Improper Limitation of a Pathname to a Restricted Directory weakness

References