Loading advisory.
Loading advisory.
Mistune: XSS via percent-encoded javascript URI bypass in safe_url()
An XSS vulnerability in Mistune allows bypassing of safe_url() protections via percent-encoded javascript URIs.
Published 2026-07-08 16:14 UTC · Modified 2026-07-20 21:46 UTC
Severity and EPSS are shown separately. Helm does not combine them into one score.
| Package | Ecosystem | Affected | Fixed in | Upgrade command |
|---|---|---|---|---|
| mistune | PyPI | < 3.3.0 versions 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.0.0 and 31 more | 3.3.0 | pip install --upgrade 'mistune>=3.3.0' |
An XSS vulnerability in Mistune allows bypassing of safe_url() protections via percent-encoded javascript URIs.
The vulnerability exists in HTMLRenderer.safe_url() in Mistune.
The function is intended to block harmful URL schemes such as "javascript:" by checking the prefix of the provided URL:
_url = url.lower()
if _url.startswith(self.HARMFUL_PROTOCOLS):
return "#harmful-link"However, the input URL is not URL-decoded before this check. Because of this, an attacker can use percent-encoding to bypass the filter. For example:
javascript%3Aalert(1)Since "%3A" is not decoded to ":", the check does not detect the "javascript:" scheme.
When rendered in a browser, the URL is decoded, resulting in execution of arbitrary JavaScript upon user interaction.
This effectively bypasses Mistune's built-in safe_url() protection mechanism.
Install vulnerable version:
pip install mistune==3.2.0
Run the following code:
import mistune
markdown = mistune.create_markdown() html = markdown("j")
print(html)
Output:
<p><a href="javascript%3Aalert(1)">j</a></p>
Open the rendered HTML in a browser and click the link.
The browser decodes "%3A" into ":" and executes:
javascript:alert(1)
This is a cross-site scripting (XSS) vulnerability.
An attacker can craft a malicious Markdown link that executes JavaScript in the victim's browser when clicked.
Impact includes:
Session hijacking (e.g., cookie theft)
Execution of arbitrary JavaScript in the victim's context
Potential account takeover depending on the application
This affects any application that renders user-controlled Markdown using Mistune without additional URL sanitization.
No public exploit code known to Helm's sources (Nuclei templates, Metasploit, Exploit-DB and PoC-in-GitHub). That does not mean none exists.
One EPSS score on record: 0.003 on 2026-11-24.
| Date | Score | Previous | Model |
|---|---|---|---|
| 2026-11-24 | 0.003 | first score | v2026.06.15 |