llamaCVEVulnerability Intelligence
/
Advisory · GitHub · PyPI · mistune

GHSA-3Q64-RW38-243V

Denial of Service via nested bracket parsing

Parche disponible
Descargar PNG JSON
CVSS 3.1
7.5
Alta
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche el mismo día de la divulgación
Exposición151 dDesde la divulgación, 21 jun 2026, 8:25 a. m.
Detección150 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche 3.3.0
Monitoreo
Detectada +1
21 jun 26
19 nov 26
21 jun 26
29 jul 26
5 sept 26
13 oct 26
19 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-3Q64-RW38-243V divulgada · CVSS 7.5 (GitHub)
Remediación Parche 3.3.0 mistune · 0 d desde divulgación
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

### Summary
A Regular Expression Denial of Service (ReDoS) vulnerability in mistune 3.2.1 allows any user to cause severe CPU exhaustion by submitting markdown with deeply nested square brackets. The `parse_link_text` function in `src/mistune/helpers.py` exhibits O(n²) time complexity when processing inputs with many nested bracket characters, causing parsing times that scale quadratically with input size.

### Details
The vulnerability exists in the `parse_link_text` function (`src/mistune/helpers.py`), which is called when parsing markdown links. The function uses `_INLINE_SQUARE_BRACKET_RE = re.compile(r"(?<!\\)(?:\\\\)*[\[\]]")` to scan for bracket characters. For each bracket found, the regex search starts from the current position and scans forward.

When processing input with n nested brackets (e.g., `[` × n + `]` × n), the inline parser's main loop attempts to parse a link at each `[` position. The `parse_link_text` function scans through all remaining brackets before determining the link is invalid, then the parser advances by one character and repeats. This results in O(n²) total work:

  • First `[`: scans through all 2n brackets
  • Second `[`: scans through all 2n-1 brackets
  • ...
  • nth `[`: scans through n brackets

Measured timing on mistune 3.2.1:
- n=1,000: 0.30s
- n=2,000: 1.15s
- n=4,000: 4.51s
- n=8,000: 18.57s
- n=16,000: 72.91s

Vulnerable code:

# src/mistune/helpers.py
def parse_link_text(src: str, pos: int) -> Union[Tuple[str, int], Tuple[None, None]]:
    level = 1
    found = False
    start_pos = pos

    while pos < len(src):
        m = _INLINE_SQUARE_BRACKET_RE.search(src, pos)  # O(n) scan per bracket
        if not m:
            break
        pos = m.end()
        marker = m.group(0)
        if marker == "]":
            level -= 1
            if level == 0:
                found = True
                break
        else:
            level += 1
    # ...

There is no depth limit on the `level` counter and no maximum input length check.

PoC
import time
import mistune

md = mistune.html  # Uses escape=False by default

# Payload: deeply nested brackets causing O(n²) parsing
for n in [1000, 2000, 4000, 8000, 16000]:
    payload = "[" * n + "]" * n
    start = time.time()
    result = md(payload)
    elapsed = time.time() - start
    print(f"n={n}: {elapsed:.3f}s")

Run with: `python3 poc_redos.py`

### Impact
- Type: Denial of Service (ReDoS / Algorithmic Complexity)
- Who is impacted: Any application using mistune to render user-supplied markdown (web applications, documentation systems, CMS platforms, API services)
- Attack vector: A single HTTP request with ~16KB of crafted markdown can cause 70+ seconds of CPU time. A few concurrent requests can completely exhaust server resources.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:N
AltoBajoNinguno
IntegridadI:N
AltoBajoNinguno
DisponibilidadA:H
AltoBajoNinguno
Versiones

Rangos afectados

Afectada Corregida Última
mistune< 3.3.0
3.3.0
3.4.0
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
pypimistune
Corregida 3.3.0 0 d 3.4.0 no afectada
Versiones corregidas3.3.0
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/lepture/mistune/security/advisories/GHSA-3q64-rw38-243v

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.