Executive brief
Mistune is a Python library used to convert Markdown text into HTML. A vulnerability in its 'include' feature allows an attacker to provide specially crafted files that reference each other in a loop. When the library tries to process these files, it enters an infinite loop that crashes the application, leading to a denial of service.
Technical details
The 'Include' directive in Mistune's RSTDirective plugin fails to properly detect transitive inclusion cycles. While it prevents a file from including itself directly, it does not track the stack of included files during recursive parsing. An attacker with the ability to provide Markdown files (e.g., in a CMS or documentation platform) can create a cycle where 'a.md' includes 'b.md' and 'b.md' includes 'a.md'. This causes the Python interpreter to exceed its maximum recursion depth, raising a 'RecursionError' that propagates and crashes the calling process. The vulnerability is fixed in version 3.3.0 by implementing an include stack to track and reject cyclic references.
Affected products
- lepture mistune < 3.3.0
Timeline
- 2026-06-21: disclosed
- 2026-07-20: advisory
- 2026-07-20: patched: Fixed in version 3.3.0
References
- https://github.com/lepture/mistune/security/advisories/GHSA-8mpj-m6qm-5qr8
- 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-2215.yaml
- https://api.github.com/repos/lepture/mistune/security-advisories/GHSA-8mpj-m6qm-5qr8