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

Use after free in Forms (CVE-2026-13848)

A static-analysis report claims that HTMLOptionElement::RemovedFrom does not check whether a state-preserving atomic move is in progress, so a synchronous DOM mutation can occur during moveBefore. This could leave a detached subtree with live frames and layout objects, potentially leading to a use-after-free or a security invariant crash.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 34 days

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: HTMLOptionElement::RemovedFrom lacks a StatePreservingAtomicMoveInProgress check, allowing synchronous DOM mutations during moveBefore. This can lead to detached subtrees with live frames and layout/DOM tree desynchronization, potentially enabling a use-after-free.

Affected files:

  • third_party/blink/renderer/core/html/forms/html_option_element.cc
  • third_party/blink/renderer/core/html/forms/html_select_element.cc
  • third_party/blink/renderer/core/html/forms/html_selected_content_element.cc

Estimated timestamp from git blame: 2024-10-10

Potential Use-After-Free via HTMLOptionElement::RemovedFrom and moveBefore DOM Mutation

Overview

A potential security vulnerability exists in Blink's handling of the state-preserving atomic move API (moveBefore). Specifically, HTMLOptionElement::RemovedFrom does not perform a StatePreservingAtomicMoveInProgress() check before calling into HTMLSelectElement::OptionRemoved. In default production configurations (where the experimental <selectedcontent> specification is disabled), this allows OptionRemoved to synchronously trigger a DOM mutation via ReplaceChildren on a connected <selectedcontent> element during the removal phase of moveBefore. This synchronous mutation can bypass the atomic move invariants, leading to a detached DOM subtree with live frames and layout/DOM tree desynchronization, which can result in a Use-After-Free (UAF) or an invariant security check crash.

Note: Since our tooling agent currently lacks the capability to run code dynamically, these findings and steps are based on static analysis of the source code and represent potential behavior.

Root Cause Analysis

During a state-preserving atomic move (such as when invoking moveBefore() on a node containing a <selectedcontent> element and an iframe), the document-wide flag StatePreservingAtomicMoveInProgress is set to true to ensure that frame disconnects and layout tree detachment are safely skipped during the removal phase (see container_node.cc).

However, during this phase:

  1. HTMLOptionElement::RemovedFrom() is invoked on a removed option element (see html_option_element.cc:636). It fails to verify if StatePreservingAtomicMoveInProgress() is active.
  2. It calls old_ancestor_select->OptionRemoved(*this, old_ancestor_select_child) (line 654).
  3. Under the default configuration, this invokes ResetToDefaultSelection, which executes SelectOption and triggers a synchronous call to UpdateAllSelectedcontentsSingle(element) (see html_select_element.cc).
  4. This method updates the descendant <selectedcontent> element by calling CloneContentsFromOptionElement (see html_selected_content_element.cc), which executes a synchronous DOM mutation via ReplaceChildren during node removal.
  5. The synchronous mutation increments the DOM tree version (IncDOMTreeVersion()), causing DOMTreeMutationDetector::NeedsRecheck() to return false (see container_node.cc).
  6. Consequently, RecheckNodeInsertionStructuralPrereq() fails (since the reference node's parent has been mutated), causing moveBefore to abort early with a NotFoundError exception.
  7. Because the move aborted after the removal phase (which ran while StatePreservingAtomicMoveInProgress was true), the skipped detachment operations are never performed. The removed element subtree is left detached but with live layout objects (LayoutObject) and its iframe's ContentFrame() active.

Potential Impact

  1. Use-After-Free (UAF): The detached subtree retains active LayoutObject pointers referencing the original parent's layout tree. If the parent layout tree is subsequently destroyed (for example, by setting display: none or removing the parent element from the DOM), these layout objects are freed, leaving the detached DOM elements with dangling pointers. Accessing or modifying these detached elements later can trigger a UAF.
  2. Security Invariant Crash: Re-inserting the detached element back into the document triggers HTMLFrameOwnerElement::InsertedInto (see html_frame_owner_element.cc:209). Since the iframe still holds a live ContentFrame() but StatePreservingAtomicMoveInProgress() is now false, this triggers a release-mode security crash (SECURITY_CHECK).

Suggested Reproduction Steps (Potential)

  1. Construct a DOM structure where an option is a descendant of a moving subtree, containing an iframe and a <selectedcontent> element sibling: select > button > [selectedcontent > span#ref] + [div#moving > (span > option[selected]) + iframe]
  2. Wait for the iframe to load.
  3. Call selectedcontent.moveBefore(moving, ref).
  4. Observe that the call throws a NotFoundError and leaves moving detached but with its iframe contentWindow non-null and layout objects active.
  5. Trigger a style/layout recalc on the button/select or set display: none to destroy the layout tree.
  6. Access/manipulate the children of moving to trigger the potential UAF, or append moving back to the document to observe the security invariant crash.

Suggested Fix

To mitigate this issue, HTMLOptionElement::RemovedFrom should perform a check for StatePreservingAtomicMoveInProgress() and skip calling OptionRemoved if a state-preserving atomic move is in progress.

Specifically, in third_party/blink/renderer/core/html/forms/html_option_element.cc:

C++
void HTMLOptionElement::RemovedFrom(ContainerNode& insertion_point) {
  HTMLElement::RemovedFrom(insertion_point);

  if (GetDocument().StatePreservingAtomicMoveInProgress()) {
    return;
  }

  HTMLSelectElement* old_ancestor_select = nearest_ancestor_select_;
  ...

Evaluated with Chrome root at commit: b1520ef4a76878853a31f0943b565e42060edec8


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.

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, HTMLOptionElement::RemovedFrom calls into select option-removal logic without checking StatePreservingAtomicMoveInProgress, so a synchronous DOM mutation aborts the move after removal but before the skipped detachment work runs.

Impact

The detached subtree could retain dangling layout pointers leading to a use-after-free, or re-insertion could trigger a release-mode security crash; the report notes these are potential findings from static analysis only.

What the attacker needed

Victim loads a crafted page; browser built from affected commit; experimental selectedcontent disabled

The fix

HTMLOptionElement::RemovedFrom should check StatePreservingAtomicMoveInProgress and skip calling OptionRemoved while a state-preserving atomic move is in progress.

How it was found

  1. Build a DOM where a moving subtree contains an option and an iframe, with a selectedcontent sibling.
  2. Wait for the iframe to load.
  3. Call moveBefore on the selectedcontent element with the moving subtree and a reference node.
  4. Observe the NotFoundError and that the moving subtree is detached but its iframe contentWindow is still non-null.
  5. Force a layout recalc or hide the parent to destroy the layout tree.
  6. Access the detached children to trigger the potential use-after-free, or re-append the subtree to hit the security check.

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 page moves part of its structure around, the browser normally keeps things consistent. Here the report argues that a piece of code can change the page in the middle of that move, leaving an element that is no longer on the page but still holds references to memory the browser thinks it has cleaned up. Using that stale reference later 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.