GHSA-R4RV-85JG-W4MF
Vulnerability from github – Published: 2026-07-20 21:34 – Updated: 2026-07-20 21:34Summary
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.
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "mistune"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "3.3.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-59924"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2026-07-20T21:34:53Z",
"nvd_published_at": "2026-07-08T17:17:28Z",
"severity": "MODERATE"
},
"details": "### Summary\n\nA path traversal issue exists in mistune\u0027s `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.\n\n### Details\n\nThe 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.\n\n```python\nrelpath = self.parse_title(m)\ndest = os.path.join(os.path.dirname(source_file), relpath)\ndest = os.path.normpath(dest)\n```\n\nBecause the final path is not restricted to a trusted base directory, path traversal sequences such as `../` may reference files outside the intended location.\n\n### Proof of Concept\n\nCreate a markdown file:\n\n```markdown\n.. include:: ../../../example.txt\n```\n\nProcess it using:\n\n```python\nimport mistune\nfrom mistune.directives import RSTDirective, Include\n\nmd = mistune.create_markdown(\n plugins=[RSTDirective([Include()])]\n)\n\nresult, state = md.read(\"test.md\")\nprint(result)\n```\n\n### Impact\n\nApplications 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.\n\n### Recommended Fix\n\nValidate the resolved path and ensure it remains within an allowed directory before opening the file.",
"id": "GHSA-r4rv-85jg-w4mf",
"modified": "2026-07-20T21:34:53Z",
"published": "2026-07-20T21:34:53Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/lepture/mistune/security/advisories/GHSA-r4rv-85jg-w4mf"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-59924"
},
{
"type": "WEB",
"url": "https://github.com/lepture/mistune/commit/1bef343ade163fc3bb95572b15be720084cdb993"
},
{
"type": "PACKAGE",
"url": "https://github.com/lepture/mistune"
},
{
"type": "WEB",
"url": "https://github.com/lepture/mistune/releases/tag/v3.3.0"
},
{
"type": "WEB",
"url": "https://github.com/pypa/advisory-database/tree/main/vulns/mistune/PYSEC-2026-2212.yaml"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N",
"type": "CVSS_V3"
}
],
"summary": "Mistune: Arbitrary File Read via Include directive path traversal"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.