CVE-2026-59923: Mistune: XSS via percent-encoded javascript URI bypass in safe_url()

Published Jul 8, 2026
·
Updated

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 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 safeurl() protection mechanism.

PoC 1. Install vulnerable version:

pip install mistune==3.2.0

2. Run the following code:

import mistune

markdown = mistune.createmarkdown() html = markdown("j)")

print(html)

3. Output:

<p><a href="javascript%3Aalert(1)">j</a></p>

4. Open the rendered HTML in a browser and click the link.

5. 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.

Other sources

Mistune is a Python Markdown parser with renderers and plugins. Prior to 3.3.0, HTMLRenderer.safeurl() 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.

MITRE

Affected Software

3 affected componentsFixes available
Mistune Mistune<3.3.0
Mistune Project Mistune<3.3.0
pip/mistune<3.3.0
3.3.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/mistune to a version that resolves this vulnerability.

    Fixed in 3.3.0
  2. Upgrade

    Upgrade mistune to a version that resolves this vulnerability.

    Fixed in 3.3.0
  3. Compensating control

    If your application renders user-controlled Markdown with Mistune, apply additional URL sanitization beyond Mistune's HTMLRenderer.safe_url() (to prevent percent-encoded javascript: URIs) before rendering or before allowing links/images to be used.

Event History

Jul 8, 2026
CVE Published
via MITRE·04:14 PM
Data Sourced
via MITRE·04:14 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·05:17 PM
RemedyDescriptionSeverityWeaknessAffected Software
Jul 20, 2026
Advisory Published
via GitHub·09:32 PM
Data Sourced
via GitHub·09:32 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2026-59923?

The severity of CVE-2026-59923 is rated as medium with a CVSS score of 6.1.

2

How do I fix CVE-2026-59923?

To fix CVE-2026-59923, upgrade Mistune to version 3.3.0 or later.

3

What type of vulnerability is CVE-2026-59923?

CVE-2026-59923 is an cross-site scripting (XSS) vulnerability.

4

Who is affected by CVE-2026-59923?

Any user or application utilizing Mistune versions prior to 3.3.0 is at risk from CVE-2026-59923.

5

What does CVE-2026-59923 allow an attacker to do?

CVE-2026-59923 allows an attacker to bypass URL protections and potentially execute malicious scripts in rendered HTML.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203