{"id":"CVE-2026-59924","aliases":["GHSA-r4rv-85jg-w4mf","PYSEC-2026-2212"],"url":"https://o3.security/vulnerability/CVE-2026-59924","summary":"Mistune: Arbitrary File Read via Include directive path traversal","details":"### Summary\n\nA 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.\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.","published":"2026-07-08T16:22:11.116Z","modified":"2026-10-21T02:30:45.262806592Z","cvss":{"score":5.9,"severity":"MEDIUM","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N"},"epss":{"score":0.00462,"percentile":0.39071,"asOf":"2026-09-16"},"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"PyPI","name":"mistune","fixedVersion":"3.3.0"}],"fix":{"url":"https://github.com/lepture/mistune/commit/1bef343ade163fc3bb95572b15be720084cdb993","label":"lepture/mistune@1bef343"},"references":[{"type":"WEB","url":"https://github.com/lepture/mistune/releases/tag/v3.3.0"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/59xxx/CVE-2026-59924.json"},{"type":"ADVISORY","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":"FIX","url":"https://github.com/lepture/mistune/commit/1bef343ade163fc3bb95572b15be720084cdb993"},{"type":"PACKAGE","url":"https://github.com/lepture/mistune"},{"type":"WEB","url":"https://github.com/pypa/advisory-database/tree/main/vulns/mistune/PYSEC-2026-2212.yaml"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-10-21T02:30:45.262806592Z"}}