CVE-2026-59923: Mistune: XSS via percent-encoded javascript URI bypass in safe_url()
Summary An XSS vulnerability in Mistune allows bypassing of safeurl() protections via percent-encoded javascript URIs. Details The vulnerability exists in HTMLRenderer.safeurl() 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.HARMFULPROTOCOLS): return "#harmful-link" However, the input URL is…
Published Jul 20, 2026
Affected packages
mistune
- Ecosystem
- PyPI
- Affected
- < 3.3.0
- Fixed in
- 3.3.0
- Check
pip show mistune
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
An XSS vulnerability in Mistune allows bypassing of safe_url() protections via percent-encoded javascript URIs.
Details
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.
PoC
- Install vulnerable version:
pip install mistune==3.2.0
- Run the following code:
import mistune
markdown = mistune.create_markdown() html = markdown("[j](javascript%3Aalert(1))")
print(html)
- Output:
j
- Open the rendered HTML in a browser and click the link.
- The browser decodes "%3A" into ":" and executes:
javascript:alert(1)
Impact
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.
Credited to redyank.
References
- https://github.com/lepture/mistune/security/advisories/GHSA-8c25-4j27-2rv3
- https://nvd.nist.gov/vuln/detail/CVE-2026-59923
- https://github.com/lepture/mistune/commit/c7101fcbb6e8790e8e39157c5ca2238fc6dd6cbc
- https://github.com/lepture/mistune/releases/tag/v3.3.0
- https://github.com/pypa/advisory-database/tree/main/vulns/mistune/PYSEC-2026-2211.yaml
- https://github.com/advisories/GHSA-8c25-4j27-2rv3
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More PyPI vulnerabilities
All PyPI entriesCVE-2026-97698
Mistune: Quadratic-time DoS in parse_link_href via unbounded parenthesis scan on empty-label links
high7.5Nov 19, 2026CVE-2026-97699
Mistune: Quadratic-time DoS in inline image parsing (precedence_scan) bypasses not-is-image guards
high7.5Nov 19, 2026CVE-2026-115355
Mistune: Path Traversal and XSS in Include directive
highOct 23, 2026CVE-2026-76098
Mistune: Denial of Service — RecursionError via Excessive Emphasis Markers in Markdown
high7.5Sep 2, 2026CVE-2026-59922
Mistune plugins/formatting: quadratic-time parsing on long runs of `~~x~~`, `==x==`, and `^^x^^` markers (strikethrough / mark / insert)
high7.5Jul 20, 2026CVE-2026-59924
Mistune: Arbitrary File Read via Include directive path traversal
medium5.9Jul 20, 2026
