GHSA-7JQX-W58W-8H4P
Quadratic text scans on upstream tool responses let a crafted response stall the proxy event loop
Texto original en inglés · Ver en español
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-7JQX-W58W-8H4P divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
Several scans that memtomem-stm runs over upstream tool-response text re-read the same text from every candidate start whenever a match fails. Their cost is quadratic in the response size, and one of them is cubic. The scans run synchronously on the proxy's event loop, so while one response is being scanned, every other call through the proxy waits.
Under the default configuration (AUTO strategy, cleaning enabled), a response of a few tens of kilobytes can stall the proxy for seconds to minutes. `max_upstream_chars` defaults to 10,000,000, so it does not bound the input in practice.
Severity: High (availability). No data is exposed. The stall ends when the scan finishes. No CVSS vector or CVE is asserted yet.
Affected scans (measured on main `5897eb75`, Python 3.13)
| stage | scan | crafted input | time |
|---|---|---|---|
| COMPRESS (TRUNCATE, picked by AUTO for plain text over budget): truncation note | link count `\[.*?\]\(.*?\)` | 31 KB of `- [](http://` repeated | 153 s (cubic) |
| same | link count | 32 KB of `[` | 2.0 s |
| COMPRESS (TRUNCATE): code-boundary search and list-item count | `(?:^\|\n)\s*…` (`\s*` crosses newlines) | 32 KB of newline-space pairs (survives cleaning) | 3.4 s |
| CLEAN (every response, no budget needed) | HTML tag stripping | 31 KB of `<a ` | 2.8 s |
| CLEAN | link-flood line check (bare URL rule) | one 32 KB line of spaces in a 10+ line paragraph | 0.6 s |
| CLEAN | `<script>`/`<style>` stripping, generic-type protection | `<script>` / `A<` repeated, 32 KB | 0.42 s / 0.17 s |
| PROGRESSIVE content-type detection | `(?:^\|\n)\s*(?:def \|…)` | `\n` repeated, 6 KB | 0.14 s (×4 per doubling) |
| heuristic fact extraction (opt-in, input capped at 20,000 chars) | decision / action-item rules | `\n` repeated, 6 KB | 0.55 s / 1.2 s (×4 per doubling) |
All of these grow quadratically or worse: doubling the input multiplies the time by about four (by about eight for the cubic case).
Prerequisites and reach
- The default configuration is affected. CLEAN runs on every text response. TRUNCATE is AUTO's choice for plain text over the compression budget.
- The content must come from an upstream MCP server the operator configured. The realistic attacker is whoever controls content that such an upstream relays (a web page returned by a fetch or browse tool, an issue body, a file in a repository), not the upstream's operator.
Fix
Each scan now runs in linear time and finds the same matches as before. The fix was checked against the old regexes as oracles on seeded random and structured inputs, and against ten mutations. There is one documented behavior change: in TRUNCATE's code-aware output, blank lines before a code boundary now belong to the previous block.
On the crafted inputs above, each consumer now finishes in at most 0.02 s.
Discovery
Found by the post-commit review of the #1212 fix, then widened to every text-path scan by a scaling sweep over the package's regexes.
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
PyPImemtomem-stm |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/memtomem/memtomem-stm/security/advisories/GHSA-7jqx-w58w-8h4pLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
