CVE-2026-59924: Mistune: Arbitrary File Read via Include directive path traversal
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.parsetitle(m) dest = os.path.join(os.path.dirname(sourcefile), 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.createmarkdown( 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.
Other sources
Mistune is a Python Markdown parser with renderers and plugins. Prior to 3.3.0, Include.parse() joins and normalizes user-supplied include paths without verifying that the result remains within the intended markdown directory, allowing crafted include paths to access files outside that directory when markdown files are processed using md.read(). This issue is fixed in version 3.3.0.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/mistuneto a version that resolves this vulnerability.Fixed in 3.3.0 - Upgrade
Upgrade
mistuneto a version that resolves this vulnerability.Fixed in 3.3.0 - Configuration
When using Mistune's `Include` directive (in `Include.parse()`), validate the resolved path after `os.path.join()` and `os.path.normpath()` to ensure it remains within the trusted/allowed base markdown directory; block/ignore any resolved paths containing traversal (e.g., `../`) that would escape the allowed directory before opening the included file.
Include directive path handling (Mistune Include.parse) base-directory validation for resolved include paths = Validate that the normalized/joined resolved path remains within the intended markdown directory before opening the file
Event History
Frequently Asked Questions
What is the severity of CVE-2026-59924?
The severity of CVE-2026-59924 is classified as medium with a score of 5.9.
What does CVE-2026-59924 affect?
CVE-2026-59924 affects the Mistune Python Markdown parser prior to version 3.3.0.
How do I fix CVE-2026-59924?
To fix CVE-2026-59924, upgrade Mistune to version 3.3.0 or later.
What type of vulnerability is CVE-2026-59924?
CVE-2026-59924 is a path traversal vulnerability that allows arbitrary file read.
What impact does CVE-2026-59924 have on systems?
CVE-2026-59924 allows crafted include paths to access files outside the intended markdown directory, potentially leaking sensitive information.