GHSA-h7ww-273w-6cm8: Path Traversal
The Include directive in src/mistune/directives/include.py does not validate that the resolved file path stays within the source directory, allowing path traversal via ../ sequences to read arbitrary files.
Additionally, error messages and included file contents are rendered without HTML escaping, leading to XSS even when escape=True.
Affected functions: - Path resolution (lines 27-31) - blockerror() in html.py (line 140) - renderhtmlinclude() (line 72)
The Include plugin must be explicitly enabled via the plugins parameter.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/mistuneto a version that resolves this vulnerability.Fixed in 3.3.0 - Configuration
Only enable the Include plugin explicitly via the plugins parameter when it is required.
Mistune Include plugin plugins = explicitly enabled - Configuration
HTML-escape error messages and included file contents, including when escape=True, before rendering them.
Mistune HTML rendering HTML escaping = enabled - Compensating control
Validate that the resolved Include file path remains within the source directory before reading it, rejecting ../ path traversal sequences.