Use after free in SVG (CVE-2026-7906)
A use-after-free exists in Blink's SVG attribute synchronisation because a live hash set of shadow instances is iterated without a snapshot. A blur event fired mid-loop lets JavaScript add instances, rehash the set and free its backing store, so the resumed loop dereferences a dangling pointer and could allow code execution in the renderer.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 42 days
Project Fortify, an experimental security project, has identified the following potential security issue.
Overview: Iterating over InstancesForElement() in SVGElement::SynchronizeAttributeInShadowInstances uses an unprotected iterator. Synchronizing the removal of a tabindex attribute can trigger a synchronous blur event, allowing JavaScript to mutate the instances set, rehash its backing store, and cause a Use-After-Free when the loop resumes.
Affected files:
third_party/blink/renderer/core/svg/svg_element.ccthird_party/blink/renderer/core/svg/svg_svg_element.cc
Estimated timestamp from git blame: 2025-10-08
Summary
A potential highly reliable Use-After-Free (UAF) exists in SVGElement::SynchronizeAttributeInShadowInstances within Blink's SVG implementation. The vulnerability is caused by iterating over a live HeapHashSet (InstancesForElement()) without snapshotting it. A synchronous DOM event (blur) can be triggered during this iteration, allowing an attacker to execute JavaScript, mutate the HeapHashSet, and force a rehash. This explicitly frees the collection's backing store, leaving the C++ iterator with a dangling pointer that is subsequently dereferenced.
Vulnerability Details
The vulnerable method is SVGElement::SynchronizeAttributeInShadowInstances:
void SVGElement::SynchronizeAttributeInShadowInstances(
const QualifiedName& name,
const AtomicString& value) {
const HeapHashSet<WeakMember<SVGElement>>& set = InstancesForElement();
for (SVGElement* instance : set) {
instance->SetAttributeWithoutValidation(name, value);
}
}
The range-based for loop uses a HashTableConstIterator which holds a raw pointer directly into the HeapHashSet's contiguous backing store array. Concurrent modification checks (container_modifications_ == container_->Modifications()) exist but are guarded by DCHECK_IS_ON() and are entirely compiled out in Release builds.
When instance->SetAttributeWithoutValidation is called to synchronize the removal of the tabindex attribute (value is null), it propagates down to Element::AttributeChanged. If the shadow instance is currently focused, removing tabindex makes it unfocusable (!IsFocusable()), which causes Element::AttributeChanged to synchronously call blur().
The blur() method synchronously dispatches a blur event. An attacker can attach an event listener to capture this event, suspending the C++ iteration and executing arbitrary JavaScript.
Inside the JavaScript handler, the attacker can add new <use> elements to the DOM that reference the original <svg> target. This causes SVGElement::AddInstance to be called, inserting new instances into the HeapHashSet. If enough elements are added to exceed the load factor, the HeapHashSet performs a rehash.
During rehashing, the old backing store is explicitly freed via cppgc::subtle::FreeUnreferencedObject. The attacker can then use standard Oilpan heap spraying techniques within the same JavaScript execution to reclaim the freed backing store memory and populate it with fake SVGElement pointers.
When the JavaScript handler finishes and control returns to the C++ for loop, the iterator advances using its dangling pointer. It retrieves an attacker-controlled SVGElement* and calls instance->SetAttributeWithoutValidation, leading to virtual method calls on the fake object and granting arbitrary Remote Code Execution (RCE) in the renderer process.
Potential Trigger Steps
Note: This sequence has been formulated by an AI agent and represents a theoretical trigger path; no working PoC has been executed yet.
- Create an
<svg id="target" tabindex="0">element. - Create a
<use href="#target">element, which instantiates a shadow instance. - Register a
blurevent listener on thewindow(capturing phase). - Programmatically or manually focus the rendered
<use>element (the shadow instance inherits thetabindex). - Use JavaScript to remove the
tabindexfrom the target:document.getElementById('target').removeAttribute('tabindex');. - The
SynchronizeAttributeInShadowInstancesloop begins in C++. - The
tabindexremoval is synchronized to the shadow instance, synchronously triggering theblurevent. - In the JS
blurhandler, append many new<use href="#target">elements to the DOM and force a synchronous layout (e.g., by readingoffsetTop) to ensure the shadow trees are built and added toInstancesForElement(). - Still in the JS handler, allocate many objects of the same size as the backing store to reclaim the explicitly freed memory.
- The JS handler returns, the C++ loop resumes, and the UAF is triggered.
Suggested Fix
Do not iterate directly over the live HeapHashSet if the loop body can execute script. Instead, snapshot the collection into a local HeapVector before iterating:
void SVGElement::SynchronizeAttributeInShadowInstances(
const QualifiedName& name,
const AtomicString& value) {
HeapVector<Member<SVGElement>> instances;
CopyToVector(InstancesForElement(), instances);
for (SVGElement* instance : instances) {
if (instance) {
instance->SetAttributeWithoutValidation(name, value);
}
}
}
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.
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 loop iterates the live HeapHashSet without copying it first, and the modification check that would catch changes is compiled out in release builds.
Impact
The text claims this could lead to arbitrary remote code execution in the renderer process, but it is a theoretical path with no working proof of concept executed.
What the attacker needed
Victim loads a crafted page; JavaScript enabled; no working exploit demonstrated
The fix
The suggested fix copies the set into a local vector before iterating so script cannot invalidate the iterator.
How it was found
- Create an SVG element with a tabindex attribute.
- Add a use element that references it, creating a shadow instance.
- Register a capturing blur listener on the window.
- Focus the rendered shadow instance.
- Remove the tabindex from the target so synchronisation fires a blur event.
- In the blur handler add many use elements to force a rehash, then let the loop resume.
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 one SVG element is reused inside another, the browser keeps a list of the copies so it can update them together. This code walked that list directly while running other code that could change the list, so the list could be moved in memory and the walker would then read freed memory. That kind of mistake, called a use-after-free, can crash the browser or let an attacker run their own 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.