Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
The probability is the direct output of the EPSS model, and conveys an overall sense of the threat of exploitation in the wild. The percentile measures the EPSS probability relative to all known EPSS scores. Note: This data is updated daily, relying on the latest available EPSS model version. Check out the EPSS documentation for more details.
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 applicationsUpgrade soupsieve to version 4.0 or higher.
Affected versions of this package are vulnerable to Inefficient Algorithmic Complexity via the descendant combinator matching logic in css_match.py, where matching a selector containing one or more descendant combinators (a b) takes time that grows polynomially with document nesting depth. For a selector with k descendant combinators, matching against a chain of n nested elements takes O(n^(k+1)) time because ancestor walks are repeated without caching, re-evaluating the same ancestors against the same selector parts on every pass. An attacker who controls the HTML or XML passed to Soup Sieve can supply a deeply nested document of roughly 1 KB to keep a CPU busy for close to a minute against an ordinary selector such as section div div.
Note: This is only exploitable when selectors are compiled with the NOCACHE flag, or on versions prior to 4.0.0 where caching was not yet implemented. After upgrading, the NOCACHE flag disables the fix and restores polynomial-time behaviour.
If upgrading is not possible: use child combinators (a > b) instead of descendant combinators where document structure is known; limit the size and nesting depth of untrusted documents before selecting on them; or run selection on untrusted input in a worker process with a time limit.
import time
import bs4
import soupsieve as sv
soup = bs4.BeautifulSoup('<div>' * 200, 'html.parser')
t = time.process_time()
sv.select('section div div div', soup)
print(time.process_time() - t)
On affected versions, doubling the nesting depth multiplies the time by about 2^(k+1), where k is the number of descendant combinators: about 4x for section div, 8x for section div div, and 16x for section div div div.