6.1medium
Mistune: XSS via percent-encoded javascript URI bypass in safe_url()
- Severity
- 6.1medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.24% (higher than 15% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-8c25-4j27-2rv3PYSEC-2026-2211
Description
Mistune is a Python Markdown parser with renderers and plugins. Prior to 3.3.0, HTMLRenderer.safe_url() does not block percent-encoded javascript URIs, allowing attacker-supplied Markdown links or images to bypass URL protections and execute script in rendered HTML. This issue is fixed in version 3.3.0.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| lepture mistune | < 3.3.0 | CVE List |
| mistune (PyPI) | before 3.3.0 | GitHub Advisory Database, PyPA Advisory Database |
| mistune_project mistune | before 3.3.0 | NVD |
All scores
| GitHub_M | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
| GitHub | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
| PyPA Advisory Database | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
Classification
SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.
What each source says
CVE List
Mistune is a Python Markdown parser with renderers and plugins. Prior to 3.3.0, HTMLRenderer.safe_url() does not block percent-encoded javascript URIs, allowing attacker-supplied Markdown links or images to bypass URL protections and execute script in rendered HTML. This issue is fixed in version 3.3.0.
GitHub Advisory Database
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")
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)
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.
NVD (es)
Mistune es un analizador de Markdown en Python con renderizadores y complementos. Antes de la versión 3.3.0, HTMLRenderer.safe_url() no bloquea las URIs de javascript codificadas por porcentaje, lo que permite que los enlaces o imágenes de Markdown proporcionados por el atacante eludan las protecciones de URL y ejecuten scripts en el HTML renderizado. Este problema se corrigió en la versión 3.3.0.
References
| https://github.com/lepture/mistune/security/advisories/GHSA-8c25-4j27-2rv3 | evidence, exploit, vendor-advisory, web | |
| https://github.com/lepture/mistune/commit/c7101fcbb6e8790e8e39157c5ca2238fc6dd6cbc | fix, patch, web | |
| https://github.com/lepture/mistune/releases/tag/v3.3.0 | advisory, release-notes, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2026-59923 | advisory | |
| https://github.com/lepture/mistune | package | |
| https://github.com/pypa/advisory-database/tree/main/vulns/mistune/PYSEC-2026-2211.yaml | web | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-59923 changed 2026-07-08 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-8c25-4j27-2rv3 changed 2026-07-20 | CC-BY-4.0 |
| NVD | CVE-2026-59923 changed 2026-10-25 | Public domain |
| PyPA Advisory Database | PYSEC-2026-2211 changed 2026-07-13 | CC-BY-4.0 |