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

Use after free in Loader (CVE-2026-17661)

A use-after-free in Chromium's DocumentLoader::ProcessDataBuffer occurs because a range-based for loop iterates over a buffer that can be reallocated by synchronous script execution. An attacker could potentially read arbitrary renderer memory by grooming the heap and causing the loop to dereference a dangling iterator.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 4 months

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

Overview: A potential Use-After-Free vulnerability exists in DocumentLoader::ProcessDataBuffer due to iterator invalidation during a C++ range-based for loop. Synchronous script execution (e.g., via Synchronous XHR) can cause reentrant data appending that reallocates the iterated buffer's backing store. The outer loop subsequently dereferences a dangling iterator, potentially allowing an attacker to read arbitrary renderer memory.

Affected files:

  • third_party/blink/renderer/core/loader/document_loader.cc
  • third_party/blink/renderer/platform/wtf/shared_buffer.h
  • third_party/blink/renderer/platform/wtf/shared_buffer.cc
  • third_party/blink/renderer/platform/loader/fetch/url_loader/navigation_body_loader.cc
  • third_party/blink/renderer/core/xml/parser/xml_document_parser.cc
  • third_party/blink/renderer/core/frame/web_frame_widget_impl.cc

Estimated timestamp from git blame: 2022-10-10

Description

A potential Use-After-Free (UAF) vulnerability occurs in DocumentLoader::ProcessDataBuffer due to unsafe iteration over a SegmentedBuffer (data_buffer_) using a C++ range-based for loop.

C++
  for (const auto& span : *data_buffer_) {
    EncodedBodyData body_data(span);
    CommitData(body_data);
  }

CommitData() synchronously parses incoming data. For XML-family documents (e.g., XHTML), parsing a <script> tag results in synchronous JavaScript execution. If the script triggers a nested message loop (e.g., by executing a Synchronous XMLHttpRequest), a ScopedPagePauser is created, which temporarily pauses the frame.

When the Sync XHR completes, the page is unpaused. This cascades to NavigationBodyLoader::SetDefersLoading(kNone), which immediately calls OnReadable() to process any network data that arrived while paused. Because the original invocation of ProcessDataBuffer originated from ResumeParser() (not a network callback), NavigationBodyLoader's reentrancy guard (is_in_on_readable_) is not active.

The newly arrived data re-enters ProcessDataBuffer. Because the outer CommitData() is still on the stack, the in_commit_data_ flag is true, causing the new data to be buffered via data_buffer_->Append(). This appends a new Segment to the SegmentedBuffer's internal WTF::Vector. If the vector's capacity is exceeded, it reallocates its backing store, freeing the old memory.

Once the nested loop unwinds and the outer CommitData() completes, the range-based for loop increments its iterator (segment_it_). Because the backing store was freed, segment_it_ is a dangling pointer, leading to a Use-After-Free.

Potential Attack Steps

Note: Our tooling agent cannot run live code; these are theoretical, suggested steps to trigger the vulnerability based on static analysis.

  1. Setup: The attacker embeds an Out-of-Process Iframe (OOPIF) pointing to an attacker-controlled XHTML document. Initially, parsing is blocked (e.g., while waiting for the frame's initial size).
  2. Buffer and Resume: The server sends a chunk containing a <script> tag, which is buffered. When the frame is resized, ResumeParser() is called, triggering ProcessDataBuffer() to iterate over the chunks.
  3. Synchronous Execution: CommitData() parses the <script>, executing a Synchronous XMLHttpRequest. This spins up a nested message loop and pauses the page.
  4. Reallocation: While paused, the server sends enough additional chunks to exceed the SegmentedBuffer's internal vector capacity.
  5. Re-entry & Free: The Sync XHR finishes, unpausing the page. OnReadable() processes the pending chunks, re-entering ProcessDataBuffer() and triggering data_buffer_->Append(). The vector reallocates, freeing the original segment list.
  6. Heap Grooming (Exploitation): The attacker grooms the renderer heap so the freed vector backing store is replaced with forged Segment objects pointing to arbitrary memory addresses.
  7. Information Leak: The outer loop resumes, increments the dangling iterator, and reads the forged Segment. The arbitrary memory is passed to CommitData(), parsed as text, and appended to the DOM, where the attacker's script can read it.
  8. Graceful Termination: The attacker supplies an empty forged segment. std::ranges::equal considers two empty spans equal, making the loop iterator match the end() iterator and safely terminating the loop without crashing.

Suggested Fix

Do not use a range-based for loop to iterate over data_buffer_ while calling CommitData(), as CommitData() can synchronously execute scripts that mutate the buffer.

A robust fix is to destructively consume the buffer (e.g., TakeData()) or move the segments to a local variable before iterating over them. For example:

C++
  Vector<Vector<char>> segments = std::move(*data_buffer_).TakeData();
  data_buffer_->Clear();
  for (const auto& segment : segments) {
    EncodedBodyData body_data(base::make_span(segment));
    CommitData(body_data);
  }

This ensures the iterated container cannot be modified by reentrant calls.

Evaluated with Chrome root at commit: a9cbf6e8b275fe4147435aa905f3b7f5a656f5f0


Results from 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

Likely the range-based for loop iterates over a buffer that can be synchronously modified and reallocated by reentrant calls during CommitData(), invalidating the loop's iterator.

Impact

An attacker could potentially read arbitrary renderer memory, but the report notes the steps are theoretical and have not been run.

What the attacker needed

Attacker-controlled XHTML document; victim loads the document in an iframe; server can send data in chunks; synchronous XHR allowed

The fix

The buffer should be destructively consumed or its segments moved to a local variable before iterating, so reentrant calls cannot modify the iterated container.

How it was found

  1. The attacker embeds an out-of-process iframe pointing to an attacker-controlled XHTML document, with parsing initially blocked.
  2. The server sends a chunk containing a script tag, which is buffered; when the frame is resized, ResumeParser() calls ProcessDataBuffer().
  3. CommitData() parses the script, which executes a synchronous XMLHttpRequest, creating a nested message loop and pausing the page.
  4. While paused, the server sends enough additional chunks to exceed the SegmentedBuffer's internal vector capacity.
  5. When the synchronous XHR finishes, the page unpauses and OnReadable() re-enters ProcessDataBuffer(), appending data and causing the vector to reallocate and free the original segment list.
  6. The attacker grooms the heap so the freed memory is replaced with forged Segment objects, then the outer loop resumes and reads arbitrary memory into the DOM.

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 use-after-free happens when a program keeps a pointer to memory after that memory has been freed and reused. Here, a loop in the browser's page loader holds a pointer into a list of data chunks, but running a script can add more chunks and move the list in memory, leaving the loop pointing at the old location. If an attacker can control what replaces that old memory, they might trick the browser into reading and showing them data from elsewhere in its memory.

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.