Mistune Path Traversal and XSS Flaw Exposes Python Markdown Processors
A high-severity vulnerability in Mistune before version 3.3.0 allows attackers to read arbitrary files and inject cross-site scripting via crafted include directives.
Key points
- The flaw affects Mistune versions prior to 3.3.0 and is rated CVSS 8.7 HIGH by NVD.
- Attackers can traverse directories using dot-dot-slash sequences in include paths to access sensitive files.
- Cross-site scripting is possible through unescaped error messages, even when escape settings are enabled.
The Python Markdown processor Mistune contains a path traversal vulnerability that permits unauthorized file access. According to the National Vulnerability Database, this flaw exists in versions before 3.3.0. The issue stems from how the library handles include directives, allowing attackers to supply relative path sequences. This enables reading arbitrary files on the server hosting the application. The vulnerability also allows for cross-site scripting through unescaped content.
Root cause
The core issue lies in the processing of include directives within Mistune. The library fails to properly sanitize paths provided in these directives. Attackers can insert sequences of dots and slashes to move up the directory tree. This bypasses intended file access restrictions. Additionally, error messages generated during this process are not escaped correctly. This secondary flaw allows injection of HTML scripts even when the escape parameter is set to true.
Attack path
An attacker crafts a Markdown document containing a malicious include directive. This directive uses path traversal sequences to point to sensitive system files. When the application processes this Markdown, it reads the targeted file. The contents of the file or the resulting error messages are then rendered as HTML. This enables cross-site scripting attacks against users viewing the rendered content. The attack requires no authentication if the application processes untrusted Markdown input.
Affected versions
- Mistune versions before 3.3.0 are affected by this vulnerability.
- Applications using Mistune for Markdown rendering are exposed.
- Environments processing untrusted Markdown input are at highest risk.
Mitigation
- Upgrade Mistune to version 3.3.0 or later as soon as possible.
- Validate and sanitize all Markdown input before processing.
- Restrict file access permissions for the application user.
- Monitor logs for unusual file access patterns or directory traversal attempts.
Signals worth monitoring
Security teams should monitor web server logs for requests containing dot-dot-slash sequences in query parameters or body content. Alert on responses that return sensitive file contents or unexpected HTML structures. Check for JavaScript execution in contexts where Markdown is rendered. Investigate any instances where error messages contain user-controlled data. Look for anomalies in file access logs that indicate attempts to read configuration or credential files.
What to do and how to stay safe: Mistune
- Audit your applications for usage of Mistune and verify the installed version.
- Implement strict input validation for any Markdown processing endpoints.
- Monitor server logs for path traversal patterns and unusual file access.
- Prepare an incident response plan for potential data exposure scenarios.
Step-by-step guide: Attack Surface Management: 6 Common Misreadings and Correct Views
General security guidance from the NetSec Observer newsroom. It is not confirmed advice from the organisations named in this story.
Frequently asked questions
What is the severity of CVE-2026-115355?
The National Vulnerability Database rates this vulnerability as HIGH with a CVSS score of 8.7.
Which versions of Mistune are affected?
All versions of Mistune prior to 3.3.0 are affected by this path traversal and XSS vulnerability.
Can this vulnerability be exploited without authentication?
Yes, if the application processes untrusted Markdown input, attackers can exploit this without authentication.




