VDB
Sign up
HIGH

GHSA-h7ww-273w-6cm8

Mistune: Path Traversal and XSS in Include directive

Quick fix

GHSA-h7ww-273w-6cm8 — mistune: upgrade to the fixed version with the command below.

pip install --upgrade 'mistune>=3.3.0'

Details

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) - `block_error()` in html.py (line 140) - `render_html_include()` (line 72)

The Include plugin must be explicitly enabled via the plugins parameter.

Are you affected?

Enter the version of the package you're using.

Affected packages

PyPI/mistune
Introduced in: 0Fixed in: 3.3.0
Fixpip install --upgrade 'mistune>=3.3.0'

References