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

Use after free in Blink (CVE-2026-5872)

A potential reentrancy vulnerability in Blink's multi-node insertion methods allows an attacker's iframe unload handler to reparent a node during argument preparation, bypassing structural safety checks and corrupting the DOM tree. This corruption could lead to use-after-free or type confusion, potentially enabling remote code execution in the renderer process.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 14 days

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

Overview: A potential reentrancy vulnerability exists in Blink's multi-node insertion paths (e.g., append(), prepend()). Synchronous iframe unload events triggered during argument preparation can allow attacker script to reparent a node, bypassing structural safety checks. This blindly splices the node into a new tree while leaving stale pointers in the old parent, corrupting the DOM and enabling potential Use-After-Free (UAF) or type confusion.

Affected files:

  • third_party/blink/renderer/core/dom/node.cc
  • third_party/blink/renderer/core/dom/container_node.cc

Estimated timestamp from git blame: 2024-10-29

Summary

There is a potential DOM tree linked-list corruption vulnerability in Blink's variadic DOM mutation methods (append, prepend, before, after, replaceWith, replaceChildren). When multiple nodes are passed to these methods, they are processed by Node::ConvertNodeUnionsIntoNodes, which iteratively removes each node from its current parent. If an argument contains an <iframe>, its removal fires a synchronous unload event.

Malicious JavaScript in the unload handler can reparent a node that was removed in an earlier iteration of the loop. Because the multi-child insertion paths (e.g., ContainerNode::AppendChildren) explicitly skip the RecheckNodeInsertionStructuralPrereq check when the number of new children is greater than 1, the reparented node is blindly inserted into the target container. This corrupts the DOM tree by leaving dangling child pointers in the old parent.

Note: The following are suggested/potential steps, as our setup does not have the ability to execute code to create a working proof of concept.

Potential Steps to Reproduce

  1. An attacker creates an HTML page and executes JavaScript to create an empty target element, an empty node1, and a node2 containing a same-origin <iframe>.
  2. The attacker registers an unload event listener on the iframe's window.
  3. The attacker calls target.append(node1, node2).
  4. In Node::ConvertNodeUnionsIntoNodes, Blink iterates over the arguments:
    • node1 is detached (node1->remove()).
    • node2 is detached (node2->remove()).
  5. Detaching node2 tears down the iframe, which synchronously fires the unload event, pausing C++ execution and running the attacker's JavaScript.
  6. The attacker's unload script executes evilParent.appendChild(node1), reparenting node1 into a new, unrelated DOM element.
  7. C++ execution resumes. ConvertNodeUnionsIntoNodes returns [node1, node2]. Critically, node1 is no longer an orphan; its parentNode() is evilParent.
  8. Execution proceeds to ContainerNode::AppendChildren.
  9. AppendChildren has a check: if (new_children.size() == 1u) { ... RecheckNodeInsertionStructuralPrereq(...) }. Because there are 2 children, this block is skipped.
  10. node1 is passed to ContainerNode::AppendChildCommon, which updates node1's parentNode, nextSibling, and previousSibling pointers to link it into target.
  11. However, node1 was never properly removed from evilParent. evilParent still holds raw pointers to node1 in its internal child linked list.
  12. The DOM tree is now corrupted with overlapping sibling and parent pointers, which will likely confuse Blink's Layout and Style engines and lead to a Use-After-Free.

Technical Details

  • File: third_party/blink/renderer/core/dom/node.cc Node::ConvertNodeUnionsIntoNodes sequentially calls node->remove(exception_state) (line ~1151). This triggers ContainerNode::RemoveChild, which fires synchronous detachment events.
  • File: third_party/blink/renderer/core/dom/container_node.cc ContainerNode::AppendChildren (and similar methods like InsertBefore) only perform the post-removal sanity check RecheckNodeInsertionStructuralPrereq if new_children.size() == 1u (line ~1156). When multiple children are inserted, this crucial guard is bypassed.
  • Inside ContainerNode::InsertNodeVector, the debug assertion DCHECK(!target_node->parentNode()) catches this in debug builds, but it compiles to a no-op in release builds, allowing the DOM corruption to proceed.

Impact

DOM tree corruption is a highly reliable primitive for memory corruption. Blink's layout objects, layers, and style recalculation engines rely heavily on the integrity of the DOM tree. Crossing sibling pointers between unrelated subtrees can deterministically trigger Use-After-Free or Type Confusion vulnerabilities, leading to Remote Code Execution (RCE) in the sandboxed renderer process.

Suggested Fix

Ensure that the structural integrity check is performed regardless of the number of nodes being inserted.

  1. Modify ContainerNode::AppendChildren, InsertBefore, ReplaceChild, and ReplaceChildren to unconditionally call RecheckNodeInsertionStructuralPrereq (or a variant of it designed for multi-node vectors) after the ConvertNodeUnionsIntoNodes step has completed and before InsertNodeVector is called.
  2. Alternatively, modify Node::ConvertNodeUnionsIntoNodes to verify that all nodes in the returned VectorOf<Node> are orphans (!node->parentNode()) immediately before returning, and throw an exception if any node has acquired a parent during the removal loop.

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 multi-child insertion path skips the structural prerequisite check when more than one child is inserted, allowing a node reparented during a synchronous unload event to be inserted while still referenced by its old parent.

Impact

DOM tree corruption could deterministically trigger use-after-free or type confusion, potentially leading to remote code execution in the sandboxed renderer process.

What the attacker needed

Victim visits attacker-controlled page; same-origin iframe; JavaScript enabled

The fix

The structural integrity check should be performed unconditionally after argument conversion and before insertion, or the conversion step should verify all nodes are orphans and throw an exception if not.

How it was found

  1. Create an empty target element, an empty node1, and a node2 containing a same-origin iframe.
  2. Register an unload event listener on the iframe's window.
  3. Call target.append(node1, node2).
  4. During argument processing, node1 and node2 are detached; detaching node2 fires the unload event synchronously.
  5. In the unload handler, reparent node1 into a new element (evilParent).
  6. Execution resumes and node1 is inserted into target without the structural check, leaving evilParent with stale pointers to node1.

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 you add several elements to a web page at once, the browser first removes each from its old parent. If one of those elements is an iframe, removing it triggers an 'unload' event, and JavaScript in that event can move an already-removed element to a new parent. The browser then inserts that element again without checking it is still detached, leaving the old parent with a broken pointer to it. This can crash the browser or, in theory, let an attacker run 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.