CVE-2026-49851: Mistune: Potential DoS via quadratic-time parsing in parse_link_text

Published Jun 24, 2026
·
Updated

Summary Mistune is vulnerable to a CPU exhaustion DoS due to superlinear (approximately O(n²)) behavior in parselinktext. A relatively small input consisting of repeated [ characters causes significant parsing slowdown.

Affected component mistune/inlineparser.py → parselinktext

Description When parsing Markdown containing many consecutive [ characters, parselinktext repeatedly scans the input using a regex search inside a loop. Each iteration re-scans a large portion of the remaining string, resulting in quadratic-time behavior. An attacker-controlled Markdown input can therefore trigger excessive CPU usage with a very small payload.

Root cause The vulnerability stems from a two-loop interaction: - The outer loop in InlineParser.parse() (inlineparser.py) advances only 1 character at a time when parselink() returns None - Each failed attempt calls parselinktext() which performs an O(n) scan to the end of the string looking for a closing ] - With n consecutive [ characters, this results in O(n) × O(n) = O(n²) total work

PoC Run below python script import mistune import time

md = mistune.createmarkdown()

s = "[" 6400

t = time.perfcounter() md(s) print(time.perfcounter() - t) <img width="2028" height="1277" alt="image" src="https://github.com/user-attachments/assets/15d5bc0b-35f8-4a15-85e0-cbc314a45b06" />

Benmark poc Run below code for benchmark import mistune import time

md = mistune.createmarkdown()

sizes = [100,200,400,800,1600,3200,6400]

for n in sizes: s = "[" n

t0 = time.perfcounter() md(s) dt = time.perfcounter() - t0

print(f"{n:6d} {dt:.6f}") <img width="2503" height="1341" alt="image" src="https://github.com/user-attachments/assets/f09a7bbb-6927-4ba2-afb1-444dd913b84e" />

Observed behaviour python3 benchmark.py 100 0.001609 200 0.003207 400 0.012906 800 0.050220 1600 0.197307 3200 0.801172 6400 3.190393 Execution time grows superlinearly, consistent with O(n²) complex

Impact This can be used as a denial-of-service attack in any application that parses user-supplied Markdown using Mistune, including:

- Web applications (comments, posts, content rendering) - API services processing Markdown - Documentation rendering systems - A small (~6 KB) payload can block CPU for multiple seconds.

Suggested fix Return the furthest scanned position from parselinktext even on failure, so the outer loop can skip ahead instead of advancing 1 character at a time

Security Classification CWE-400: Uncontrolled Resource Consumption Denial of Service (CPU exhaustion)

Other sources

Mistune is a Python Markdown parser with renderers and plugins. Prior to 3.3.0, Mistune is vulnerable to a CPU exhaustion DoS due to superlinear (approximately O(n²)) behavior in parselinktext. When parsing Markdown containing many consecutive [ characters, parselinktext repeatedly scans the input using a regex search inside a loop. Each iteration re-scans a large portion of the remaining string, resulting in quadratic-time behavior. An attacker-controlled Markdown input can therefore trigger excessive CPU usage with a very small payload. This vulnerability is fixed in 3.3.0.

NVD

Mistune: Potential DoS via quadratic-time parsing in parselinktext

Microsoft

Affected Software

3 affected componentsFixes available
Mistune<3.3.0
Microsoft azl3 python-mistune 3.2.1-1<3.3.0-1
3.3.0-1
pip/mistune<3.3.0
3.3.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 3.3.0-1
  2. Upgrade

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

    Fixed in 3.3.0
  3. Upgrade

    Upgrade mistune to a version that resolves this vulnerability.

    Fixed in 3.3.0

Event History

Jun 24, 2026
CVE Published
via MITRE·05:05 PM
Data Sourced
via MITRE·05:05 PM
DescriptionWeakness
Data Sourced
via Red Hat·06:04 PM
DescriptionSeverityAffected Software
Data Sourced
via NVD·06:17 PM
DescriptionSeverityWeakness
Jun 27, 2026
Data Sourced
via Microsoft·08:15 AM
DescriptionSeverityWeaknessAffected Software
Updated
via Microsoft·08:15 AM
DescriptionSeverity
Jul 9, 2026
Advisory Published
via GitHub·11:52 PM
Data Sourced
via GitHub·11:52 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2026-49851?

CVE-2026-49851 has a high severity rating of 8.7.

2

How do I fix CVE-2026-49851?

To address CVE-2026-49851, upgrade Mistune to version 3.3.0 or later.

3

What type of attack does CVE-2026-49851 enable?

CVE-2026-49851 enables a denial-of-service (DoS) attack due to CPU exhaustion.

4

What versions of Mistune are affected by CVE-2026-49851?

CVE-2026-49851 affects all versions of Mistune prior to 3.3.0.

5

What is the cause of the vulnerability in CVE-2026-49851?

The vulnerability is caused by superlinear parsing behavior in the parse_link_text function when handling many consecutive '[' characters.

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