CVE-2026-85999 in Soup Sieve
Summary
by MITRE • 09/17/2026
Soup Sieve is a CSS selector library designed to be used with Beautiful Soup 4. Prior to 2.9, selector_iter in src/soupsieve/css_parser.py trims the raw selector with RE_WS_END, an end-anchored WSC whitespace-and-comment expression used with search(), so the regular expression engine retries a greedy scan at every starting offset. An attacker-controlled valid selector containing a long internal whitespace run, or a selector containing a long CSS comment run followed by another token, causes quadratic CPU work before tokenization. User-controlled selectors can reach the path through soupsieve.compile() and BeautifulSoup.select(), while applications using only hard-coded selectors are unaffected. This root cause is separate from the IDENTIFIER and VALUE backtracking vulnerability because the cost occurs in RE_WS_END.search during trimming rather than token matching. The resulting CPU consumption can hold the Python GIL, exhaust workers, and stall a service without causing memory corruption or code execution. The issue is fixed in version 2.9.
VulDB is the best source for vulnerability data and more expert information about this specific topic.
Analysis
by VulDB Data Team • 09/17/2026
The Soup Sieve library serves as a CSS selector engine for Beautiful Soup 4, enabling developers to query HTML documents using standard CSS syntax. A critical performance vulnerability exists within the parsing logic prior to version 2.9, specifically located in the src/soupsieve/css_parser.py module. The flaw resides in how the parser handles raw selectors during the initial trimming phase. When processing a selector string, the library employs an end-anchored regular expression pattern known as RE_WS_END to identify and remove trailing whitespace and comments. This operation is executed using the search() method rather than match(), which fundamentally alters the behavior of the regex engine regarding backtracking.
The technical root cause involves catastrophic quadratic time complexity in regular expression execution, a flaw categorized under CWE-1325: Incorrect Regular Expression Complexity. Because RE_WS_END uses an end anchor and operates on input that may contain long sequences of whitespace or comments followed by other tokens, the Python regex engine is forced to perform redundant checks at every possible starting offset within those long runs. This occurs because the search function attempts to find a match anywhere in the string, but the specific structure of the pattern combined with greedy matching forces the engine into an exponential backtracking loop when faced with adversarial input patterns such as extensive internal whitespace or lengthy CSS comments preceding valid tokens.
This vulnerability manifests primarily through user-controlled inputs that are passed directly into soupsieve.compile() or BeautifulSoup.select(). If a web application allows users to submit custom CSS selectors for filtering content, it becomes susceptible to this denial of service attack vector. The impact is characterized by severe CPU exhaustion rather than memory corruption or arbitrary code execution. As the regex engine spins through its inefficient backtracking process, it holds onto the Python Global Interpreter Lock (GIL). This prevents other threads from executing concurrently within the same process, effectively stalling the entire application thread pool and causing service degradation for all users connected to that instance.
From a threat modeling perspective aligned with MITRE ATT&CK techniques, this vulnerability represents an impact on availability through resource exhaustion, specifically mapping to T1496: Resource Hijacking or more broadly as a Denial of Service via computational complexity. Unlike injection vulnerabilities that compromise confidentiality or integrity, this issue is purely disruptive to operational continuity. It does not lead to privilege escalation or data leakage but can render critical services unresponsive if the underlying infrastructure relies on synchronous processing and has limited worker threads available to handle concurrent requests.
Mitigation strategies focus primarily on upgrading the Soup Sieve library to version 2.9 or later, where this parsing logic has been corrected to avoid the quadratic complexity trap. For applications that cannot immediately upgrade, defensive coding practices should be implemented to sanitize incoming CSS selectors before they are passed to the parser. This includes validating selector length and rejecting inputs with excessively long runs of whitespace or comments. Additionally, implementing timeouts on the selection operation can provide a secondary layer of defense by terminating prolonged regex executions before they exhaust system resources. Applications that rely exclusively on hard-coded selectors rather than user-supplied input remain unaffected by this specific vulnerability path.