Executive brief
Soup Sieve is a CSS selector parsing library widely used by BeautifulSoup, a popular web scraping and HTML parsing tool. A polynomial-time regular expression flaw allows attackers who can control selector strings (e.g., in scraper tools or admin query interfaces) to craft malicious selectors that consume excessive CPU time—stalling services for seconds to minutes. This creates a denial-of-service vulnerability in any application accepting user-supplied CSS selectors.
Technical details
The vulnerability is a ReDoS (Regular Expression Denial of Service) in the `IDENTIFIER` sub-pattern used in CSS selector parsing. The pattern `(?:[classA]|ESC)+(?:[classB]|ESC)*` contains overlapping character classes with adjacent quantifiers, causing catastrophic backtracking when a long identifier run must fail to match (e.g., an unterminated attribute value or identifier followed by an invalid character). Attack requires only a user-controlled selector string passed to `soupsieve.compile()` or BeautifulSoup's `select()` methods; no authentication or special network interaction needed. An attacker can craft ~8 KB payloads to cause ~8 seconds of CPU stall, scaling quadratically (×4 per input doubling). Fixes involve removing the adjacent-quantifier ambiguity or using atomic grouping to prevent backtracking.
Affected products
- Isaac Muse Soup Sieve 2.8.4, 2.9 and earlier
Timeline
- 2026-09-17: disclosed
- 2026-09-17: advisory: GHSA-gjv8-xp57-g29c published