Vulnerabilities in pkg:pypi/mistune
PACKAGECVE-2026-97698 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 parse_link_href via unbounded parenthesis scan on empty-label links. Remediation is available by upgrading affected packages to version 3.3.4.
pkg:pypi/mistune
Vulnerability advisories affecting package pkg:pypi/mistune. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-phmp-hrw4-r36r | CVE-2026-97698 | HIGH | Mistune: Quadratic-time DoS in parse_link_href via unbounded parenthesis scan on empty-label links |
| GHSA-ww7q-mxrj-5ffg | CVE-2026-97699 | HIGH | Mistune: Quadratic-time DoS in inline image parsing (precedence_scan) bypasses not-is-image guards |
| GHSA-6m44-fpc8-c3rq | CVE-2026-76098 | HIGH | Mistune: Denial of Service — RecursionError via Excessive Emphasis Markers in Markdown |
| GHSA-qfrw-5rxm-mhh2 | CVE-2026-59929 | MODERATE | Mistune renderers/html.safe_url: HARMFUL_PROTOCOLS list misses legacy and chained schemes that historically chain to `javascript:` execution |
| GHSA-2hm2-hc3v-44h9 | CVE-2026-59930 | MODERATE | Mistune toc / TableOfContents directive: heading IDs use predictable `toc_N` numbering with no slugification, allowing collision with attacker-controlled `id="toc_N"` content |
| GHSA-r4rv-85jg-w4mf | CVE-2026-59924 | MODERATE | Mistune: Arbitrary File Read via Include directive path traversal |
| GHSA-c8j7-8cv4-2xmq | CVE-2026-59922 | HIGH | Mistune plugins/formatting: quadratic-time parsing on long runs of `~~x~~`, `==x==`, and `^^x^^` markers (strikethrough / mark / insert) |
| GHSA-g97x-gvcm-x72h | CVE-2026-59926 | MODERATE | Mistune: XSS via unescaped class option in Admonition directive |
| GHSA-8c25-4j27-2rv3 | CVE-2026-59923 | MODERATE | Mistune: XSS via percent-encoded javascript URI bypass in safe_url() |
| GHSA-4j32-57v6-6g45 | CVE-2026-59925 | HIGH | Mistune inline_parser: quadratic-time parsing on long runs of `**x**` and `***x***` emphasis pairs |
| GHSA-8mpj-m6qm-5qr8 | CVE-2026-59927 | MODERATE | Mistune directives/include: mutual `.. include::` recursion crashes the renderer with `RecursionError`, denial of service via two attacker-controlled markdown files |
| GHSA-ffq3-xpv3-j92q | CVE-2026-59928 | HIGH | Mistune block_parser: quadratic-time parsing on long lists of repeated reference-link definitions |
| GHSA-qcq2-496w-v96p | CVE-2026-49851 | HIGH | Mistune: Potential DoS via quadratic-time parsing in parse_link_text |
| GHSA-58cw-g322-p94v | CVE-2026-44896 | MODERATE | Mistune has XSS via unescaped figclass/figwidth in Figure directive |
| GHSA-ccfx-mfmx-2fx9 | CVE-2026-44899 | MODERATE | Mistune Image Directive CSS Injection Vulnerability |
| GHSA-6269-cqxg-mhhv | CVE-2026-44898 | MODERATE | Mistune TOC Anchor Injection XSS |
| GHSA-v87v-83h2-53w7 | CVE-2026-44897 | MODERATE | Mistune Heading ID Attribute has Injection XSS |
| GHSA-8g87-j6q8-g93x | CVE-2026-44708 | MODERATE | Mistune Math Plugin has an XSS Escape Bypass |
| GHSA-hjph-f4mc-wx4c | - | HIGH | Duplicate Advisory: Mistune has a ReDoS in LINK_TITLE_RE that allows denial of service via crafted Markdown input |
| GHSA-8mp2-v27r-99xp | CVE-2026-33079 | HIGH | Mistune has a ReDoS in LINK_TITLE_RE that allows denial of service via crafted Markdown input |
| GHSA-fw3v-x4f2-v673 | CVE-2022-34749 | HIGH | Mistune vulnerable to catastrophic backtracking |
| GHSA-98gj-wwxm-cj3h | CVE-2017-16876 | MODERATE | mistune Cross-site scripting (XSS) vulnerability |
| GHSA-hpv5-v8g5-c864 | CVE-2017-15612 | MODERATE | Cross-site Scripting in Mistune |
CVE-2026-97698 at a Glance
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).
How to Fix CVE-2026-97698
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.
pip install mistune>=3.3.4
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-97698, 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
CVE-2026-97698 Affected Mistune Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
mistune
|
PyPI |
< 3.3.4
|
3.3.4
|
References
Frequently Asked Questions
What is CVE-2026-97698?
Which Mistune versions are affected?
What version fixes CVE-2026-97698?
Is mistune affected?
What is the CVSS score of CVE-2026-97698?
What CWE is associated with CVE-2026-97698?
How can I check PyPI dependencies for CVE-2026-97698?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-phmp-hrw4-r36r",
"modified" : "2026-11-19T22:44:42Z",
"published" : "2026-11-19T22:44:42Z",
"aliases" : [ "CVE-2026-97698" ],
"summary" : "Mistune: Quadratic-time DoS in parse_link_href via unbounded parenthesis scan on empty-label links",
"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\n`parse_link_href` in mistune performs an unbounded parenthesis-balancing scan that runs to end-of-document on each unmatched `(`. Because the empty label `[]` bypasses the `no_close_bracket_before` high-water-mark guard, a single small document of the form `\"[](\" * N` causes O(N) openers to each drive an O(N) scan, producing O(N²) CPU on the **default** `mistune.html()` renderer with no plugins.\n\n## Root Cause\n`parse_link` matches the empty label `[]` (`parse_link_label(\"[](\",1)` returns `('', 2)`), so it reaches the `(` branch and calls `parse_link_href`. That function's scan loop (helpers.py:143-159) advances past characters and increments `level` on each `(`, never finding an unescaped `)` at `level==0`, so it runs to EOF and returns `None`. The cursor then advances only ~2 chars to the next `[](`. The `no_close_bracket_before` high-water mark that keeps the balanced-bracket link path linear is never entered because the empty label matches before that branch; `_mark_no_link_before` only advances past the 2-char label, not the href region.\n\n## Impact\nA single unauthenticated request rendering untrusted markdown pins a worker at 100% CPU for tens of seconds. Measured on default `mistune.html`, no plugins: 6KB->0.80s, 12KB->3.15s, 24KB->12.5s, 48KB->49.8s (2x input -> ~3.9x time, clean O(n²)). This is the most severe of the mistune quadratic-DoS findings.\n\n## Proof of Concept\n```python\nimport mistune\nmd = mistune.create_markdown() # default HTML renderer, no plugins\nmd(\"[](\" * 16000) # ~48KB input stalls a worker ~50s\n```\n\n## Attack Chain\n1. Entry: rendered markdown body -> `\"[](\" * N` (3 bytes/unit, no plugins). Guard: none on input size (grep of markdown.py/core.py = no size/time cap). Bypass proof: no global guard exists.\n2. Check: `parse_link` guards at inline_parser.py:141 (`no_link_before`), :150 (`no_close_bracket_before`). Guard: high-water marks that linearize balanced-bracket links. Bypass proof: empty label matches (label != None) so the :150 branch is skipped entirely; `no_link_before` only crawls +2/opener because `parse_link_label` returns `('',2)`.\n3. Processing: `parse_link_href` (helpers.py:143) scans to EOF per `(` (unbalanced parens), returns `None`.\n4. Sink: O(N) openers x O(N) scan each -> O(N²) CPU.\n5. Impact: single ~48KB request stalls a worker ~50s (single-threaded); ~200KB approx minutes.\n\n## Bypass Evidence\n- `parse_link_label(\"[](\",1)` returns `('', 2)` — the empty label matches, so the balanced-bracket branch owning `no_close_bracket_before` is never entered.\n- `git log -S \"if c == \\\"(\\\":\" -- helpers.py` returns only refactor `5de41fb`; `parse_link_href` has NEVER received a DoS fix (all helpers.py DoS fixes targeted `parse_link_text`).\n- Empirical: the `[`*n unbalanced-bracket payload is LINEAR on HEAD (0.03->0.12s) while `[](`*n is O(n²) (3.99x per 2x) — proving the fix does not cover this branch.\n\n## Affected Versions\n`<= 3.3.3` (present on latest release tag v3.3.3 and HEAD `719107f`; no fix on HEAD).\n\n## Suggested Fix\nAdd a high-water mark for `parse_link_href` failed scans (mirroring `no_link_before`/`no_close_bracket_before`), or bound the parenthesis scan to a maximum length, so repeated failed href scans cannot each traverse the remaining 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-phmp-hrw4-r36r"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-97698"
}, {
"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:42Z",
"nvd_published_at" : "2026-11-17T20:18:00Z"
}
}