All vulnerabilities

PyPI

CVE-2026-126192

Soup Sieve: General sibling combinator inside :has() matches untrusted HTML in quadratic time

Severity
Medium
Published
13 Nov 2026
Last changed
13 Nov 2026
Added to UpHeron
23 Nov 2026
Fixed in
2.10.0
Exploit chance
0.5% in the next 30 daysHigher than 41% of CVEs. EPSS by FIRST, 24 Nov 2026
Weakness
Uncontrolled resource consumption (CWE-400)Inefficient algorithmic complexity (CWE-407)
Also known as
GHSA-4j63-6c4x-wfg4
Sources
OSV.dev and GitHub

Description

Matching a selector that puts a general-sibling combinator inside :has(), such as div:has(a ~ b), against untrusted HTML runs in O(n²) time in the number of sibling elements. A single small document with a few thousand siblings ties the process up for a minute of CPU, so an application that runs a fixed selector of this shape over HTML it doesn't control can be stalled by one request.

:has is powerful, but much in the same way poor regular expressions can be crafted to cause catastrophic backtracking with greedy capturing, has can be used to create non-ideal scenarios that can cause large portions of the tree to be evaluated for one or many elements if not used thoughtfully.

This behavior is not exclusive to Soup Sieve, but browsers make note of these potential performance issues themselves: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:has#performance_considerations.

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

Workarounds

Quadratic time for :has in some circumstances is expected and not a bug. While we've made optimizations and there may be more in the future, the way :has is designed to operate will never perform in linear time in all circumstances. Users should thoughtfully apply the use of :has.

The anchor selector (the A in A:has(B)) should not be an element that has too many children. Additionally, too general an anchor, such as *, can cause :has() to be applied to every element.

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

Affected software

SoftwareAffected versions
soupsievePyPI · osv:PyPI:soupsieve
  • Every version before 2.10.0

About soupsieve

References