CVE-2026-59925: inline_parser: quadratic-time parsing on long runs of `**x**` and `***x***` emphasis pairs

Published Jul 8, 2026
·
Updated

Summary

Type: Algorithmic-complexity DoS in core emphasis parsing. A long sequence of well-formed x (strong) or x (strong-emphasis combined) pairs causes O(N²) parser work. Distinct from the bracket-bomb DoS ([ repetition) and from the formatting-plugin DoS (~~/==/^^); this one fires on default-config mistune with no plugins required. File: src/mistune/inlineparser.py lines 41-48 (the EMPHASISENDRE family) and the surrounding emphasis dispatch. Root cause: for every opening run of s the parser scans forward using one of EMPHASISENDRE[''] / [''] / [''] to find the matching close. Each scan is bounded per call, but the parser invokes the scan from every potential start position. For input shaped x repeated N times, every is treated as a potential start, each scan can cover up to the end of input. Total work is O(N²). The triple-emphasis variant x is slightly worse due to the extra alternation between , , and close patterns. Reproducible against default mistune with no plugins.

Affected Code

File: src/mistune/inlineparser.py, lines 41-48.

python EMPHASISENDRE = { "": re.compile(r"(?:" + PREVENTBACKSLASH + r"\\\|[^\s])\(?!\)"), "": re.compile(r"(?:" + PREVENTBACKSLASH + r"\\|[^\s])(?!)\b"), "": re.compile(r"(?:" + PREVENTBACKSLASH + r"\\\|[^\s])\\(?!\)"), "": re.compile(r"(?:" + PREVENTBACKSLASH + r"\\|[^\s])(?!)\b"), "": re.compile(r"(?:" + PREVENTBACKSLASH + r"\\\|[^\s])\\\(?!\)"), "": re.compile(r"(?:" + PREVENTBACKSLASH + r"\\|[^\s])(?!)\b"), } Each of the six end-patterns is invoked from every emphasis open position fired by the inline rule r"\{1,3}(?=[^\s])|\b{1,3}(?=[^\s])". The scan itself is bounded per call; the cost comes from the parser invoking the scan at every matching open marker, giving O(N²) total work.

Why it's wrong: same shape as the formatting-plugin and bracket-bomb DoS findings. The CommonMark reference parser handles emphasis in linear time using a delimiter-stack algorithm (commonmark.js, commonmark-py, markdown-it-py all do this). mistune retries the close-scan from each open marker. The bounded regex is not enough; the surrounding loop is the source of the quadratic.

Exploit Chain

1. Application uses mistune to render user-supplied markdown. No plugins required — affects the default mistune.createmarkdown() configuration. 2. Attacker submits a 40 KB payload of x repeated 8000 times. 3. Server CPU pegs for ~4 seconds; 16 KB → ~17 seconds. Doubling input quadruples time. 4. Repeating the request floods the worker pool.

Security Impact

Severity: sec-high. Network-reachable, no authentication, no plugin requirement. Default mistune is vulnerable. Attacker capability: O(N²) CPU cost from a single small input. Predictable scaling, easy to combine with concurrent requests for service denial. Preconditions: application uses mistune.createmarkdown() (default config) on attacker-supplied markdown. No plugins required. Differential: PoC-verified against mistune@3.2.1, default config:

python import mistune, time md = mistune.createmarkdown() # no plugins for n in [500, 1000, 2000, 4000, 8000]: s = 'x' n t = time.time() md(s) print(f' x {n} ({len(s)}b): {(time.time() - t) 1000:.0f}ms')

Output (Python 3.13, Linux, 2.5GHz CPU): x 500 (2500b): 20ms x 1000 (5000b): 74ms x 2000 (10000b): 284ms x 4000 (20000b): 1079ms x 8000 (40000b): 4309ms

Triple-emphasis is similar: md('x' 4000) # ~1500ms

Linear in N for non-emphasis input of comparable size: md('xxxxx' 8000) # 1ms (4000x faster)

The patched build (with the suggested fix below — delimiter-stack rewrite or hard cap on simultaneous open markers) keeps the time linear in N.

Suggested Fix

Cap the number of unmatched opening emphasis markers the parser will track simultaneously, treating the rest as literal text:

diff --- a/src/mistune/inlineparser.py +++ b/src/mistune/inlineparser.py @@ ... in the emphasis-handling code path + # Bound the number of open emphasis markers tracked. CommonMark gives + # no semantics to deeply nested unmatched emphasis; this cap turns the + # parser-level O(N^2) into O(N) for adversarial inputs while preserving + # behaviour on every realistic markdown document. + MAXOPENEMPHASIS = 100 + if openemphasiscount > MAXOPENEMPHASIS: + # treat remaining / as literal text + ...

The proper fix is a delimiter-stack pass, the same approach the formatting-plugin advisory and the bracket-bomb advisory recommend. All three DoS findings share the same algorithmic pattern; a single rewrite of the inline-token retry loop closes them together. Add a regression test asserting that md('x' 50000) completes in under 1 second.

Other sources

Mistune is a Python Markdown parser with renderers and plugins. Prior to 3.3.0, long sequences of well-formed double-asterisk or triple-asterisk emphasis pairs around a character cause quadratic work in src/mistune/inlineparser.py because the parser scans forward for matching close markers from every potential opening run, allowing denial of service in default Mistune parsing. 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. Configuration

    Cap the number of unmatched opening emphasis markers tracked simultaneously. In src/mistune/inline_parser.py, set MAX_OPEN_EMPHASIS = 100; when open_emphasis_count exceeds this cap, treat remaining '*'/ '_' runs as literal text to prevent O(N^2) close-scanning DoS.

    mistune inline emphasis parsing (src/mistune/inline_parser.py) MAX_OPEN_EMPHASIS = 100

Event History

Jul 8, 2026
CVE Published
via MITRE·04:18 PM
Data Sourced
via MITRE·04:18 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-59925?

CVE-2026-59925 has a severity score of 7.5, classifying it as high risk.

2

How do I fix CVE-2026-59925?

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

3

What does CVE-2026-59925 impact?

CVE-2026-59925 impacts the Mistune Markdown parser, specifically its handling of double-asterisk and triple-asterisk emphasis pairs.

4

What kind of vulnerability is CVE-2026-59925?

CVE-2026-59925 is characterized as a performance vulnerability due to quadratic-time parsing on long runs of emphasis pairs.

5

What are the consequences of exploiting CVE-2026-59925?

Exploiting CVE-2026-59925 can lead to excessive CPU usage and slowdowns when processing specific Markdown content.

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