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

Use after free in WebXR (CVE-2026-17881)

An unchecked integer overflow in the WebXR callback ID counter can make a callback ID reach -1, which Blink's hash map treats as a deleted bucket, so the garbage collector skips tracing the callback and frees it. The next WebXR frame then looks up that ID and calls a virtual method on the freed object, a potential use-after-free.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 47 days

Flapjack, 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 integer overflow in XRFrameRequestCallbackCollection can cause a callback ID to reach -1, a reserved sentinel value in Blink's hash maps. This collision causes the garbage collector to skip tracing the callback object, prematurely freeing it. When the WebXR frame executes, it successfully retrieves and uses the dangling pointer, resulting in a potential Use-After-Free.

Affected files:

  • third_party/blink/renderer/modules/xr/xr_frame_request_callback_collection.cc
  • third_party/blink/renderer/modules/xr/xr_frame_request_callback_collection.h

Estimated timestamp from git blame: Unknown (Google3 checkout)

Summary

A potential Use-After-Free (UAF) vulnerability exists in XRFrameRequestCallbackCollection due to an unchecked integer overflow of the next_callback_id_ counter. When this 32-bit signed integer overflows and eventually reaches the value -1, it collides with the DeletedValue sentinel used by Blink's HeapHashMap. This causes the garbage collector to skip tracing the associated callback object, leaving a dangling pointer in the map which is subsequently accessed during frame execution.

Technical Details

In third_party/blink/renderer/modules/xr/xr_frame_request_callback_collection.cc, the RegisterCallback method generates a new ID for each requestAnimationFrame callback using a 32-bit signed integer:

C++
XRFrameRequestCallbackCollection::CallbackId
XRFrameRequestCallbackCollection::RegisterCallback(
    V8XRFrameRequestCallback* callback) {
  CallbackId id = ++next_callback_id_;
  // ...
  auto add_result_frame_request = callback_frame_requests_.Set(id, callback);
  pending_callbacks_.push_back(id);
  return id;
}

An attacker can overflow next_callback_id_ by repeatedly registering and canceling WebXR callbacks. By spreading these requests across multiple frames, the attacker avoids Out-Of-Memory (OOM) crashes, as pending_callbacks_ is cleared at the start of every frame and canceled callbacks are garbage collected.

When the counter wraps around and becomes -1, the ID is inserted into callback_frame_requests_. Because CallbackId is an int, Blink uses WTF::IntHashTraits<int>, which reserves 0 as the EmptyValue and -1 as the DeletedValue. Inserting -1 corrupts the internal state of the HeapHashMap, as the bucket is implicitly marked as deleted.

During Garbage Collection, TraceHashTableBackingInCollectionTrait::Trace (third_party/blink/renderer/platform/heap/collection_support/heap_hash_table_backing.h) iterates the map's backing store to trace live objects. It explicitly skips buckets whose keys match the empty or deleted sentinels:

C++
if (!IsHashTraitsEmptyOrDeletedValue<typename Table::KeyTraitsType>(
        Extractor::ExtractKey(UNSAFE_TODO(array[i])))) {
  blink::TraceCollectionIfEnabled<weak_handling, Value, Traits>::Trace(
      visitor, &UNSAFE_TODO(array[i]));
}

Because the attacker's bucket has the key -1, IsHashTraitsEmptyOrDeletedValue(-1) evaluates to true. Oilpan skips tracing the Member<V8XRFrameRequestCallback> pointer, assumes the object is unreachable, and sweeps it. The bucket now contains a dangling pointer.

When XRFrameRequestCallbackCollection::ExecuteCallbacks runs for the frame, it iterates over pending_callbacks_ (which contains -1) and calls current_callback_frame_requests_.find(-1). For integer keys, kSafeToCompareToEmptyOrDeleted is true, causing HashTable::Lookup to bypass standard sentinel checks and return the bucket if the key exactly matches. The code then executes it_frame_request->value->InvokeAndReportException(session, timestamp, frame);, resulting in a virtual method call on a freed object.

Potential Attack Steps

(Note: These are suggested steps; our tooling agent does not yet have the ability to run code.)

  1. Initialize Session: An attacker initiates a WebXR session via navigator.xr.requestSession('inline').
  2. Flood and Cancel: The attacker runs a loop in Javascript that repeatedly calls session.requestAnimationFrame(callback) and session.cancelAnimationFrame(id).
  3. Span Frames: The loop is spread across multiple animation frames (e.g., 100,000 iterations per frame) to clear pending_callbacks_ and allow GC of canceled wrappers, avoiding OOM.
  4. Overflow: After $2^{32} - 1$ calls, the internal counter overflows to -1. The -1 callback is registered but not canceled.
  5. Trigger GC: The attacker triggers garbage collection (via memory pressure or natural GC cycles), causing the -1 callback object to be freed.
  6. Trigger UAF: The browser renders the next WebXR frame, triggering ExecuteCallbacks, retrieving the dangling pointer, and executing the UAF.

Suggested Fix

Ensure that next_callback_id_ never takes on reserved sentinel values (such as 0 and -1). This can be achieved by skipping these values during increment:

C++
CallbackId id;
do {
  id = ++next_callback_id_;
} while (id <= 0); // or !IsValidCallbackId(id)

Alternatively, change CallbackId to an unsigned 64-bit integer, which realistically cannot overflow.

Evaluated with Chrome root at commit: 65b3256311f3ab6fb9870eaa522de7e6dd2663bb


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 the callback ID counter is a signed 32-bit integer that is incremented without skipping the reserved sentinel values 0 and -1 used by Blink's hash map traits.

Impact

A page could potentially cause a use-after-free in the renderer, which may lead to a crash and, in principle, memory corruption, though the report only claims a potential issue and the steps were not executed.

What the attacker needed

Victim visits a malicious page; WebXR support in the browser; billions of callback registrations

The fix

The counter should skip reserved sentinel values (or use an unsigned 64-bit type) so an ID can never equal -1; the text does not say it was fixed.

How it was found

  1. Start an inline WebXR session from JavaScript.
  2. Repeatedly register and cancel animation frame callbacks in a loop.
  3. Spread the loop over many frames so pending callbacks are cleared and cancelled ones are collected, avoiding memory exhaustion.
  4. After the counter wraps, register a callback that receives the ID -1 and leave it uncancelled.
  5. Trigger garbage collection so the callback object is freed while still referenced.
  6. Render the next WebXR frame so the freed pointer is looked up and invoked.

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.

WebXR lets web pages draw 3D scenes in a headset or browser. The browser keeps a list of animation callbacks and gives each one a number; a special number, -1, is reserved to mean 'empty slot'. If the counter wraps round to -1, the browser thinks that slot is empty, stops protecting the callback from being cleaned up, and later uses memory that has already been freed, which can crash or be exploited.

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.