Use after free in Bindings (CVE-2026-95353)
A use-after-free exists in V8's FastIterateArray helper because it caches raw pointers to array elements on the stack. When a Blink callback allocates on the cppgc heap, a synchronous garbage collection can move the array, leaving the cached pointers dangling and allowing a stale write and a fake-object read.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 3 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: A potential Use-After-Free vulnerability exists in FastIterateArray when handling PACKED or HOLEY elements. A Blink IDL sequence callback allocating on the cppgc heap can trigger a synchronous V8 mark-compact GC, leaving raw stack-resident Tagged pointers stale since conservative stack scanning is off by default. This leads to an in-cage stale write and fakeobj-shaped read.
Affected files:
src/api/api.cc
Estimated timestamp from git blame: 2023-09-14
1. Summary of the Issue (Meant for Human Triage)
A potential use-after-free (UAF) / stale pointer vulnerability exists in the FastIterateArray optimization helper in src/api/api.cc. When iterating over arrays with PACKED or HOLEY element kinds, the function caches a raw (non-handle) Tagged<FixedArray> stack local and dereferences elements into a raw Tagged<Object> stack local. While the documented contract of v8::Array::Iterate prohibits the embedder's callback from allocating V8 objects while iterating, this restriction is not enforced in release builds, and embedders often interpret this as allowing allocations on independent heaps like Blink's cppgc (Oilpan).
In Chromium, Blink's IDL sequence converter for DOMArrayBuffer (CreateIDLSequenceFromV8ArraySlow<DOMArrayBuffer>) acts as the callback. During iteration, it allocates new DOMArrayBuffer objects on the cppgc heap via MakeGarbageCollected, subsequently returning kContinue to resume iteration. This cppgc allocation can synchronously trigger a full V8 mark-compact GC with compaction/evacuation when incremental marking is active and the old-generation allocation limit is overshot. Because conservative stack scanning (CSS) is disabled by default (v8_enable_direct_handle = false), the raw stack-resident Tagged<> pointers are neither traced nor updated when the elements array is relocated during GC.
This results in severe in-cage memory corruption:
- Stale Write: During the same iteration, the callback writes a
CppHeapPointerhandle to the stale, evacuated address of theArrayBufferelement viav8::Object::Wrap. - Stale Read: In the subsequent iteration,
FastIterateArrayreads elements from the danglingFixedArraypointer, yielding arbitrary/garbage values treated strictly asTagged<Object>(a fakeobj-style type confusion / arbitrary read primitive).
This vulnerability is reachable from standard, unprivileged web content via several shipped WebCodecs APIs that accept a sequence<ArrayBuffer> dictionary member (e.g., EncodedVideoChunkInit.transfer).
2. Proof-of-Concept & Detailed Execution Flow
Note: Our tooling agent does not have the ability to run code, so the following are suggested, potential steps an attacker would follow to trigger the vulnerability based on static code analysis.
Phase 1: Setup and Preconditions
- Heap Grooming: The attacker grooms the V8 heap such that incremental major marking is currently active.
- Allocation Limit: The attacker ensures that the V8 heap allocation limit is currently overshot by a large margin (meaning
heap->AllocationLimitOvershotByLargeMargin()evaluates totrue). - Payload Construction: The attacker creates a large array containing fresh
ArrayBufferobjects via JavaScript:let abs = []; for(let k=0; k<50000; k++) abs.push(new ArrayBuffer(8));. Because they were just created in V8, they do not yet have BlinkDOMArrayBufferwrapper objects instantiated on thecppgcheap. - API Invocation: The attacker triggers a WebCodecs API that accepts a
sequence<ArrayBuffer>. For example:new EncodedVideoChunk({type: 'key', timestamp: 0, data: new Uint8Array(1), transfer: abs});.
Phase 2: V8 Invokes FastIterateArray
- Blink Bindings Resolution: The Blink bindings layer invokes
CreateIDLSequenceFromV8ArraySlow<DOMArrayBuffer>to convert the incoming JavaScript array into an IDL sequence (third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h:909). - V8 Fast Iteration Entry: Because
DOMArrayBufferimplementsScriptWrappable, the Blink bindings callv8::Array::Iterate(include/v8-container.h:79), attempting to execute a fast callback for each element in the array. - V8 delegates
v8::Array::Iteratetoi::FastIterateArray(src/api/api.cc:8199). FastIterateArraychecksCanUseFastIterationwhich evaluates to true for standard arrays.- Execution enters a
DisallowJavascriptExecutionscope (src/api/api.cc:8212). While this scope intercepts and fatals on V8 JS execution re-entry, it does not block V8 GC sweeps orcppgcmemory allocations. FastIterateArraydetermines the elements kind of the array (e.g.,PACKED_ELEMENTS).- The Vulnerable Cache: V8 extracts the backing store of the array into a raw C++ stack local variable, bypassing Handle protections entirely:
Tagged<FixedArray> elements = Cast<FixedArray>(array->elements());(src/api/api.cc:8221).
Phase 3: The Iteration Loop and Raw Pointer Exposure
- The
forloop begins iterating over the array length (src/api/api.cc:8222). - During the first iteration (
i=0), the element at index0is fetched into a second raw C++ stack local variable:Tagged<Object> element = elements->get(static_cast<int>(i));(src/api/api.cc:8223). - V8 constructs a temporary
IndirectHandle<Object>namedfake_handlethat points directly to the memory address of the localelementvariable on the C++ stack (src/api/api.cc:8226-8227). - V8 invokes the Blink-provided callback, passing the
fake_handlecontaining the raw, unprotected pointer (src/api/api.cc:8228).
Phase 4: Blink Allocates on the cppgc Heap
- The Blink callback maps to
NativeValueTraits<DOMArrayBuffer>::NativeValuewhich invokesToDOMArrayBuffer(third_party/blink/renderer/bindings/core/v8/native_value_traits_buffer_sources.cc:286). - Inside
ToDOMArrayBuffer, Blink notices that the current V8ArrayBufferdoes not possess a Blink wrapper. - Blink allocates a new
DOMArrayBufferobject to act as the wrapper usingDOMArrayBuffer::Create(contents). DOMArrayBuffer::CreateutilizesMakeGarbageCollected<DOMArrayBuffer>to allocate memory on thecppgc(Oilpan) heap (include/cppgc/allocation.h:325).
Phase 5: Synchronous Mark-Compact Garbage Collection is Triggered
- The
cppgcallocator callscppgc::ObjectAllocator::OutOfLineAllocateGCSafePoint(src/heap/cppgc/object-allocator.cc:152). - This notifies the stats collector via
StatsCollector::NotifySafePointForConservativeCollection(src/heap/cppgc/stats-collector.cc:60). - The stats collector invokes the
CppHeapobserver function:CppHeap::AllocatedObjectSizeIncreased(src/heap/cppgc-js/cpp-heap.cc:1056). CppHeapinvokesReportBufferedAllocationSizeIfPossible(src/heap/cppgc-js/cpp-heap.cc:1066).- Because
IsGCAllowed()evaluates to true and incremental marking is active, execution proceeds to check the allocation limits. - Due to the attacker's heap grooming (Step 2), the condition
heap->AllocationLimitOvershotByLargeMargin()evaluates to true (src/heap/cppgc-js/cpp-heap.cc:1098). - Synchronous GC Execution: V8 synchronously triggers a full atomic mark-compact GC by calling
heap->FinalizeIncrementalMarkingAtomically(i::GarbageCollectionReason::kExternalFinalize)(src/heap/cppgc-js/cpp-heap.cc:1099).
Phase 6: Array Backing Store Evacuation
- The mark-compact garbage collector begins execution.
- The V8 heap page containing the array's
FixedArraybacking store is selected as an evacuation candidate for compaction. - The
FixedArraycontaining the elements is relocated to a completely new address on a different heap page. - By default, V8 does not scan the C++ stack for raw pointers. Because
v8_enable_direct_handleisfalse(gni/v8.gni:200),ConservativeStackScanningModeForMajorGCreturnsStackScanMode::kNone(src/heap/heap.h:414). - Because there is no conservative stack scanning, the raw
Tagged<FixedArray> elementsandTagged<Object> elementstack variables in the frozenFastIterateArraystack frame are not updated to reflect the new object locations. They now contain stale, dangling addresses pointing to the evacuated (freed) page memory. - The garbage collection cycle completes, and execution returns to
ToDOMArrayBuffer.
Phase 7: Stale Write (Same Iteration)
- Blink links the newly allocated
array_bufferto the V8 object viaarray_buffer->AssociateWithWrapper(...). - The V8 object provided to
AssociateWithWrapperis backed by thefake_handle, which dereferences the un-updated, danglingelementstack local. - The execution path reaches
v8::Object::Wrap(src/api/api.cc:6237). Wrapattempts to link the wrapper by storing aCppHeapPointerinside the V8 object viaSetCppHeapWrappable.- This calls
WriteLazilyInitializedCppHeapPointerField(src/sandbox/cppheap-pointer-inl.h:56). - The Stale Write (In-Cage UAF): V8 performs an atomic 32-bit release store (
slot.Release_StoreHandle(new_handle)) to write theCppHeapPointerHandledirectly to the object field located at the dangling, evacuated pointer address. This constitutes an out-of-bounds, in-cage Write Use-After-Free. - The Blink callback completes and returns
v8::Array::CallbackResult::kContinueto V8 (third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h:962).
Phase 8: Stale Read & Fake Object Confusion (Subsequent Iteration)
FastIterateArrayresumes execution. Since the result iskContinue, theforloop continues (src/api/api.cc:8229).- The loop counter
iis incremented. - The Stale Read (In-Cage UAF):
FastIterateArrayattempts to fetch the next element in the array using the danglingelementspointer:Tagged<Object> element = elements->get(static_cast<int>(i));(src/api/api.cc:8223). - This reads garbage data (or attacker-groomed data placed during the GC evacuation) from the freed heap page.
- The garbage data is treated strictly as a valid
Tagged<Object>by V8. - A new
fake_handleis bound to this invalidTagged<Object>memory. - The Blink callback is invoked again with the garbage pointer (
src/api/api.cc:8228). - Fake Object / Type Confusion: The callback invokes
value->IsArrayBuffer(), which dereferences the map word of the fake object at the invalid pointer address, yielding a type confusion / controlled arbitrary read primitive.
Suggested Fix
Blink-side (route to Blink>Bindings): Exclude DOMArrayBuffer and DOMSharedArrayBuffer from the Array::Iterate fast-path at native_value_traits_impl.h:909. Their NativeValue lazy-creates an Oilpan wrapper, inherently violating V8's fast-iteration non-allocation constraints under memory pressure.
V8-side hardening: Handlify the elements and element variables in the PACKED and HOLEY branches of FastIterateArray at api.cc:8221 and api.cc:8241. The DOUBLE case at api.cc:8261 correctly uses DirectHandle<FixedDoubleArray> and is not vulnerable to this UAF.
3. Technical Verification Details (Automated Audit Logs - Reviewers may skip this section)
VERDICT: accept
RULE: Layer-1 write primitive whose reachability needs a contrived-but-plausible heap/feedback state.
LAYER: 1 CLASS: K6
Probabilities:
- 99% probability the vulnerability is real.
- 99% probability the details in the writeup are correct.
- 95% probability it could be exploited by an adversary (fakeobj-shaped read and Use-After-Free write).
Step-by-step Justification:
1. Determine the layer: The report specifies how a plain JavaScript WebCodecs API (`EncodedVideoChunk`) triggers the vulnerability via standard Blink bindings. The attacker does not require prior in-cage memory corruption. Thus, this is a Layer-1 finding.
2. Disqualifier checklist: No disqualifiers apply. The bug does not rely on DevTools, `d8`-only sinks, or non-shipping experimental flags. It is reachable on default flags (`v8_enable_direct_handle = false` disabling conservative stack scanning). The `DisallowJavascriptExecution` scope does not prevent the GC that triggers the bug.
3. Base severity: This is a Layer-1 memory corruption (Use-After-Free) resulting in a fakeobj-shaped read and an in-cage write. Under normal circumstances, an in-cage UAF write is rated `high`. However, as the report correctly identifies, reaching the GC trigger requires a very specific, contrived-but-plausible heap state (`Heap::AllocationLimitOvershotByLargeMargin()` being true during incremental marking, alongside a cppgc allocation threshold). Per the V8 severity determination guide, a "Layer-1 write primitive whose reachability needs a contrived-but-plausible heap/feedback/tier-up state that an attacker could realistically arrange but that significantly narrows applicability" caps the severity at `medium`.
4. Modifiers: The WebCodecs API is shipped and available on default flags. No experimental or developer flags are required. The bug applies to all architectures, including tier-1 (x64/arm64). Therefore, no modifiers reduce the severity. Final severity remains `medium`.
VERIFIED:
- `api.cc:8219-8233` (PACKED) and `:8239-8254` (HOLEY) use raw `Tagged<FixedArray>` and `Tagged<Object>` without Handle protections, unlike the DOUBLE branch.
- `DisallowJavascriptExecution` blocks JS via `execution.cc` but does not block V8 or cppgc GC.
- `cpp-heap.cc:1099` (`ReportBufferedAllocationSizeIfPossible`) triggers `FinalizeIncrementalMarkingAtomically`, causing a full GC with evacuation.
- `v8_enable_direct_handle = false` means conservative stack scanning is off by default, leaving raw stack pointers un-updated during GC.
NOT-VERIFIED:
- Blink's `third_party/blink/` binding implementations; accepted as reported.
DUPLICATE: DISTINCT from other `FastIterateArray` bugs (which involve Layer-2 length trusts).
Environmental Assumptions & Preconditions Verified by Tooling
- CSS Off By Default: Checked
v8_enable_direct_handleingni/v8.gni:200. It defaults tofalse. As a result,ConservativeStackScanningModeForMajorGCreturnsStackScanMode::kNone(src/heap/heap.h:406-415). - DisallowJavascriptExecution: Traced in
src/common/assert-scope.handsrc/execution/execution.cc. This is an Isolate-level assertion scope checked strictly duringExecution::Invoke. It does not intercept memory allocations or GC cycles. Indeed,DisallowJavascriptExecutionis actively used insideHeap::CollectGarbage(src/heap/heap.cc:1467), proving it permits GC. - cppgc Triggers V8 GC: The call tree from
MakeGarbageCollectedleads tocppgc::ObjectAllocator::OutOfLineAllocateGCSafePoint. This callsStatsCollector::NotifySafePointForConservativeCollection, which invokesCppHeap::AllocatedObjectSizeIncreased(src/heap/cppgc-js/cpp-heap.cc:1056). InsideReportBufferedAllocationSizeIfPossible, the path explicitly executesheap->FinalizeIncrementalMarkingAtomicallyif allocation limits are breached. - In-Cage Stale Write: Evaluated
v8::Object::Wrap. It delegates toCppHeapObjectWrapper::SetCppHeapWrappable, which invokesWriteLazilyInitializedCppHeapPointerField(src/sandbox/cppheap-pointer-inl.h:56). Under pointer compression, this safely allocates an externalCppHeapPointerTableentry, but performs an atomic 32-bit release store (slot.Release_StoreHandle) directly into the in-cage V8JSObjectmemory address. If the object was evacuated, the write occurs at the dangling address.
Evaluated with Chrome root at commit: 71e7e1a98476f8faf0d126dc83935a84331b2194
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.
Note: This bug has been automatically redirected to the top-level Chromium component. Please move it to the actual component: https://b.corp.google.com/components/1456124 once PoCs have been generated.
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, FastIterateArray stores raw Tagged pointers to the array's backing store and elements on the C++ stack, and because conservative stack scanning is disabled by default, these pointers are not updated when a synchronous garbage collection relocates the array during a callback that allocates on the cppgc heap.
Impact
An attacker could achieve an in-cage stale write and a fake-object-shaped read, potentially leading to memory corruption or information disclosure, though reaching the required heap state is contrived.
What the attacker needed
Ability to run JavaScript in the browser; heap grooming to trigger GC during iteration
The fix
The issue should be fixed by excluding DOMArrayBuffer and DOMSharedArrayBuffer from the fast iteration path in Blink and by using handles for the elements and element variables in FastIterateArray.
How it was found
- Groom the V8 heap so incremental major marking is active and the allocation limit is overshot.
- Create a large JavaScript array of ArrayBuffer objects.
- Call a WebCodecs API that accepts a sequence<ArrayBuffer>, such as EncodedVideoChunk with a transfer member.
- The Blink bindings invoke v8::Array::Iterate, which enters FastIterateArray and caches raw pointers to the array elements.
- The Blink callback allocates a DOMArrayBuffer on the cppgc heap, triggering a synchronous mark-compact garbage collection that moves the array.
- The stale pointers are used for a write in the same iteration and a read in the next, causing memory corruption.
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 JavaScript code passes an array of buffers to a browser API, the browser's engine iterates over the array using a fast path that keeps direct pointers to the array's internal storage on the call stack. If, during that iteration, the browser allocates memory in a way that triggers a garbage collection, the array can be moved to a new location. The old pointers are not updated, so the code later reads and writes through them, which can corrupt memory or leak data.
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.