CVE-2026-97699: Mistune Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-ww7q-mxrj-5ffg
CVSS 7.5
CWE-400 CWE-407
Published
Advisory Summary

CVE-2026-97699 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Mistune libraries in the PyPI ecosystem. The issue involves quadratic-time dos in inline image parsing (precedence_scan) bypasses not-is-image guards. Remediation is available by upgrading affected packages to version 3.3.4.

CVE-2026-97699 at a Glance

CVE Identifier CVE-2026-97699
GHSA Identifier GHSA-ww7q-mxrj-5ffg
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Mistune
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2026-97699

To remediate this vulnerability, upgrade all affected Mistune dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

mistune fixed: 3.3.4
pip install mistune>=3.3.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show mistune

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-97699, inspect your installed packages using pip:

pip show mistune

Analyze the terminal output to locate any version of Mistune in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.3.4), your application is affected.

Note: The pip show mistune command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Mistune, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Resolution **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 ```python import mistune md = mistune.create_markdown() # default, no plugins md("![" * 16000 + "x" + "]" * 16000) ``` ## Attack Chain 1. Entry: rendered markdown -> `"!["*N + "x" + "]"*N` (no plugins). Guard: none on input size. Bypass proof: no global cap. 2. 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. 3. Processing: reaches `precedence_scan` (:179) -> `sc.search(state.src, mark_pos, end_pos)` over the full body per opener. 4. Sink: O(N) openers x O(N) scan -> O(N²) CPU. 5. Impact: 48KB -> ~16s single-threaded worker stall. ## Bypass Evidence - 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. - `max_image_depth` set 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

CVE-2026-97699 Affected Mistune Versions

1 component(s)
Fixed Versions:
3.3.4
Product / Package Ecosystem Affected Versions Fixed Version
mistune
PyPI
< 3.3.4
3.3.4

References

Frequently Asked Questions

What is CVE-2026-97699?
CVE-2026-97699 is a security vulnerability in Mistune involving Quadratic-time DoS in inline image parsing (precedence_scan) bypasses not-is-image guards under CWE-400: Uncontrolled Resource Consumption.
Which Mistune versions are affected?
Affected versions include releases prior to 3.3.4 across affected packages: mistune.
What version fixes CVE-2026-97699?
Upgrading to 3.3.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mistune affected?
Yes, mistune is affected in releases prior to 3.3.4. Upgrade your dependency to 3.3.4 or later.
What is the CVSS score of CVE-2026-97699?
CVE-2026-97699 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2026-97699?
CVE-2026-97699 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check PyPI dependencies for CVE-2026-97699?
Run the dependency tree command: 'pip show mistune'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-ww7q-mxrj-5ffg",
  "modified" : "2026-11-19T22:44:00Z",
  "published" : "2026-11-19T22:44:00Z",
  "aliases" : [ "CVE-2026-97699" ],
  "summary" : "Mistune: Quadratic-time DoS in inline image parsing (precedence_scan) bypasses not-is-image guards",
  "details" : "## 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---\nReported by **zx (Jace)** — GitHub: @manus-use",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "mistune"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.3.4"
      } ]
    } ]
  } ],
  "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"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400", "CWE-407" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-11-19T22:44:00Z",
    "nvd_published_at" : "2026-11-17T20:18:00Z"
  }
}