Executive brief
Mistune is a popular Python library used to convert Markdown text into HTML. A security flaw in its 'Admonition' feature allows attackers to inject malicious scripts into web pages. If a user views a page containing specially crafted Markdown, the attacker could potentially steal session information or perform unauthorized actions on the user's behalf.
Technical details
A Cross-Site Scripting (XSS) vulnerability exists in Mistune's Admonition directive implementation within `src/mistune/directives/admonition.py`. The `render_admonition()` function fails to escape the `:class:` option before concatenating it into the HTML class attribute. This oversight allows for attribute injection and XSS even when the `HTMLRenderer` is configured with `escape=True`. An attacker can exploit this by providing raw user input in the class option of an Admonition directive. The issue is resolved in version 3.3.0.
Affected products
- lepture mistune < 3.3.0
Timeline
- 2026-06-21: disclosed
- 2026-07-08: advisory: NVD publication
- 2026-07-20: advisory: GitHub Advisory published
References
- https://api.github.com/users/sergeykochanov
- https://github.com/sergeykochanov
- https://api.github.com/users/sergeykochanov/gists%7B/gist_id%7D
- https://api.github.com/users/sergeykochanov/repos
- https://avatars.githubusercontent.com/u/47022537?v=4
- https://api.github.com/users/sergeykochanov/events%7B/privacy%7D