Listen to this Post
How CVE-2026-59924 Works
Mistune is a Python Markdown parser with renderers and plugins. Prior to version 3.3.0, a path traversal vulnerability existed in the `Include` directive, specifically within the `Include.parse()` method.
The core issue lies in how user-supplied include paths are processed. When a markdown file containing an `.. include::` directive is parsed using md.read(), the `Include.parse()` method joins the user-supplied path with the directory of the source file and normalizes the result:
relpath = self.parse_(m) dest = os.path.join(os.path.dirname(source_file), relpath) dest = os.path.normpath(dest)
The critical flaw is that after normalization, the resulting path is not verified to ensure it remains within the intended markdown directory. This allows an attacker to use path traversal sequences such as `../` to escape the intended directory and access arbitrary files on the filesystem. The vulnerability leverages the fundamental principle of path traversal attacks, where relative path components are exploited to gain access to restricted file systems.
The impact can be significant. An attacker could craft a malicious markdown file with an include directive pointing to sensitive system files (e.g., /etc/passwd, configuration files, database credentials, or application source code). When processed by a vulnerable application, these files would be read and potentially exposed. The vulnerability is classified under CWE-22 (Improper Limitation of a Pathname to a Restricted Directory).
The issue is fixed in Mistune version 3.3.0, which introduces proper path validation to ensure normalized include paths remain within the intended directory boundaries before processing.
DailyCVE Form:
| Field | Value |
|-|-|
| Platform | Mistune (Python) |
| Version | < 3.3.0 |
| Vulnerability | Path Traversal (CWE-22) |
| Severity | Medium (CVSS 5.9) |
| Date | 2026-07-08 |
| Prediction | 2026-07-22 (within 2 weeks) |
What Undercode Say:
Analytics & Technical Breakdown:
Check installed mistune version pip show mistune | grep Version Vulnerable versions: < 3.3.0 Fixed version: 3.3.0
Proof of Concept – Malicious Markdown File (`test.md`):
.. include:: ../../../etc/passwd
Proof of Concept – Python Exploit Script:
import mistune
from mistune.directives import RSTDirective, Include
Create markdown parser with Include directive enabled
md = mistune.create_markdown(
plugins=[RSTDirective([Include()])]
)
Process malicious markdown file
result, state = md.read("test.md")
print(result) Will print contents of /etc/passwd if accessible
Vulnerable Code Snippet (src/mistune/directives/include.py):
def parse(self, m, state): ... relpath = self.parse_(m) dest = os.path.join(os.path.dirname(source_file), relpath) dest = os.path.normpath(dest) No directory boundary check! ...
Exploit:
An attacker can exploit this vulnerability by:
- Crafting a malicious Markdown file containing an include directive with `../` sequences targeting sensitive files outside the intended directory.
- Submitting the file to an application that processes untrusted Markdown content using `md.read()` with the `Include` directive enabled.
- Triggering the path traversal when the application calls
Include.parse(), which joins and normalizes the path without validating it stays within the allowed directory. - Exfiltrating the file contents as the parsed Markdown output includes the content of the traversed file.
The attack requires no authentication (PR:NONE) and no user interaction (UI:NONE), though the attack complexity is rated as `HIGH` due to the need to know or guess valid path locations.
Protection:
- Upgrade to Mistune 3.3.0 or later – This is the primary and most effective mitigation.
- Implement strict input validation for all include paths – validate that resolved paths remain within the intended markdown directory.
- Restrict file system permissions for the process running Markdown parsing – limit access to only necessary directories.
- Use a whitelist approach for allowed include paths rather than accepting arbitrary user input.
- Monitor application logs for suspicious path patterns (e.g.,
../,/etc/,/proc/). - If upgrading is not immediately possible, consider disabling the `Include` directive plugin entirely:
md = mistune.create_markdown(plugins=[]) Exclude RSTDirective with Include
Impact:
- Confidentiality Impact: HIGH – Attackers can read arbitrary files accessible to the running process, including sensitive configuration files, database credentials, application source code, and system files.
- Integrity Impact: NONE – The vulnerability only allows reading files, not modifying them.
- Availability Impact: NONE – The vulnerability does not cause denial of service.
- Scope: UNCHANGED – The vulnerable component does not affect resources beyond its security scope.
- Attack Vector: NETWORK – The vulnerability can be exploited remotely by submitting malicious Markdown content.
- Potential for Further Exploitation – Information disclosure can enable privilege escalation or remote code execution depending on the application’s access controls and the nature of accessible files.
🎯Let’s Practice Exploiting & Learn Patching For Free:
🎓 Live Courses & Certifications:
Join Undercode Academy for Verified Certifications
🚀 Request a Custom Project:
Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands
Sources:
Reported By: github.com
Extra Source Hub:
Undercode

