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

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

A use-after-free in Blink's form state restoration occurs because a range-based loop iterates over a cached list of form elements that can be synchronously cleared by DOM mutations during restoration. An attacker could potentially achieve type confusion and arbitrary code execution in the renderer.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 13 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 without the security team.

Overview: A potential Use-After-Free (UAF) vulnerability exists in the Blink renderer due to iterator invalidation during form state restoration. FormController::RestoreControlStateIn iterates over a cached list of form elements that can be synchronously cleared mid-iteration by DOM mutations triggered when restoring <select> elements. This allows an attacker to free and reclaim the iterator's backing buffer, leading to type confusion and arbitrary code execution in the renderer.

Affected files:

  • third_party/blink/renderer/core/html/forms/form_controller.cc
  • third_party/blink/renderer/core/html/forms/html_form_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: 2019-09-29

Summary

A potential Use-After-Free (UAF) vulnerability exists in the Blink renderer's form restoration logic. Specifically, FormController::RestoreControlStateIn iterates over a HeapVector of listed elements using a C++ range-based for loop. During this iteration, the restoration of a <select> element containing a <selectedcontent> element can trigger a synchronous DOM mutation. If this mutation removes an existing form-associated element, it clears the form's internal element cache, freeing the backing buffer while the loop's iterators are still actively pointing to it.

Technical Details

In third_party/blink/renderer/core/html/forms/form_controller.cc, RestoreControlStateIn processes elements during history navigation:

C++
void FormController::RestoreControlStateIn(HTMLFormElement& form) {
  // ...
  const ListedElement::List& elements = form.ListedElements();
  for (const auto& control : elements) { // Caches raw __begin and __end pointers
    if (!control->ClassSupportsStateRestore())
      continue;
    // ...
    RestoreControlStateInternal(*control);
  }
}

The range-based for loop caches raw pointers to the HeapVector's backing buffer. Inside the loop, RestoreControlStateInternal invokes HTMLSelectElement::RestoreFormControlState. If the select element has a <selectedcontent> descendant, it calls UpdateAllSelectedcontents, which clones the new option's contents and replaces the old contents via ReplaceChildren.

If the <selectedcontent> previously contained a form-associated element (e.g., an <input>), ReplaceChildren detaches it. This removal synchronously triggers HTMLFormControlElement::RemovedFrom -> ListedElement::ResetFormOwner -> HTMLFormElement::Disassociate.

HTMLFormElement::Disassociate calls listed_elements_.clear(). For a HeapVector, this translates to ShrinkCapacity(0), which synchronously invokes cppgc::subtle::FreeUnreferencedObject. If no GC pause is active, the memory is immediately returned to the cppgc Linear Allocation Buffer (LAB) or free list.

The range-based for loop resumes, increments its dangling iterator, and dereferences the reclaimed memory. The subsequent virtual call (control->ClassSupportsStateRestore()) results in a type confusion and control-flow hijack. MiraclePtr (BRP) does not prevent this because the freed memory is a cppgc backing buffer.

Potential Attacker Steps

Please note: These are suggested steps based on static analysis. Our tooling agent does not have the ability to execute code to produce a live proof-of-concept.

  1. Construct a web page with an <form>.
  2. Inside the form, place a <select> element associated with a <selectedcontent> element.
  3. Inside the <selectedcontent> element, nest a form-associated control like an <input>. This places the <input> into the form's cached ListedElements().
  4. Add extra dummy form controls to the page to pad the ListedElements() vector to a target size, allowing for precise cppgc heap grooming.
  5. Use JavaScript to change the <select> element's selected option, saving its state.
  6. Navigate the page away, then trigger a history.back() navigation.
  7. Upon restoration, the <select> triggers the removal of the <input>, freeing the HeapVector buffer synchronously.
  8. The subsequent allocations from the CloneContentsFromOptionElement operation reclaim the freed buffer with attacker-controlled data.
  9. The loop dereferences the attacker-controlled fake object, hijacking the renderer process via a fake vtable.

Suggested Fix

Do not iterate over the live reference returned by form.ListedElements(), as it is highly susceptible to mutation during event dispatch or DOM modifications. Instead, make a local copy of the HeapVector before iterating. This safely anchors the elements and protects the backing buffer from being destroyed by cache invalidation:

C++
void FormController::RestoreControlStateIn(HTMLFormElement& form) {
  // ...
  ListedElement::List elements_copy(form.ListedElements());
  for (const auto& control : elements_copy) {
    // ...
  }
}

Evaluated with Chrome root at commit: 09ec9e7cc4d24823d20b6d37cf3d282734f6bf0f


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

The code iterates over a live reference to a list of form elements that can be cleared synchronously during iteration, leaving dangling pointers.

Impact

An attacker could potentially achieve type confusion and arbitrary code execution in the renderer, though the report notes this is based on static analysis without a live proof-of-concept.

What the attacker needed

Victim visits a crafted web page; victim navigates away and back

The fix

The code should make a local copy of the list of elements before iterating to prevent the backing buffer from being destroyed.

How it was found

  1. Create a web page with a form containing a select element and a selectedcontent element.
  2. Nest a form-associated control like an input inside the selectedcontent element.
  3. Add extra dummy form controls to pad the list of elements for heap grooming.
  4. Use JavaScript to change the select's selected option and save its state.
  5. Navigate away and then trigger a history.back() navigation.
  6. Upon restoration, the select triggers removal of the input, freeing the list buffer, and subsequent allocations reclaim it with attacker-controlled data.

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 is restored from history, the browser tries to put form fields back to their previous values. A bug in that process means the browser can free a list of form fields while still reading from it, which can crash or let an attacker run their own code. This is called a use-after-free because the program uses memory after it has been freed.

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.