GHSA-r4rv-85jg-w4mf

Suggest an improvement
Source
https://github.com/advisories/GHSA-r4rv-85jg-w4mf
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/07/GHSA-r4rv-85jg-w4mf/GHSA-r4rv-85jg-w4mf.json
JSON Data
https://api.test.osv.dev/v1/vulns/GHSA-r4rv-85jg-w4mf
Aliases
Published
2026-07-20T21:34:53Z
Modified
2026-08-24T00:37:07Z
Severity
  • 5.9 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N CVSS Calculator
Summary
Mistune: Arbitrary File Read via Include directive path traversal
Details

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.

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.

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"
}
References

Affected packages

PyPI / mistune

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
3.3.0

Affected versions

0.*
0.1.0
0.2.0
0.3.0
0.3.1
0.4
0.4.1
0.5
0.5.1
0.6
0.7
0.7.1
0.7.2
0.7.3
0.7.4
0.8
0.8.1
0.8.2
0.8.3
0.8.4
2.*
2.0.0a1
2.0.0a2
2.0.0a3
2.0.0a4
2.0.0a5
2.0.0a6
2.0.0rc1
2.0.0
2.0.1
2.0.2
2.0.3
2.0.4
2.0.5
2.1.0
3.*
3.0.0a1
3.0.0a2
3.0.0a3
3.0.0rc1
3.0.0rc2
3.0.0rc3
3.0.0rc4
3.0.0rc5
3.0.0
3.0.1
3.0.2
3.1.0
3.1.1
3.1.2
3.1.3
3.1.4
3.2.0
3.2.1

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/07/GHSA-r4rv-85jg-w4mf/GHSA-r4rv-85jg-w4mf.json"