Use after free in HTML (CVE-2026-19144)
An earlier fix for a use-after-free in the HTML slot element only added a defensive copy of the child vector in one function, leaving three sibling functions iterating the same vector by reference. If layout or style traversal synchronously re-enters slot assignment recalculation, the backing vector is freed while still being iterated, which could lead to a use-after-free and a virtual call hijack.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 2 months
Project Fortify, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: An incomplete fix for crbug.com/497830330 in HTMLSlotElement leaves sibling loops iterating flat_tree_children_ by reference. If style or layout tree traversal re-enters slot assignment recalculation, the backing vector can be prompt-freed while still being iterated, potentially resulting in a use-after-free. This can potentially be reached via standard layout-tree-rebuild or accessibility-enabled paths.
Affected files:
third_party/blink/renderer/core/html/html_slot_element.cc
Estimated timestamp from git blame: 2026-04-02
Root Cause
The defensive fix for crbug.com/497830330 added a local copy of the backing vector only in HTMLSlotElement::DetachLayoutTree:
// third_party/blink/renderer/core/html/html_slot_element.cc
void HTMLSlotElement::DetachLayoutTree(bool performing_reattach) {
if (SupportsAssignment()) {
auto* host = OwnerShadowHost();
// Defensive copy to prevent UAF from sync recalc. See crbug.com/497830330.
const HeapVector<Member<Node>> flat_tree_children = assigned_nodes_;
for (auto& node : flat_tree_children) { ... }
However, three other sibling functions in the same file still iterate over flat_tree_children_ directly by reference without a defensive copy:
HTMLSlotElement::AttachLayoutTreeForSlotChildren:
void HTMLSlotElement::AttachLayoutTreeForSlotChildren(AttachContext& context) {
for (Node* child : flat_tree_children_) {
child->AttachLayoutTree(context);
}
}
HTMLSlotElement::RebuildDistributedChildrenLayoutTrees:
void HTMLSlotElement::RebuildDistributedChildrenLayoutTrees(
WhitespaceAttacher& whitespace_attacher) {
DCHECK(SupportsAssignment());
for (const auto& child : base::Reversed(flat_tree_children_)) {
RebuildLayoutTreeForChild(child, whitespace_attacher);
}
}
HTMLSlotElement::RecalcStyleForSlotChildren:
void HTMLSlotElement::RecalcStyleForSlotChildren(
const StyleRecalcChange change,
const StyleRecalcContext& style_recalc_context) {
for (auto& node : flat_tree_children_) {
...
}
}
If the inner loop body synchronously re-enters SlotAssignment::RecalcAssignment() for the slot's containing shadow root while needs_assignment_recalc_ == true, the recalculation will call RecalcFlatTreeChildren() which swaps the active vector:
void HTMLSlotElement::RecalcFlatTreeChildren() {
DCHECK(SupportsAssignment());
HeapVector<Member<Node>> old_flat_tree_children;
old_flat_tree_children.swap(flat_tree_children_);
...
}
When old_flat_tree_children goes out of scope, its destruction immediately calls cppgc::subtle::FreeUnreferencedObject(). This is a prompt-free operation that immediately reclaims and invalidates the backing memory by returning it to the allocator free-list, completely bypassing conservative stack scanning. On subsequent loop iterations, dereferencing the freed backing to fetch the next node can trigger a use-after-free.
Potential Trigger Path
Blink prevents recursive slot recalculations in debug builds via the SlotAssignmentRecalcForbiddenScope check, but this check compiles out in release builds, leaving production code vulnerable to synchronous re-entry during layout tree updates.
One potential non-AX path for triggering this is through RebuildDistributedChildrenLayoutTrees:
- A style/layout tree update triggers
RebuildDistributedChildrenLayoutTrees(whitespace_attacher), which loops overflat_tree_children_by reference. - In the first iteration,
RebuildLayoutTreeForChildcallsElement::RebuildLayoutTreeon a child element which needs reattachment. RebuildLayoutTreeattempts to find the parent layout object viaLayoutTreeBuilderTraversal::ParentLayoutObject(*this)->LayoutTreeBuilderTraversal::LayoutParent->FlatTreeTraversal::Parent->FlatTreeTraversal::TraverseParent.- Since the child's container is a shadow host,
TraverseParentreturnsnode.AssignedSlot(). Node::AssignedSlot()determines that the document is not currently in a slot assignment recalculation phase, and callsroot->GetSlotAssignment().RecalcAssignment()synchronously on the owner shadow root.RecalcAssignment()setsneeds_assignment_recalc_ = falseand callsDidRecalcAssignedNodes->RecalcFlatTreeChildren(), which swaps and prompt-frees the backing vector currently being iterated.- On the next loop iteration, the outer loop accesses the prompt-freed memory, leading to a UAF and a potential virtual function call hijack.
(Note: These are potential steps based on static analysis; our tooling does not currently have the capability to execute code to produce a fully functional proof-of-concept.)
Suggested Fix
To remediate this issue, apply a defensive copy of flat_tree_children_ or assigned_nodes_ before iterating in the remaining sibling functions (AttachLayoutTreeForSlotChildren, RebuildDistributedChildrenLayoutTrees, and RecalcStyleForSlotChildren), matching the defensive approach already implemented in HTMLSlotElement::DetachLayoutTree.
Evaluated with Chrome root at commit: d8b226a3be7c9c1ac9240c09e14698866c82e4ac
Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:
- If you are familiar with the severity guidelines, you may adjust the severity.
- If this is a false positive, and there's no work to be done, please close as WAI.
- If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.
Data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.
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 an incomplete fix: only one function took a defensive copy of the child vector before iterating, while three sibling functions still iterate the member vector by reference and can be re-entered synchronously.
Impact
This could lead to a use-after-free and potentially a virtual function call hijack, though the report is based on static analysis and no working proof-of-concept was produced.
What the attacker needed
Release build of the browser; layout tree rebuild or accessibility path
The fix
The remaining sibling functions should take a defensive copy of the child vector before iterating, matching the approach already used in the detach function.
How it was found
- A style or layout tree update enters the rebuild function, which loops over the child vector by reference.
- In the first iteration, rebuilding a child element looks up its parent layout object through flat tree traversal.
- The traversal asks the node for its assigned slot, which synchronously triggers slot assignment recalculation on the shadow root.
- The recalculation swaps and promptly frees the backing vector that the outer loop is still iterating.
- On the next iteration the loop reads the freed memory, giving a use-after-free.
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 slot is a placeholder in a web page component that gets filled with other elements. The browser keeps a list of those filled-in elements and walks through it; if something during that walk causes the list to be rebuilt and thrown away, the walk continues over memory that no longer belongs to it. That is a use-after-free: reading memory after it has been released, which can crash the browser or let an attacker influence what happens next.
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.