GHSA-WW7Q-MXRJ-5FFG
Vulnerability from github – Published: 2026-11-19 22:44 – Updated: 2026-11-19 22:44Resolution
Fixed in Mistune 3.3.4. Upgrade to 3.3.4 or later.
- Affected versions:
< 3.3.4 - First patched version:
3.3.4 - Fix: https://github.com/lepture/mistune/compare/v3.3.3...v3.3.4
The reported payload was reproduced against the 3.3.3 release tag and verified to scale approximately linearly against the 3.3.4 release tag.
Original report
The following report describes the issue before the fix.
Summary
mistune's inline image parsing reaches precedence_scan for ![ openers because the two guards that keep the link path linear are both gated behind not is_image. A small default-renderer document of the form "![" * N + "x" + "]" * N produces O(N²) CPU with no plugins.
Root Cause
For ![ openers, is_image is True, so both linearizing guards are skipped: if not is_image and pos <= state.no_link_before (inline_parser.py:141) and has_nested_link = not is_image and _label_contains_link(...) (:171). Execution reaches precedence_scan (:179) which runs sc.search(state.src, mark_pos, end_pos) over the whole image body — O(n) per outer opener, x O(n) openers -> O(n²). max_image_depth never fires because the failing scans never produce an image token (image_depth stays 0).
Impact
A single unauthenticated request pins a worker at 100% CPU. Measured on default mistune.html, no plugins: 6KB->0.28s, 12KB->1.07s, 24KB->4.20s, 48KB->15.8s (2x input -> ~3.8x time).
Proof of Concept
import mistune
md = mistune.create_markdown() # default, no plugins
md("![" * 16000 + "x" + "]" * 16000)
Attack Chain
- Entry: rendered markdown ->
"!["*N + "x" + "]"*N(no plugins). Guard: none on input size. Bypass proof: no global cap. - Check:
not is_imageguards at inline_parser.py:141 (no_link_before) and :171 (_label_contains_link). Guard: high-water mark + nested-link short-circuit. Bypass proof:is_imageis True for![, so BOTH guards are gated out;max_image_depth(:checked after) measured flat across all values because no image token is produced. - Processing: reaches
precedence_scan(:179) ->sc.search(state.src, mark_pos, end_pos)over the full body per opener. - Sink: O(N) openers x O(N) scan -> O(N²) CPU.
- Impact: 48KB -> ~16s single-threaded worker stall.
Bypass Evidence
- The LINK payload
"["*n+"x"+"]"*nis LINEAR on HEAD (0.076s @ 16k, ~2x per 2x) because links get the_label_contains_linkshort-circuit; the IMAGE payload"!["*n+"x"+"]"*nis O(n²) (0.27->1.05->3.92s, ~3.8x). Same HEAD, onlyis_imagediffers — proves the guard asymmetry, not incidental input growth. max_image_depthset across 0..100 leaves runtime flat (no image token produced by failing scans).
Affected Versions
<= 3.3.3 (present on latest release tag v3.3.3 and HEAD).
Suggested Fix
Generalize the no_link_before high-water mark (and/or the _label_contains_link short-circuit) to cover the image path, so failed ![ scans do not each re-traverse the document.
Reported by zx (Jace) — GitHub: @manus-use
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "mistune"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "3.3.4"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-97699"
],
"database_specific": {
"cwe_ids": [
"CWE-400",
"CWE-407"
],
"github_reviewed": true,
"github_reviewed_at": "2026-11-19T22:44:00Z",
"nvd_published_at": "2026-11-17T20:18:00Z",
"severity": "HIGH"
},
"details": "## Resolution\n\n**Fixed in Mistune 3.3.4.** Upgrade to 3.3.4 or later.\n\n- Affected versions: `\u003c 3.3.4`\n- First patched version: `3.3.4`\n- Fix: https://github.com/lepture/mistune/compare/v3.3.3...v3.3.4\n\nThe reported payload was reproduced against the 3.3.3 release tag and verified to scale approximately linearly against the 3.3.4 release tag.\n\n## Original report\n\nThe following report describes the issue before the fix.\n\n## Summary\nmistune\u0027s inline image parsing reaches `precedence_scan` for `![` openers because the two guards that keep the link path linear are both gated behind `not is_image`. A small default-renderer document of the form `\"![\" * N + \"x\" + \"]\" * N` produces O(N\u00b2) CPU with no plugins.\n\n## Root Cause\nFor `![` openers, `is_image` is True, so both linearizing guards are skipped: `if not is_image and pos \u003c= state.no_link_before` (inline_parser.py:141) and `has_nested_link = not is_image and _label_contains_link(...)` (:171). Execution reaches `precedence_scan` (:179) which runs `sc.search(state.src, mark_pos, end_pos)` over the whole image body \u2014 O(n) per outer opener, x O(n) openers -\u003e O(n\u00b2). `max_image_depth` never fires because the failing scans never produce an image token (`image_depth` stays 0).\n\n## Impact\nA single unauthenticated request pins a worker at 100% CPU. Measured on default `mistune.html`, no plugins: 6KB-\u003e0.28s, 12KB-\u003e1.07s, 24KB-\u003e4.20s, 48KB-\u003e15.8s (2x input -\u003e ~3.8x time).\n\n## Proof of Concept\n```python\nimport mistune\nmd = mistune.create_markdown() # default, no plugins\nmd(\"![\" * 16000 + \"x\" + \"]\" * 16000)\n```\n\n## Attack Chain\n1. Entry: rendered markdown -\u003e `\"![\"*N + \"x\" + \"]\"*N` (no plugins). Guard: none on input size. Bypass proof: no global cap.\n2. Check: `not is_image` guards at inline_parser.py:141 (`no_link_before`) and :171 (`_label_contains_link`). Guard: high-water mark + nested-link short-circuit. Bypass proof: `is_image` is True for `![`, so BOTH guards are gated out; `max_image_depth` (:checked after) measured flat across all values because no image token is produced.\n3. Processing: reaches `precedence_scan` (:179) -\u003e `sc.search(state.src, mark_pos, end_pos)` over the full body per opener.\n4. Sink: O(N) openers x O(N) scan -\u003e O(N\u00b2) CPU.\n5. Impact: 48KB -\u003e ~16s single-threaded worker stall.\n\n## Bypass Evidence\n- The LINK payload `\"[\"*n+\"x\"+\"]\"*n` is LINEAR on HEAD (0.076s @ 16k, ~2x per 2x) because links get the `_label_contains_link` short-circuit; the IMAGE payload `\"![\"*n+\"x\"+\"]\"*n` is O(n\u00b2) (0.27-\u003e1.05-\u003e3.92s, ~3.8x). Same HEAD, only `is_image` differs \u2014 proves the guard asymmetry, not incidental input growth.\n- `max_image_depth` set across 0..100 leaves runtime flat (no image token produced by failing scans).\n\n## Affected Versions\n`\u003c= 3.3.3` (present on latest release tag v3.3.3 and HEAD).\n\n## Suggested Fix\nGeneralize the `no_link_before` high-water mark (and/or the `_label_contains_link` short-circuit) to cover the image path, so failed `![` scans do not each re-traverse the document.\n\n---\nReported by **zx (Jace)** \u2014 GitHub: @manus-use",
"id": "GHSA-ww7q-mxrj-5ffg",
"modified": "2026-11-19T22:44:00Z",
"published": "2026-11-19T22:44:00Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/lepture/mistune/security/advisories/GHSA-ww7q-mxrj-5ffg"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-97699"
},
{
"type": "WEB",
"url": "https://github.com/lepture/mistune/commit/b4dd3284e52ec741ed9a227db29ade9017828e90"
},
{
"type": "PACKAGE",
"url": "https://github.com/lepture/mistune"
},
{
"type": "WEB",
"url": "https://github.com/lepture/mistune/releases/tag/v3.3.4"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "Mistune: Quadratic-time DoS in inline image parsing (precedence_scan) bypasses not-is-image guards"
}
Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline
Sightings and recorded dates, grouped by day · UTC
How durations are calculated
Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation.
Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.
Loading timeline…
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.