Описание
Mistune: Arbitrary File Read via Include directive path traversal
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.
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:
Process it using:
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.
Ссылки
- https://github.com/lepture/mistune/security/advisories/GHSA-r4rv-85jg-w4mf
- https://nvd.nist.gov/vuln/detail/CVE-2026-59924
- https://github.com/lepture/mistune/commit/1bef343ade163fc3bb95572b15be720084cdb993
- https://github.com/lepture/mistune/releases/tag/v3.3.0
- https://github.com/pypa/advisory-database/tree/main/vulns/mistune/PYSEC-2026-2212.yaml
Пакеты
mistune
< 3.3.0
3.3.0
Связанные уязвимости
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.
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.
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.
Mistune is a Python Markdown parser with renderers and plugins. Prior ...