Skip to content
Memory corruption Advisory Advanced CVE-2026-5914

Type Confusion in CSS (CVE-2026-5914)

Editing the prelude text of a nested @scope rule through the DevTools CSS agent left the CSSOM wrapper pointing at a newly allocated rule while the stylesheet kept the old one, so wrapper and sheet fell out of step. A later index-based reattach then cast a plain style rule to a grouping rule, and further CSSOM calls could corrupt memory and crash style resolution.

Syn4pse Follow

Originally disclosed on Chrome VRP

  • Fix shipped in 34 days

Summary

CSS.setScopeText (via InspectorCSSAgent::setScopeText) desynchronizes nested @scope wrappers: CSSScopeRule::SetPreludeText mutates only wrapper-local group_rule_, and later index-based reattach calls CSSGroupingRule::Reattach with a non-group StyleRule*, leading to type confusion and the memory corruption.

NOTE: this is a resubmission of the report 488270255, since the previous issue is repurposed.

Details

CSS.setScopeText edits the prelude of an existing @scope rule by calling InspectorStyleSheet::SetScopeRuleText, which locates the existing CSSScopeRule wrapper and invokes CSSScopeRule::SetPreludeText.

The key problem is that CSSScopeRule::SetPreludeText replaces the wrapper’s internal group_rule_ pointer with a newly allocated StyleRuleScope, but does not replace the corresponding StyleRuleScope inside the stylesheet’s rule graph. This means the wrapper becomes detached from the real sheet contents, yet still participates in subsequent CSSOM calls and later Reattach() cascades (which assume wrapper/rule index+type stability).

In CSSScopeRule::SetPreludeText, the mutation ends by assigning a new rule object only to the wrapper field:

C++
  HeapVector<Member<StyleRuleBase>> new_child_rules;
  new_child_rules.ReserveInitialCapacity(
      GetStyleRuleScope().ChildRules().size());
  for (StyleRuleBase* child_rule : GetStyleRuleScope().ChildRules()) {
    new_child_rules.push_back(
        child_rule->Clone(new_style_scope->RuleForNesting(),
                          /*mixin_parameter_bindings=*/nullptr));
  }
  group_rule_ = MakeGarbageCollected<StyleRuleScope>(
      *new_style_scope, std::move(new_child_rules));

After this, page JS can mutate the stale CSSScopeRule wrapper (e.g. deleteRule() then insertRule('@media all {}', 0)) such that the wrapper’s child_rule_cssom_wrappers_ at index 0 becomes a CSSMediaRule, while the stylesheet-backed @scope still has a style rule at index 0.

Later, a parent rule mutation that performs a replacement+reattach (e.g. CSSStyleRule::setSelectorText) reattaches nested wrappers by index. During that reattach, the stale scope wrapper forwards ChildRules()[0] (a StyleRule*) into the CSSMediaRule wrapper’s Reattach(). CSSMediaRule inherits CSSGroupingRule::Reattach, which performs an unchecked cast:

In CSSGroupingRule::Reattach, the downcast is a static_cast without runtime validation:

C++
void CSSGroupingRule::Reattach(StyleRuleBase* rule) {
  DCHECK(rule);
  group_rule_ = static_cast<StyleRuleGroup*>(rule);
  for (unsigned i = 0; i < child_rule_cssom_wrappers_.size(); ++i) {
    if (child_rule_cssom_wrappers_[i]) {
      child_rule_cssom_wrappers_[i]->Reattach(
          group_rule_->ChildRules()[i].Get());
    }
  }
}

Once the wrapper’s group_rule_ is miscast to a StyleRuleGroup*, subsequent CSSOM operations on that wrapper (notably insertRule) can write through the misinterpreted layout, corrupting the real StyleRule object fields. A reliable symptom is that later style resolution (RuleSet construction) crashes in RuleSet::AddStyleRule/AddChildRules while iterating nested rules, consistent with a corrupted StyleRule::ChildRules() pointer.

Bisection

This issue is introduced by the commit: ed46557e198a8fce6c1ef52b38e5c17734c99ba9 [css-nesting] Implement CSSScopeRule::SetPreludeText by rule replacement.

Reproduction

Download the chrome from https://storage.googleapis.com/chromium-browser-asan/linux-release/asan-linux-release-1591355.zip

Run the chrome with the attached extension:

./chrome --load-extension=/path/to/ext --no-sandbox

You would observe the ASAN stack trace shown in the asan.txt

Suggested Fix

Harden CSSGroupingRule::Reattach against type mismatches by validating rule is a StyleRuleGroup before assigning it to group_rule_ (e.g. DynamicTo<StyleRuleGroup>).

The original report as published on the Chromium issue tracker, by Syn4pse. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely CSSScopeRule::SetPreludeText swapped only the wrapper's internal rule pointer for a fresh rule without updating the stylesheet's rule graph, so a later index-based Reattach passed a non-group StyleRule into an unchecked static_cast in CSSGroupingRule::Reattach.

Impact

An attacker who can drive these CSSOM edits could corrupt memory in the renderer and crash it, with the report not claiming anything beyond that.

What the attacker needed

Ability to run CSSOM edits via DevTools; a nested @scope rule in the page

The fix

The report suggests validating that the rule is a StyleRuleGroup before assigning it in CSSGroupingRule::Reattach.

How it was found

  1. Load the supplied extension into the ASAN build of Chrome and start it.
  2. Use the extension to call CSS.setScopeText on a nested @scope rule.
  3. Mutate the stale scope wrapper with deleteRule and then insertRule of a media rule at index 0.
  4. Trigger a parent rule mutation such as setSelectorText so nested wrappers are reattached by index.
  5. Observe the ASAN crash during later style resolution.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A web page's stylesheet is held in memory as a tree of rule objects, and the browser's developer tools can edit those rules live. This report shows that editing one kind of rule (an @scope block) made two copies of the tree disagree about what sat at each position. When the browser later matched them up by position, it treated one object as a different type than it really was, which can corrupt memory and crash the tab.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Syn4pse

View all

13 more disclosed reports, best first.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.