All vulnerabilities

PyPI

CVE-2026-126193

Soup Sieve: Uncontrolled recursion in CSS parser lets nested pseudo-class selectors exhaust the Python call stack

Severity
Medium 5.3
Published
13 Nov 2026
Last changed
13 Nov 2026
Added to UpHeron
23 Nov 2026
Fixed in
3.0.2
Exploit chance
0.5% in the next 30 daysHigher than 43% of CVEs. EPSS by FIRST, 24 Nov 2026
Weakness
Uncontrolled recursion (CWE-674)
Attack
Over the network · No login needed · No user action needed
Attacker can
Slow it down
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Also known as
GHSA-7g44-g9rc-x53w
Sources
OSV.dev and GitHub

Description

The Soup Sieve CSS selector parser recurses once per level of nested pseudo-class selector (:is(), :not(), :where(), :has()) without any limit on nesting depth. An unauthenticated attacker who can supply a CSS selector string to soupsieve.compile(), soupsieve.select(), or Beautiful Soup's soup.select() / soup.select_one() can force the parser to exceed Python's recursion limit with a small crafted input (about 1.6 KB, roughly 330 nesting levels), raising an uncontrolled RecursionError. Because this exception is not part of the parser's documented error contract, applications that catch only ValueError or SelectorSyntaxError see an unexpected failure of the request or task that parsed the selector.

The parser dispatches each opening pseudo-class token to parse_pseudo_open, which calls back into parse_selectors to parse the pseudo-class body. Every nesting level therefore adds Python stack frames, and no counter, depth guard, or RecursionError handler bounds this descent.

From the GitHub Advisory Database, CC BY 4.0. Shortened; the full text is there.

Workarounds

For those on older versions where the algorithm is still recursive, a try/except block that captures RecursionError can be added around calls if accepting untrusted user input is allowed.

Workarounds as given by the GitHub Advisory Database, CC BY 4.0.

Affected software

SoftwareAffected versions
soupsievePyPI · osv:PyPI:soupsieve
  • From 0.4 before 3.0.2

About soupsieve

References