{"vuln_id":"CVE-2026-97699","aliases":["GHSA-ww7q-mxrj-5ffg"],"description":"Mistune: Quadratic-time DoS in inline image parsing (precedence_scan) bypasses not-is-image guards","published_at":"2026-11-17T20:18:00.220000Z","modified_at":"2026-11-19T23:00:36.653352Z","first_seen_at":"2026-11-21T19:15:19.422451Z","severity":"high","severity_source":"nvd","cvss_score":7.5,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","cwe":["CWE-400","CWE-407"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":0.00543,"epss_percentile":0.46468,"nvd_status":"Deferred","enriched_at":null,"links":{"nvd":"https://nvd.nist.gov/vuln/detail/CVE-2026-97699"},"matched_alias":null,"items":[{"id":10712,"source":{"id":"osv","name":"OSV.dev"},"title":"GHSA-ww7q-mxrj-5ffg: Mistune: Quadratic-time DoS in inline image parsing (precedence_scan) bypasses not-is-image guards","summary":"Mistune: Quadratic-time DoS in inline image parsing (precedence_scan) bypasses not-is-image guards\n\n## Resolution\n\n**Fixed in Mistune 3.3.4.** Upgrade to 3.3.4 or later.\n\n- Affected versions: `< 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'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.\n\n## Root Cause\nFor `![` 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).\n\n## Impact\nA 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).\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 -> `\"![\"*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) -> `sc.search(state.src, mark_pos, end_pos)` over the full body per opener.\n4. Sink: O(N) openers x O(N) scan -> O(N²) CPU.\n5. Impact: 48KB -> ~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²) (0.27->1.05->3.92s, ~3.8x). Same HEAD, only `is_image` differs — 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`<= 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---\nReporte\n\nAffected: PyPI:mistune\n\nFixed in: 3.3.4\n\nReferences:\nhttps://github.com/lepture/mistune/security/advisories/GHSA-ww7q-mxrj-5ffg\nhttps://nvd.nist.gov/vuln/detail/CVE-2026-97699\nhttps://github.com/lepture/mistune/commit/b4dd3284e52ec741ed9a227db29ade9017828e90\nhttps://github.com/lepture/mistune\nhttps://github.com/lepture/mistune/releases/tag/v3.3.4","url":"https://osv.dev/vulnerability/GHSA-ww7q-mxrj-5ffg","published_at":"2026-11-19T22:44:00Z","updated_at":"2026-11-19T23:00:36.653352Z","fetched_at":"2026-11-21T19:15:55.946123Z","severity":"high","cvss_score":7.5,"epss":0.00543,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"mistune","vuln_id":"CVE-2026-97699","vuln_ids":["CVE-2026-97699","GHSA-WW7Q-MXRJ-5FFG"],"tags":["osv","pypi","fix-available"],"cluster_id":2190,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/10712","html":"https://vulnwatch.ve1ve2.com/item/10712"}},{"id":2378,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-ww7q-mxrj-5ffg / CVE-2026-97699: Mistune: Quadratic-time DoS in inline image parsing (precedence_scan) bypasses not-is-image guards","summary":"Mistune: Quadratic-time DoS in inline image parsing (precedence_scan) bypasses not-is-image guards\n\n## Resolution\n\n**Fixed in Mistune 3.3.4.** Upgrade to 3.3.4 or later.\n\n- Affected versions: `< 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'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.\n\n## Root Cause\nFor `![` 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).\n\n## Impact\nA 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).\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 -> `\"![\"*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) -> `sc.search(state.src, mark_pos, end_pos)` over the full body per opener.\n4. Sink: O(N) openers x O(N) scan -> O(N²) CPU.\n5. Impact: 48KB -> ~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²) (0.27->1.05->3.92s, ~3.8x). Same HEAD, only `is_image` differs — 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`<= 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---\nReporte\n\nAffected packages: pip:mistune\nPatched: mistune 3.3.4","url":"https://github.com/advisories/GHSA-ww7q-mxrj-5ffg","published_at":"2026-11-19T22:44:00Z","updated_at":"2026-11-19T22:44:01Z","fetched_at":"2026-11-21T19:15:18.416791Z","severity":"high","cvss_score":7.5,"epss":0.00543,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"mistune","vuln_id":"CVE-2026-97699","vuln_ids":["CVE-2026-97699","GHSA-WW7Q-MXRJ-5FFG"],"tags":["ghsa","pip","CWE-400","CWE-407"],"cluster_id":2190,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2378","html":"https://vulnwatch.ve1ve2.com/item/2378"}},{"id":6702,"source":{"id":"nvd","name":"NVD CVE API 2.0"},"title":"CVE-2026-97699: Mistune is a Python Markdown parser with renderers and plugins. Prior to 3.3.4, inline image parsing sends nested ![ openers through precedence_scan because th…","summary":"Mistune is a Python Markdown parser with renderers and plugins. Prior to 3.3.4, inline image parsing sends nested ![ openers through precedence_scan because the no_link_before and _label_contains_link linearization guards are gated by not is_image. In src/mistune/inline_parser.py, each outer image opener can therefore search the remaining image body, while max_image_depth does not apply because the failed scans do not produce image tokens. Rendering untrusted Markdown with the default HTML renderer and no plugins can perform quadratic CPU work and keep a worker at 100 percent utilization. This issue is fixed in version 3.3.4.\n\nReferences:\nhttps://github.com/lepture/mistune/commit/b4dd3284e52ec741ed9a227db29ade9017828e90\nhttps://github.com/lepture/mistune/releases/tag/v3.3.4\nhttps://github.com/lepture/mistune/security/advisories/GHSA-ww7q-mxrj-5ffg","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-97699","published_at":"2026-11-17T20:18:00.220000Z","updated_at":"2026-11-17T23:18:01.900000Z","fetched_at":"2026-11-21T19:15:31.482500Z","severity":"high","cvss_score":7.5,"epss":0.00543,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":null,"vuln_id":"CVE-2026-97699","vuln_ids":["CVE-2026-97699","GHSA-WW7Q-MXRJ-5FFG"],"tags":["CWE-400","CWE-407"],"cluster_id":2191,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/6702","html":"https://vulnwatch.ve1ve2.com/item/6702"}}]}