Executive brief
Mistune is a popular Python library used to convert Markdown text into HTML. A security flaw in its URL filtering allows attackers to bypass safety checks by using obscure or legacy web address formats. If a user clicks a malicious link generated by this library, an attacker could execute unauthorized code in the user's browser, potentially leading to account takeover or data theft.
Technical details
Mistune's `safe_url` function in `renderers/html.py` relies on a hardcoded `HARMFUL_PROTOCOLS` denylist that only includes 'javascript:', 'vbscript:', 'file:', and 'data:'. This approach fails to account for legacy or chained URI schemes that certain browsers (like older Firefox versions, Internet Explorer, or Edge Legacy) and browser extensions resolve to JavaScript execution. Examples of bypasses include 'feed:javascript:', 'livescript:', and 'ms-its:javascript:'. An attacker can provide these schemes in Markdown links or images to achieve XSS. The vulnerability is addressed in version 3.3.0 by moving to a strict allowlist of safe protocols.
Affected products
- lepture mistune < 3.3.0
Timeline
- 2026-06-21: disclosed
- 2026-07-20: advisory
- 2026-07-20: patched