llamaCVEVulnerability Intelligence
/
Advisory · GitHub · PyPI · soupsieve

GHSA-X25M-VX33-V837

Selector limit does not cover empty comma slots in forgiving pseudos

Parche disponible
Descargar PNG JSON
CVSS
—
medium
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche a -89 d de la divulgación
Exposición17 dDesde la divulgación, 4 nov 2026, 8:57 a. m.
Detección14 dDesde la divulgación hasta su ingreso al índice
Decisión estimadaSeguir
Remediar en la ventana regular de mantenimiento
Estimación de Llama con el árbol SSVC de CISA a partir de la severidad declarada por GHSA (media) y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, no automatizable e impacto técnico parcial. Hay versiones corregidas disponibles.
Paso a paso, como subiendo al Cotopaxi.Revisa, agenda, parchea. El clásico de siempre.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Modificada
Explotación
Remediación
Parche 2.9.2
Monitoreo
Detectada +1
7 ago 26
4 nov 26
12 nov 26
18 nov 26
21 nov 26
7 ago 26
3 sept 26
29 sept 26
26 oct 26
21 nov 26
FechaFaseEventoDetalle
Remediación Parche 2.9.2 soupsieve · -89 d desde divulgación
Divulgación Publicada GHSA-X25M-VX33-V837 divulgada
Divulgación Modificada Última actualización del registro
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

Selector limit does not cover empty comma slots in forgiving pseudos.

The 8192 selector limit added for GHSA-2wc2-fm75-p42x counts selector tokens, so two comma-separated constructs still compile without any bound and a 500 KB selector allocates over 350 MiB.

Details

The 8192 selector limit added for GHSA-2wc2-fm75-p42x counts selector tokens, so two comma-separated constructs still compile without any bound and a 500 KB selector allocates over 350 MiB.

PoC
Reproduction

soupsieve 2.9.1 from PyPI, Python 3.12.13, macOS 26.5. Measured with `tracemalloc` so the number is soupsieve's own allocation, not process RSS.

import tracemalloc, soupsieve as sv

def measure(label, sel):
    sv.purge(); tracemalloc.start()
    try:
        c = sv.compile(sel)
        peak = tracemalloc.get_traced_memory()[1]
        print(f'{label}: input {len(sel)} bytes -> peak {peak/1048576:.1f} MiB (x{peak/len(sel):.0f})')
    except Exception as e:
        print(f'{label}: input {len(sel)} bytes -> {type(e).__name__}: {e}')
        c = None
    tracemalloc.stop(); return c

n = 20000
c = measure('is-empty-commas', ':is(' + (','*n) + 'a)')
if c is not None:
    print('   nested selector entries:', len(c.selectors[0].selectors[0].selectors))
measure('is-nonempty-control', ':is(' + ','.join(['a']*n) + ')')
soupsieve 2.9.1 python 3.12.13
is-empty-commas: input 20006 bytes -> peak 14.3 MiB (x750)
   nested selector entries: 20001
is-nonempty-control: input 40004 bytes -> ValueError: Selector exceeds pseudo-class nesting limit of 8192

The control line is the point: the same `:is()` with 20000 *non-empty* selectors hits the limit and raises. Replace each `a` with nothing and it compiles 20001 entries.

Scaled to the same 500 KB input the anchor advisory used:

is-empty-commas 500KB: input 500006 bytes -> peak 357 MiB (x749)
Impact
What happens

Anyone who can hand an application a CSS selector string, directly through `soupsieve.compile()` or through BeautifulSoup's `.select()` and `.select_one()`, can make compilation allocate hundreds of megabytes from a small input. No privileges, no user interaction, and it happens during compile, before any document is even touched.

This shape that works: `:is(,,,,...a)` (empty comma slots inside any forgiving pseudo).

Severity

MEDIUM, `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L` (5.3).

AV:N/AC:L/PR:N/UI:N because a single selector string does it, in whatever application accepts one. C:N/I:N, nothing is read or written. A:L rather than A:H: the amplification is roughly 750x, so an attacker needs a fairly large request body to reach a gigabyte, and any request size limit in front of the application caps the damage proportionally. That is the same reasoning that fits the anchor advisory, and I would not argue this one deserves a higher availability limb than that one did.

Where

`soupsieve/css_parser.py` at tag 2.9.1 (`05e92be2b34cd6164506ba6c34cdfc764f04ff80`).

The counter in `parse_selectors` skips combinators, and a comma is a combinator:

if key not in ('combine', 'pseudo_close'):
    self.count += 1

In `parse_combinator`, a comma seen before any selector token in a forgiving pseudo appends a `no_match` entry, and that append is not counted:

if not has_selector:
    if not is_forgive or combinator != COMMA_COMBINATOR:
        raise SelectorSyntaxError(...)

    # If we are in a forgiving pseudo class, just make the selector a "no match"
    if combinator == COMMA_COMBINATOR:
        sel.no_match = True
        del relations[:]
        selectors.append(sel)
Suggested fix

One small change, reusing the machinery that already exists.

In `parse_combinator`, count the dangling-comma `no_match` entry the same way a real selector is counted, so `check_count` sees it:

if combinator == COMMA_COMBINATOR:
    sel.no_match = True
    del relations[:]
    selectors.append(sel)
    self.count += 1
    self.check_count()
Not a duplicate of GHSA-2wc2-fm75-p42x

GHSA-2wc2-fm75-p42x (CVE-2026-49476) is the same class of problem, unbounded allocation from comma-separated input, and the fix added the 8192 selector limit enforced in `parse_selectors` via `self.count` and `check_count`. That fix works for what it counts: the control case above proves it, since a 20000-item non-empty `:is()` list now raises `ValueError`.

What it does not cover is anything that is not a counted selector token. Commas are tokenized as `combine` and explicitly excluded from the increment, so empty comma slots in a forgiving pseudo slip past. This is present and unbounded in 2.9.1, which is the release carrying that fix.

Mitigations

It should be noted that the risk of exploitation greatly depends on how this project is used.

Beautiful Soup, and by extension Soup Sieve, is not designed to be exposed to users on a server, as it is a Python library for parsing HTML and XML, not a web service or API. Exposing it directly would create security vulnerabilities, including potential Cross-Site Scripting (XSS) if untrusted input is processed insecurely.

Using the software as intended, as a backend tool, greatly reduces risk. If it is still desired to be used in an environment where untrusted user input is desired, putting a limit on input sizes, something that Soup Sieve has purposely chosen to leave up to those employing the software, can greatly help.

AI assistance

I used an AI assistant for the audit and for drafting this report. I ran every measurement above myself against soupsieve 2.9.1 from PyPI on Python 3.12.13 and pasted the output verbatim, including the control case that shows the existing limit does fire for non-empty lists, and I read the GHSA-2wc2-fm75-p42x fix to confirm the counter it added does not reach either of these two paths.

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

Versiones

Rangos afectados

Afectada Corregida Última
soupsieve≤ 2.9.1
2.9.1
4.1.2
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
pypisoupsieve
Corregida 2.9.2 -89 d 4.1.2 no afectada
Versiones corregidas2.9.2
Explotación

Arsenal público

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

Referencias
Advisoryhttps://github.com/facelessuser/soupsieve/security/advisories/GHSA-x25m-vx33-v837

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