GHSA-W3P6-XVP9-C78V
Quadratic ReDoS in pymdownx.tilde and pymdownx.caret default smart processor
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche 11.0.2 | pymdown-extensions · -77 d desde divulgación | |
| Divulgación | Publicada | GHSA-W3P6-XVP9-C78V divulgada · CVSS 7.5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
In pymdown-extensions 11.0.1, `PatternSequenceProcessor.handleMatch()` tries every `TildeSmartProcessor.PATTERNS` regex at each `~`. For `~a~~a~~a...`, `SMART_DEL_SUB3` scans most of the remaining suffix before failing, producing quadratic work. An unauthenticated attacker can reach this path through a downstream service that explicitly enables `pymdownx.tilde`, accepts attacker-controlled Markdown, and uses the default options. The library has no input-length or render-time limit. `pymdownx.extra` does not enable `pymdownx.tilde`.
Similar behavior can be observed in `pymdownx.caret` as well.
It should be noted that the inline processor path of Python Markdown is not linear, so not all quadratic work measured can be attributed solely to the Tilde's implementation. Reasonable fixes within Pymdown Extensions will not prevent all risks of quadratic work as Python Markdown does not process work linearly, and this is an extension for Python Markdown.
Vulnerable pattern and registration:
https://github.com/facelessuser/pymdown-extensions/blob/c68498598d7b13011bb4571350b6e3612a4ce44b/pymdownx/tilde.py#L78-L110
Default configuration:
https://github.com/facelessuser/pymdown-extensions/blob/c68498598d7b13011bb4571350b6e3612a4ce44b/pymdownx/tilde.py#L144-L179
Unbounded pattern dispatch:
https://github.com/facelessuser/pymdown-extensions/blob/c68498598d7b13011bb4571350b6e3612a4ce44b/pymdownx/util.py#L317-L335
PoC
In order to demonstrate what Pymdown Extensions is specifically capable of improving, outside of Python Markdown, a simple baseline extension is compared against. Improvements must be compared against a baseline, as Python Markdown itself may be responsible for a portion of the quadratic work and would be outside the scope of any fix here.
Preconditions:
- pymdown-extensions 10.13–11.0.1
- `pymdownx.tilde` enabled with default options (but are specified specifically in case the defaults change)
- Attacker-controlled Markdown without an input-size or render-time limit
( P.S. this unexecuted reproducer consumes CPU; do not increase its sizes on shared or production systems)
import time
import markdown
import xml.etree.ElementTree as etree
from markdown import Extension
from markdown.inlinepatterns import InlineProcessor
class TestProcessor(InlineProcessor):
def handleMatch(self, m, data):
el = etree.Element('span')
el.text = m.group(1)
return el, m.start(0), m.end(0)
class TestExtension(Extension):
def extendMarkdown(self, md):
test = TestProcessor(r'%([^%]+)%')
md.inlinePatterns.register(test, "span", 40)
ranges = (500, 1_000, 2_000)
print('=== Baseline ===')
for blocks in ranges:
payload = "%a" + "%%a" * blocks
started = time.perf_counter()
markdown.markdown(payload, extensions=[TestExtension()])
print(blocks, time.perf_counter() - started)
print('=== Tilde ===')
for blocks in (500, 1_000, 2_000):
payload = "~a" + "~~a" * blocks
started = time.perf_counter()
markdown.markdown(payload, extensions=["pymdownx.tilde"], extension_configs={"pymdownx.tilde": {"smart_delete": True}})
print(blocks, time.perf_counter() - started)Runtime should grow superlinearly (or closer to it based on Python Markdown's limitations) as `blocks` doubles. `NOT_TILDE` only handles tilde runs surrounded by whitespace, so it does not match this input. After `SMART_DEL_SUB3` fails, `handleMatch()` returns `(None, None, None)` and Python-Markdown continues to later tilde positions, repeating the suffix scan. Release 11.0.1 changes only `SUB2`; it leaves `SMART_DEL_SUB3` unchanged. Rewrite delimiter matching so each suffix is scanned once and add a regression test asserting linear scaling.
Impact
A downstream network service synchronously rendering unauthenticated Markdown can have its workers exhausted by repeated requests. GHSA-gm37-52c6-37mw / CVE-2026-67422 covers exponential ReDoS in `SUB2` and identifies 11.0.1 as fixed, but does not describe this residual `SMART_DEL_SUB3` path.
Mitigation
- `pymdownx.tilde` and `pymdownx.caret` can be disabled if on a system that cannot tolerate such issues.
- It should be noted that Python Markdown's processing is not linear in general, so care should be used when considering where it is employed. While great for documentation, running on a critical server and accepting untrusted user input without employing timeouts and restricting large user input is not advised.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
pypipymdown-extensions |
Corregida | 11.0.2 | -77 d | 13.1.0 no afectada |
11.0.2Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/facelessuser/pymdown-extensions/security/advisories/GHSA-w3p6-xvp9-c78vLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
