CVE-2026-126193
Deeply nested CSS pseudo-classes cause Soup Sieve recursion overflow → RecursionError.
- CVSS 5.3
- CWE-674
- Resource Management
- Remote
Soup Sieve is a CSS selector library for Beautiful Soup. From 0.4 until 3.0, deeply nested CSS pseudo-class selectors can cause recursive parsing to exceed Python’s recursion limit and raise RecursionError . Applications accepting untrusted selectors may experience failure of the affected request or task if the exception is not handled. The demonstrated behavior is recoverable and does not establish an interpreter crash or persistent service-wide denial of service. This vulnerability is fixed in version 3.0.
- CWE
- CWE-674
- CVSS base score
- 5.3
- Published
- 2026-11-12
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Timing/Serialization
- Code defect classification
- Timing Issues
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- Soup Sieve
- Fixed by upgrading
- Yes
Solution
Upgrade Soup Sieve to version 3.0 or later.
Vulnerable code sample
from bs4 import BeautifulSoup
import soupsieve as sv
def extract_links(html, selector):
"""Return hrefs of <a> tags matching a user‑supplied CSS selector."""
soup = BeautifulSoup(html, "html.parser")
# VULNERABLE: deep pseudo‑class selectors can cause unbounded recursion
elements = sv.select(selector, soup)
return [el.get("href") for el in elements if el.name == "a"]Patched code sample
from bs4 import BeautifulSoup
import soupsieve as sv
def extract_links(html, selector):
"""Return hrefs of <a> tags matching a user‑supplied CSS selector."""
# FIX: limit nesting depth of pseudo‑class selectors to prevent recursion overflow
if selector.count(":has(") > 5:
raise ValueError("Selector nesting depth exceeds safe limit")
soup = BeautifulSoup(html, "html.parser")
elements = sv.select(selector, soup)
return [el.get("href") for el in elements if el.name == "a"]Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Recursion elimination (#306) (facelessuser/soupsieve)
soupsieve/css_match.py,soupsieve/css_match.py · CSSMatch.closest,soupsieve/css_match.py · CSSMatch.find_bidi,soupsieve/css_match.py · CSSMatch.match_contains,soupsieve/css_match.py · CSSMatch.match_default,soupsieve/css_match.py · CSSMatch.match_dir,soupsieve/css_match.py · CSSMatch.match_empty,soupsieve/css_match.py · CSSMatch.match_future_child,soupsieve/css_match.py · CSSMatch.match_future_relations,soupsieve/css_match.py · CSSMatch.match_general_sibling,soupsieve/css_match.py · CSSMatch.match_lang,soupsieve/css_match.py · CSSMatch.match_nthand 41 more
Cite this entry
@misc{vaitp:cve2026126193,
title = {{Deeply nested CSS pseudo-classes cause Soup Sieve recursion overflow → RecursionError.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-126193},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-126193/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
