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

Use after free in DOM (CVE-2026-9126)

A heap use-after-free exists in Blink's attribute cloning because raw pointer iterators can be invalidated by synchronous JavaScript events. An attacker could trigger memory corruption and potentially achieve remote code execution in the renderer process.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 56 days

Project Fortify, an experimental security project, has identified the following potential security issue.

Overview: A potential heap use-after-free vulnerability exists in Blink's Element::CloneAttributesFrom due to raw pointer iterators being invalidated during attribute cloning. By triggering synchronous beforetoggle events during a popover attribute change, an attacker can reallocate the attribute vector, leaving the iteration loop with stale pointers. This can lead to memory corruption and potential Remote Code Execution in the renderer process.

Affected files:

  • third_party/blink/renderer/core/dom/element.cc
  • third_party/blink/renderer/core/editing/commands/replace_node_with_span_command.cc
  • third_party/blink/renderer/core/html/html_element.cc
  • third_party/blink/renderer/core/editing/commands/replace_selection_command.cc

Estimated timestamp from git blame: 2025-11-04

Summary

A potential heap use-after-free (UAF) vulnerability has been identified in Element::CloneAttributesFrom in Blink. The issue occurs because the function iterates over an element's attributes using a range-based for loop, which desugars to raw pointers (const Attribute*) pointing into a WTF::Vector backing buffer on the PartitionAlloc heap.

Synchronous JavaScript execution triggered during this loop can reallocate the vector, freeing the backing buffer while the raw pointer iterators are still on the stack. Because these iterators are raw pointers, they are not protected by MiraclePtr (BRP).

Technical Details

In third_party/blink/renderer/core/dom/element.cc, the attribute cloning process loops over the source element's attributes and applies them to the target element:

C++
void Element::CloneAttributesFrom(const Element& other) {
  // ... 
  for (const Attribute& attr : element_data_->Attributes()) {
    attribute_or_class_bloom_ |= FilterForAttribute(attr.GetName());
    AttributeChanged(
        AttributeModificationParams(attr.GetName(), g_null_atom, attr.Value(),
                                    AttributeModificationReason::kByCloning));
  }
  // ...
}

The element_data_->Attributes() collection uses raw const Attribute* iterators. If AttributeChanged triggers synchronous JavaScript, the underlying AttributeVector (a WTF::Vector<Attribute, 4>) can be modified, causing it to exceed its capacity, reallocate a new buffer, and free the old one.

Potential Attacker Steps (Theoretical)

Note: These are suggested steps, as our setup does not execute code to verify a working proof-of-concept.

  1. Setup: The attacker creates a target element with popover="manual" and at least 5 attributes (to ensure the AttributeVector uses a heap-allocated PartitionAlloc buffer instead of inline capacity). An iframe with an unload event listener is appended as a child of this element.
  2. Trigger Command: The attacker executes an editing command like insertHTML which invokes ReplaceNodeWithSpanCommand.
  3. Pre-arming via Unload: ReplaceNodeWithSpanCommand inserts a new span and moves the children to it. Moving the iframe fires a synchronous unload event. In this handler, the attacker's script sets the new span to popover="auto" and calls showPopover().
  4. Attribute Cloning: C++ execution resumes. CloneAttributesFrom begins iterating over the attributes to copy them to the new span.
  5. The Trap: When the loop reaches the popover attribute (copying the value "manual"), it calls AttributeChanged, which routes to HTMLElement::UpdatePopoverAttribute.
  6. Synchronous Event: UpdatePopoverAttribute detects a type mismatch (the element is currently an "auto" popover, but the attribute is changing to "manual"). It calls HidePopoverInternal, which synchronously dispatches a beforetoggle event via DispatchEvent.
  7. Reallocation (UAF Trigger): The attacker catches the beforetoggle event in JavaScript. The script repeatedly calls setAttribute on the new span. This appends new attributes to the span's UniqueElementData attribute vector, forcing WTF::Vector to reallocate and free the old PartitionAlloc backing buffer.
  8. Exploitation: The attacker script reclaims the freed PartitionAlloc chunk using heap spraying (e.g., ArrayBuffers) filled with fake Attribute structures containing controlled StringImpl pointers. When C++ execution returns to the for loop, it increments the stale raw pointer iterator and reads the fake objects, leading to an arbitrary read/write primitive and potential RCE.

Suggested Fix

Do not use range-based for loops (which rely on raw pointer iterators) when iterating over collections that can be modified by synchronous JavaScript execution.

Instead, iterate over the attributes using a stable index (wtf_size_t i = 0; i < element_data_->Attributes().size(); ++i), or take an inline copy/snapshot of the attributes vector before iterating through them. Using an index ensures that even if the underlying WTF::Vector reallocates its backing buffer, the next element access (at(i)) will correctly read from the newly allocated buffer.

Evaluated with Chrome root at commit: a3f5fcb392f2902650ca2b71820e7e418787e18b


Results so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; data from false positives will be used to improve accuracy over time. Please feel free to reach out to me if you have concerns or feedback.

The original report as published on the Chromium issue tracker. 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, the code iterates over a vector of attributes using raw pointers that are not protected against reallocation caused by synchronous JavaScript execution during the loop.

Impact

This could lead to memory corruption and potential remote code execution in the renderer process, though the report notes the steps are theoretical and not verified with a working proof-of-concept.

What the attacker needed

Victim visits a malicious page; browser runs vulnerable Blink version; JavaScript enabled

The fix

The code should be fixed by iterating with a stable index or taking a snapshot of the attributes vector before iterating, so that reallocation does not leave stale pointers.

How it was found

  1. Create a target element with popover="manual" and at least five attributes, and append an iframe with an unload event listener.
  2. Execute an editing command such as insertHTML that invokes ReplaceNodeWithSpanCommand.
  3. In the iframe's unload handler, set the new span to popover="auto" and call showPopover().
  4. CloneAttributesFrom begins iterating over the attributes to copy them to the new span.
  5. When the loop reaches the popover attribute, AttributeChanged calls UpdatePopoverAttribute, which dispatches a beforetoggle event.
  6. In the beforetoggle handler, repeatedly call setAttribute to force the attribute vector to reallocate and free the old buffer, then spray the heap to reclaim the freed chunk.

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.

When a web browser copies attributes from one element to another, it uses a list that can be changed while it is being read. If a script runs in the middle of that reading and changes the list, the browser may later read from memory that has already been freed, which can crash or be abused to run attacker code.

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 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.