BREW-MANIM-CVE-2026-126192 (GHSA-4J63-6C4X-WFG4)

Vulnerability from osv_homebrew – Published: 2026-11-13 09:09 – Updated: 2026-11-13 09:09 – Source website
VLAI
Summary
Soup Sieve: General sibling combinator inside :has() matches untrusted HTML in quadratic time
Details

Summary

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.

With all of that said, there is room for improvements that can in some cases greatly improve performance.

Details

:has(a ~ b) asks "does this element contain an a that has a later sibling b?". When no b is present, soupsieve can't short-circuit, and it answers the question with a nested scan: match_future_child walks every candidate a under the scope, and for each one the general-sibling branch of match_future_relations walks all of that a's following siblings looking for b. With n siblings that is (n-1) + (n-2) + ... + 1 comparisons, i.e. O(n²).

The adjacent-sibling form div:has(a + b) stays linear, because its branch checks only the one immediately following sibling per candidate. So the cost is specific to the general-sibling ~ (and ~ nested inside :has), and it shows up on the common case where the right-hand side simply isn't there.

Proof of concept

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.

Impact

Availability. Any caller that evaluates a fixed selector containing a general sibling under :has() over attacker-controlled markup can be forced to spend minutes of CPU on a small input. The selector is developer-authored and ordinary; the untrusted part is the HTML, which is soupsieve's normal input.

A single-pass evaluation of the sibling run (remember whether an a has been seen while scanning the siblings once) would make this case linear.

Mitigation

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.

Further, it is recommended that the inner selector (the B in A:has(B)) should use combinators like > or + to limit traversal. When the selector inside :has() is not tightly constrained, Soup Sieve might need to traverse the entire subtree of the anchor element to check the condition.

If the risk for a given project is too great, user input can be scanned for usage of :has and be denied. Calls can also be wrapped in a timeout to prevent long-running processes as well.

Impacted products
Ecosystem Package Version
Homebrew manim
pkg:brew/manim
Affected: ≥ 0.19.0, < 0.22.0 (ecosystem)

{
  "affected": [
    {
      "ecosystem_specific": {
        "fix": "bump",
        "range_state": "fixed",
        "resource": "soupsieve",
        "resource_purl": "pkg:pypi/soupsieve@3.0.4",
        "upstream_fixed_in": "2.10.0"
      },
      "package": {
        "ecosystem": "Homebrew",
        "name": "manim",
        "purl": "pkg:brew/manim"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0.19.0"
            },
            {
              "fixed": "0.22.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "database_specific": {
    "confidence": "high",
    "source": "matched",
    "strategy": "registry",
    "upstream_evidence": [
      {
        "ecosystem": "PyPI",
        "key": "pkg:pypi/soupsieve@3.0.4",
        "name": "soupsieve",
        "resource": "soupsieve",
        "strategy": "registry",
        "subject_version": "3.0.4"
      }
    ]
  },
  "details": "## Summary\n\nMatching a selector that puts a general-sibling combinator inside `:has()`, such as `div:has(a ~ b)`, against untrusted HTML runs in O(n\u00b2) 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\u0027t control can be stalled by one request.\n\n`: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.\n\nThis 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.\n\nWith all of that said, there is room for improvements that can in some cases greatly improve performance.\n\n## Details\n\n`:has(a ~ b)` asks \"does this element contain an `a` that has a later sibling `b`?\". When no `b` is present, soupsieve can\u0027t short-circuit, and it answers the question with a nested scan: `match_future_child` walks every candidate `a` under the scope, and for each one the general-sibling branch of `match_future_relations` walks all of that `a`\u0027s following siblings looking for `b`. With n siblings that is (n-1) + (n-2) + ... + 1 comparisons, i.e. O(n\u00b2).\n\nThe adjacent-sibling form `div:has(a + b)` stays linear, because its branch checks only the one immediately following sibling per candidate. So the cost is specific to the general-sibling `~` (and `~` nested inside `:has`), and it shows up on the common case where the right-hand side simply isn\u0027t there.\n\n## Proof of concept\n\nInstalled from PyPI: `pip install soupsieve==2.9.2 beautifulsoup4`.\n\n```python\nimport time\nimport soupsieve\nfrom bs4 import BeautifulSoup\n\nselector = \"div:has(a ~ b)\"\n\nfor n in (1000, 2000, 4000, 8000):\n    html = \"\u003cdiv\u003e\" + (\"\u003ca\u003e\u003c/a\u003e\" * n) + \"\u003c/div\u003e\"\n    soup = BeautifulSoup(html, \"html.parser\")\n    start = time.perf_counter()\n    soupsieve.select(selector, soup)\n    print(n, round((time.perf_counter() - start) * 1000), \"ms\")\n```\n\nMeasured:\n\n```\nn=1000    837 ms\nn=2000   3667 ms\nn=4000  14797 ms\nn=8000  59746 ms\n```\n\nTime quadruples for each doubling of n. The n=8000 input is a ~56 KB HTML fragment.\n\n## Impact\n\nAvailability. Any caller that evaluates a fixed selector containing a general sibling under `:has()` over attacker-controlled markup can be forced to spend minutes of CPU on a small input. The selector is developer-authored and ordinary; the untrusted part is the HTML, which is soupsieve\u0027s normal input.\n\nA single-pass evaluation of the sibling run (remember whether an `a` has been seen while scanning the siblings once) would make this case linear.\n\n## Mitigation\n\nQuadratic time for `:has` in some circumstances is expected and not a bug. While we\u0027ve 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`.\n\nThe 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.\n\nFurther, it is recommended that the inner selector (the `B` in `A:has(B)`) should use combinators like `\u003e` or `+` to limit traversal. When the selector inside `:has()` is not tightly constrained, Soup Sieve might need to traverse the entire subtree of the anchor\nelement to check the condition.\n\nIf the risk for a given project is too great, user input can be scanned for usage of `:has` and be denied. Calls can also be wrapped in a timeout to prevent long-running processes as well.",
  "id": "BREW-manim-CVE-2026-126192",
  "modified": "2026-11-13T09:09:38Z",
  "published": "2026-11-13T09:09:38Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/facelessuser/soupsieve/security/advisories/GHSA-4j63-6c4x-wfg4"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-126192"
    },
    {
      "type": "WEB",
      "url": "https://github.com/facelessuser/soupsieve/pull/304"
    },
    {
      "type": "WEB",
      "url": "https://github.com/facelessuser/soupsieve/commit/ffb88cca745c591224f74a8e86414a85e8f35fc0"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/facelessuser/soupsieve"
    },
    {
      "type": "WEB",
      "url": "https://github.com/facelessuser/soupsieve/releases/tag/2.10"
    }
  ],
  "schema_version": "1.7.3",
  "severity": [
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N",
      "type": "CVSS_V4"
    }
  ],
  "summary": "Soup Sieve: General sibling combinator inside :has() matches untrusted HTML in quadratic time",
  "upstream": [
    "GHSA-4j63-6c4x-wfg4",
    "CVE-2026-126192"
  ]
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline

Sightings and recorded dates, grouped by day · UTC

JSON
How durations are calculated

Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation.

Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.

Events included in the timeline

Loading timeline…


    Loading…

    Loading…

    Loading…

    Related by attack behaviour

    Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.