5.9medium
Mistune: Arbitrary File Read via Include directive path traversal
- Severity
- 5.9medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.40% (higher than 36% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-r4rv-85jg-w4mfPYSEC-2026-2212
Description
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| lepture mistune | < 3.3.0 | CVE List |
| mistune (PyPI) | before 3.3.0 | GitHub Advisory Database, PyPA Advisory Database |
| mistune_project mistune | before 3.3.0 | NVD |
All scores
| GitHub_M | 5.9medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N |
| GitHub | 5.9medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N |
| PyPA Advisory Database | 5.9medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
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.
GitHub Advisory Database
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.
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:
.. include:: ../../../example.txt
Process it using:
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.
NVD (es)
Mistune es un analizador de Markdown para Python con renderizadores y complementos. Antes de la versión 3.3.0, Include.parse() une y normaliza rutas de inclusión proporcionadas por el usuario sin verificar que el resultado permanezca dentro del directorio de markdown previsto, lo que permite que rutas de inclusión manipuladas accedan a archivos fuera de ese directorio cuando los archivos de markdown se procesan usando md.read(). Este problema se solucionó en la versión 3.3.0.
References
| https://github.com/lepture/mistune/security/advisories/GHSA-r4rv-85jg-w4mf | evidence, exploit, vendor-advisory, web | |
| https://github.com/lepture/mistune/commit/1bef343ade163fc3bb95572b15be720084cdb993 | fix, patch, web | |
| https://github.com/lepture/mistune/releases/tag/v3.3.0 | advisory, release-notes, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2026-59924 | advisory | |
| https://github.com/lepture/mistune | package | |
| https://github.com/pypa/advisory-database/tree/main/vulns/mistune/PYSEC-2026-2212.yaml | web | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-59924 changed 2026-07-08 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-r4rv-85jg-w4mf changed 2026-07-20 | CC-BY-4.0 |
| NVD | CVE-2026-59924 changed 2026-10-25 | Public domain |
| PyPA Advisory Database | PYSEC-2026-2212 changed 2026-07-13 | CC-BY-4.0 |