Mistuneに細工したMarkdownを処理させるとサービス停止に陥る脆弱性
Summary
Mistuneの画像解析処理に脆弱性があり、細工したMarkdownを処理させると処理時間が二次関数的に増え、CPUを使い切ってサービス停止に陥るおそれがあります。影響を受けるのは3.3.4より前のバージョンで、3.3.4で修正されています。信頼できない入力を扱う場合は、3.3.4以降へ更新してください。
AI summary
Produced by SecPulse using an external AI model; it may contain mistakes. Check the original description and references below before acting on it.
Mistuneの画像解析処理に脆弱性があり、細工したMarkdownを処理させると処理時間が二次関数的に増え、CPUを使い切ってサービス停止に陥るおそれがあります。影響を受けるのは3.3.4より前のバージョンで、3.3.4で修正されています。信頼できない入力を扱う場合は、3.3.4以降へ更新してください。
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| lepturemistune | — | Not listed |
| PyPImistune |
< 3.3.4→ 3.3.4 |
3.3.4 |
| pipmistune |
< 3.3.4→ 3.3.4 |
3.3.4 |
Fix status by distribution
Records published by each distribution for this CVE. Fixed versions differ by release; check each link.
- Debian DEBIAN-CVE-2026-97699 mistune Fix available
- Ubuntu UBUNTU-CVE-2026-97699 mistune No fixed version in this record
Original description The description as published by the source.
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
import mistune
md = mistune.create_markdow…
Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
References
- advisory github.com
- package github.com
- web github.com
- web github.com
- web github.com
- web nvd.nist.gov
- web github.com