CVE-2026-49851: Mistune Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-qcq2-496w-v96p
CVSS 7.5
CWE-400 CWE-1333
Published
Advisory Summary

CVE-2026-49851 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 potential dos via quadratic-time parsing in parse_link_text. Remediation is available by upgrading affected packages to version 3.3.0.

CVE-2026-49851 at a Glance

CVE Identifier CVE-2026-49851
GHSA Identifier GHSA-qcq2-496w-v96p
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-49851

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.0
pip install mistune>=3.3.0
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-49851, 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.0), 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

### Summary 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. ### Affected component mistune/inline_parser.py → **parse_link_text** ### Description 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. ### Root cause The vulnerability stems from a two-loop interaction: - The outer loop in `InlineParser.parse()` (inline_parser.py) advances only 1 character at a time when parse_link() returns None - Each failed attempt calls `parse_link_text()` which performs an O(n) scan to the end of the string looking for a closing `]` - With n consecutive `[` characters, this results in O(n) × O(n) = O(n²) total work ### PoC Run 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" /> ### Observed behaviour ``` 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 ### Impact This can be used as a denial-of-service attack in any application that parses user-supplied Markdown using Mistune, including: - Web applications (comments, posts, content rendering) - API services processing Markdown - Documentation rendering systems - A small (~6 KB) payload can block CPU for multiple seconds. ### Suggested fix 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 ### Security Classification CWE-400: Uncontrolled Resource Consumption Denial of Service (CPU exhaustion)

CVE-2026-49851 Affected Mistune Versions

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

References

Frequently Asked Questions

What is CVE-2026-49851?
CVE-2026-49851 is a security vulnerability in Mistune involving Potential DoS via quadratic-time parsing in parse_link_text under CWE-400: Uncontrolled Resource Consumption.
Which Mistune versions are affected?
Affected versions include releases prior to 3.3.0 across affected packages: mistune.
What version fixes CVE-2026-49851?
Upgrading to 3.3.0 (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.0. Upgrade your dependency to 3.3.0 or later.
What is the CVSS score of CVE-2026-49851?
CVE-2026-49851 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-49851?
CVE-2026-49851 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-49851?
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-qcq2-496w-v96p",
  "modified" : "2026-07-09T23:52:28Z",
  "published" : "2026-07-09T23:52:27Z",
  "aliases" : [ "CVE-2026-49851" ],
  "summary" : " Mistune: Potential DoS via quadratic-time parsing in parse_link_text",
  "details" : "### Summary\nMistune 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.\n\n### Affected component\nmistune/inline_parser.py → **parse_link_text**\n\n### Description\nWhen 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.\nAn attacker-controlled Markdown input can therefore trigger excessive CPU usage with a very small payload.\n\n### Root cause\nThe vulnerability stems from a two-loop interaction:\n- The outer loop in `InlineParser.parse()` (inline_parser.py) advances \n  only 1 character at a time when parse_link() returns None\n- Each failed attempt calls `parse_link_text()` which performs an O(n) \n  scan to the end of the string looking for a closing `]`\n- With n consecutive `[` characters, this results in O(n) × O(n) = O(n²) \n  total work\n\n### PoC\nRun below python script\n```\nimport mistune\nimport time\n\nmd = mistune.create_markdown()\n\ns = \"[\" * 6400\n\nt = time.perf_counter()\nmd(s)\nprint(time.perf_counter() - t)\n```\n<img width=\"2028\" height=\"1277\" alt=\"image\" src=\"https://github.com/user-attachments/assets/15d5bc0b-35f8-4a15-85e0-cbc314a45b06\" />\n\n**Benmark poc**\nRun below code for benchmark\n```\nimport mistune\nimport time\n\nmd = mistune.create_markdown()\n\nsizes = [100,200,400,800,1600,3200,6400]\n\nfor n in sizes:\n    s = \"[\" * n\n\n    t0 = time.perf_counter()\n    md(s)\n    dt = time.perf_counter() - t0\n\n    print(f\"{n:6d} {dt:.6f}\")\n```\n<img width=\"2503\" height=\"1341\" alt=\"image\" src=\"https://github.com/user-attachments/assets/f09a7bbb-6927-4ba2-afb1-444dd913b84e\" />\n\n\n### Observed behaviour\n```\npython3 benchmark.py \n   100 0.001609\n   200 0.003207\n   400 0.012906\n   800 0.050220\n  1600 0.197307\n  3200 0.801172\n  6400 3.190393\n```\nExecution time grows superlinearly, consistent with O(n²) complex\n\n### Impact\nThis can be used as a denial-of-service attack in any application that parses user-supplied Markdown using Mistune, including:\n\n- Web applications (comments, posts, content rendering)\n- API services processing Markdown\n- Documentation rendering systems\n- A small (~6 KB) payload can block CPU for multiple seconds.\n\n### Suggested fix\nReturn 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\n\n### Security Classification\nCWE-400: Uncontrolled Resource Consumption\nDenial of Service (CPU exhaustion)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "mistune"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.3.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/lepture/mistune/security/advisories/GHSA-qcq2-496w-v96p"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-49851"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/security/cve/CVE-2026-49851"
  }, {
    "type" : "WEB",
    "url" : "https://bugzilla.redhat.com/show_bug.cgi?id=2492304"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/lepture/mistune"
  }, {
    "type" : "WEB",
    "url" : "https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-49851.json"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333", "CWE-400" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-09T23:52:27Z",
    "nvd_published_at" : "2026-06-24T18:17:18Z"
  }
}