Use after free in WebGL (CVE-2026-5285)
A use-after-free in the GPU command buffer's ReadbackBufferShadowTracker is triggered when a WebGL2 page calls getBufferSubData with a non-zero offset on a STREAM_READ buffer, causing the wrong block in the FencedAllocator to be freed. An attacker could reclaim the freed region to read or corrupt another buffer's data, and by draining the chunk and forcing a visibility change could crash the renderer through a dangling pointer.
c6eed09fc8b174b0f3eebedcceb1e792 Follow
Originally disclosed on Chrome VRP
- Fix shipped in 19 days
Use-After-Free in ReadbackBufferShadowTracker via getBufferSubData with Non-Zero Offset
Summary
A use-after-free exists in the GPU command buffer client's ReadbackBufferShadowTracker on all desktop platforms. When a WebGL2 application calls getBufferSubData with a non-zero srcByteOffset on a STREAM_READ buffer, the internal UnmapBuffer path frees the wrong block in the FencedAllocator, releasing an adjacent buffer's shadow memory while it is still live. An attacker can reclaim the freed region to read or corrupt another buffer's data. By further manipulating the mapped memory lifecycle so the entire backing chunk is destroyed, the dangling shadow pointer dereferences unmapped memory, crashing the renderer. This is exploitable from any WebGL2-capable page with no special permissions.
Bisect
Introducing Commit: 2ca03f3fc6fde691b46cba5744b31dff33c7725c
- Date: 2018-06-12
- Author: Kai Ninomiya ([email protected])
- Review: https://chromium-review.googlesource.com/c/chromium/src/+/1043024
Root Cause
The ReadbackBufferShadowTracker maintains shadow copies of STREAM_READ, DYNAMIC_READ, and STATIC_READ buffers in shared memory, enabling getBufferSubData to return data without a GPU round-trip. When MapBufferRange is called on such a buffer, it calls MapReadbackShm(offset, size), which returns a subspan of the full allocation:
// readback_buffer_shadow_tracker.cc:47-66
base::span<uint8_t> ReadbackBufferShadowTracker::Buffer::MapReadbackShm(
uint32_t offset,
uint32_t map_size) {
// ...
is_mapped_ = true;
return readback_buffer_.subspan(offset, map_size);
}
This subspan is stored in mapped_buffer_range_map_ keyed by buffer ID. When offset > 0, the span's data() pointer points into the middle of the allocation, not at its base.
The corresponding UnmapBuffer correctly frees the allocation at its base address through UnmapReadbackShm, which internally calls Free():
// readback_buffer_shadow_tracker.cc:39-45, 68-74
void ReadbackBufferShadowTracker::Buffer::Free() {
if (!readback_buffer_.empty()) {
mapped_memory_->FreePendingToken(readback_buffer_.data(),
helper_->InsertToken());
}
readback_buffer_ = {};
}
bool ReadbackBufferShadowTracker::Buffer::UnmapReadbackShm() {
Free();
bool was_mapped = is_mapped_;
is_mapped_ = false;
return was_mapped;
}
However, after UnmapReadbackShm returns, UnmapBuffer unconditionally calls RemoveMappedBufferRangeById, which frees the subspan pointer a second time:
// gles2_implementation.cc:5608-5617
bool was_mapped_by_readback_tracker = false;
if (auto* buffer_object =
readback_buffer_shadow_tracker_->GetBuffer(buffer)) {
was_mapped_by_readback_tracker = buffer_object->UnmapReadbackShm();
}
if (!was_mapped_by_readback_tracker) {
helper_->UnmapBuffer(target);
InvalidateReadbackBufferShadowDataCHROMIUM(GetBoundBufferHelper(target));
}
RemoveMappedBufferRangeById(buffer); // unconditional second free
RemoveMappedBufferRangeById passes the subspan's data() pointer to FreePendingToken:
// gles2_implementation.cc:5442-5452
void GLES2Implementation::RemoveMappedBufferRangeById(GLuint buffer) {
if (buffer > 0) {
auto iter = mapped_buffer_range_map_.find(buffer);
if (iter != mapped_buffer_range_map_.end() &&
!iter->second.shm_memory.empty()) {
mapped_memory_->FreePendingToken(iter->second.shm_memory.data(),
helper_->InsertToken());
mapped_buffer_range_map_.erase(iter);
}
}
}
When srcByteOffset > 0, the subspan pointer does not correspond to the base of any allocation in the FencedAllocator. The allocator's GetBlockByOffset uses lower_bound binary search to resolve the offset to a block index, and the only guard against a mismatch is DCHECK_EQ(block.offset, offset), which is stripped in release builds:
// fenced_allocator.cc:101-110
void FencedAllocator::FreePendingToken(FencedAllocator::Offset offset,
int32_t token) {
BlockIndex index = GetBlockByOffset(offset);
Block &block = blocks_[index];
DCHECK_EQ(block.offset, offset); // stripped in release
if (block.state == IN_USE)
bytes_in_use_ -= block.size;
block.state = FREE_PENDING_TOKEN;
block.token = token;
}
The lower_bound search resolves to the next block after the intended allocation, since the subspan offset falls between two block boundaries. This erroneously marks the adjacent block as FREE_PENDING_TOKEN, freeing memory that belongs to a different, still-live buffer.
Once the adjacent block is freed, an attacker can allocate new buffers that reuse the same memory region, creating an overlapping allocation where two logical buffers share the same physical backing. Reading from the original (dangling) buffer returns the new buffer's contents, demonstrating information disclosure. Writing to one buffer corrupts the other.
Reproduce
Notes on the PoC Structure and Flags
The vulnerability itself is triggerable from any WebGL2 page without any special flags or user interaction; in a normal release build, the same bug produces exploitable heap corruption silently. All flags in the launch command, including --disable-popup-blocking, exist only for reproducing the ASAN crash log. Specifically, --disable-popup-blocking is required because Phase 2 of the PoC uses window.open to force a tab switch, triggering the page visibility transition that unmaps the shared memory chunk and produces the ASAN-detectable access-violation.
The PoC has two phases because the FencedAllocator is a sub-allocator within a single shared memory mapping, and its internal block-level mis-free is invisible to ASAN. Phase 1 proves the vulnerability is real by demonstrating overlapping allocation: after the mis-free, a newly allocated buffer E reuses the erroneously freed block, and reading through the original buffer C returns E's data (0xEE). The overlapping allocation from Phase 1 is already sufficient for exploitation, as an attacker can spray controlled data into the reclaimed region to corrupt adjacent buffer contents or hijack pointer-containing structures. Phase 2 exists purely to provide a minimal, deterministic ASAN crash as proof: it drains all other allocations from the chunk so bytes_in_use reaches zero, then triggers a page visibility transition that causes MappedMemoryManager to destroy the entire chunk via UnmapViewOfFile. The dangling readback_buffer_ span now points into unmapped virtual address space, and getBufferSubData crashes in memcpy.
Steps
Tested on commit 4e910e2277470c4576177b37937569fa4151abdc, Windows 11. No source patches are required.
Build out/asan-release with args.gn:
is_debug = false
dcheck_always_on = false
is_asan = true
is_component_build = false
Build and launch:
autoninja -C out/asan-release chrome
python3 -m http.server 8080 -d issue_blink_mod_010
out\asan-release\chrome.exe --disable-gpu-sandbox --no-sandbox --disable-popup-blocking --enable-logging=stderr http://localhost:8080/poc.html
ASAN log:
==13076==ERROR: AddressSanitizer: access-violation on unknown address 0x132df6bb0c80 (pc 0x7ff92936dc7d bp 0x00ae447fcb30 sp 0x00ae447fcaa8 T0)
==13076==The signal is caused by a READ memory access.
#0 0x7ff92936dc7c in memcpy+0x17c (C:\WINDOWS\System32\ucrtbase.dll+0x1800edc7c)
#1 0x7ff8d343b532 in _asan_memcpy+0x422 (D:\chromium\src\out\asan-release\clang_rt.asan_dynamic-x86_64.dll+0x18004b532)
#2 0x7ff8556ac923 in blink::WebGL2RenderingContextBase::getBufferSubData D:\chromium\src\third_party\blink\renderer\modules\webgl\webgl2_rendering_context_base.cc:456
#3 0x7ff8556fe4cb in blink::`anonymous namespace'::v8_webgl2_rendering_context::GetBufferSubDataOperationCallback D:\chromium\src\out\asan-release\gen\third_party\blink\renderer\bindings\modules\v8\v8_webgl2_rendering_context.cc:4154
#4 0x7ff85a7647e4 in Builtins_CallApiCallbackGeneric+0xa4 (D:\chromium\src\out\asan-release\chrome.dll+0x1ada747e4)
#5 0x7ff85a76293b in Builtins_InterpreterEntryTrampoline+0x13b (D:\chromium\src\out\asan-release\chrome.dll+0x1ada7293b)
#6 0x7ff85a75f6db in Builtins_JSEntryTrampoline+0x5b (D:\chromium\src\out\asan-release\chrome.dll+0x1ada6f6db)
#7 0x7ff85a75f23e in Builtins_JSEntry+0xfe (D:\chromium\src\out\asan-release\chrome.dll+0x1ada6f23e)
#8 0x7ff8322b2222 in v8::internal::`anonymous namespace'::Invoke D:\chromium\src\v8\src\execution\execution.cc:474
#9 0x7ff8322b0493 in v8::internal::Execution::Call D:\chromium\src\v8\src\execution\execution.cc:564
#10 0x7ff831db389c in v8::Function::Call D:\chromium\src\v8\src\api\api.cc:5584
#11 0x7ff848d77fdd in blink::V8ScriptRunner::CallFunction D:\chromium\src\third_party\blink\renderer\bindings\core\v8\v8_script_runner.cc:851
#12 0x7ff853c92406 in blink::bindings::CallbackInvokeHelper<blink::CallbackInterfaceBase,0,0>::Call D:\chromium\src\third_party\blink\renderer\bindings\core\v8\callback_invoke_helper.cc:148
#13 0x7ff8538248df in blink::V8EventListener::InvokeWithoutRunnabilityCheck D:\chromium\src\out\asan-release\gen\third_party\blink\renderer\bindings\core\v8\v8_event_listener.cc:119
#14 0x7ff84e982abb in blink::JSEventListener::InvokeInternal D:\chromium\src\third_party\blink\renderer\bindings\core\v8\js_event_listener.cc:58
#15 0x7ff84e954feb in blink::JSBasedEventListener::Invoke D:\chromium\src\third_party\blink\renderer\bindings\core\v8\js_based_event_listener.cc:193
#16 0x7ff848ee8c56 in blink::EventTarget::FireEventListeners D:\chromium\src\third_party\blink\renderer\core\dom\events\event_target.cc:1081
#17 0x7ff848ee6a02 in blink::EventTarget::FireEventListeners D:\chromium\src\third_party\blink\renderer\core\dom\events\event_target.cc:982
#18 0x7ff84e80209f in blink::EventDispatcher::DispatchEventAtBubbling D:\chromium\src\third_party\blink\renderer\core\dom\events\event_dispatcher.cc:368
#19 0x7ff84e800a0e in blink::EventDispatcher::Dispatch D:\chromium\src\third_party\blink\renderer\core\dom\events\event_dispatcher.cc:278
#20 0x7ff84e7fef51 in blink::EventDispatcher::DispatchEvent D:\chromium\src\third_party\blink\renderer\core\dom\events\event_dispatcher.cc:79
#21 0x7ff848a48f5a in blink::Document::DidChangeVisibilityState D:\chromium\src\third_party\blink\renderer\core\dom\document.cc:2275
#22 0x7ff8489bab61 in blink::LocalFrame::DidChangeVisibilityState D:\chromium\src\third_party\blink\renderer\core\frame\local_frame.cc:1175
#23 0x7ff848c68d56 in blink::Page::SetVisibilityState D:\chromium\src\third_party\blink\renderer\core\page\page.cc:854
#24 0x7ff8488e5e41 in blink::WebViewImpl::SetVisibilityState D:\chromium\src\third_party\blink\renderer\core\exported\web_view_impl.cc:4189
#25 0x7ff848902757 in blink::WebViewImpl::SetPageLifecycleStateInternal D:\chromium\src\third_party\blink\renderer\core\exported\web_view_impl.cc:2551
#26 0x7ff848903fd4 in blink::WebViewImpl::SetPageLifecycleState D:\chromium\src\third_party\blink\renderer\core\exported\web_view_impl.cc:2473
#27 0x7ff83a218c88 in blink::mojom::blink::PageBroadcastStubDispatch::AcceptWithResponder D:\chromium\src\out\asan-release\gen\third_party\blink\public\mojom\page\page.mojom-blink.cc:1950
#28 0x7ff84891d390 in blink::mojom::blink::PageBroadcastStub<mojo::RawPtrImplRefTraits<blink::mojom::blink::PageBroadcast> >::AcceptWithResponder D:\chromium\src\out\asan-release\gen\third_party\blink\public\mojom\page\page.mojom-blink.h:248
#29 0x7ff8405deefd in mojo::InterfaceEndpointClient::HandleValidatedMessage D:\chromium\src\mojo\public\cpp\bindings\lib\interface_endpoint_client.cc:1036
#30 0x7ff845e8488d in mojo::MessageDispatcher::Accept D:\chromium\src\mojo\public\cpp\bindings\lib\message_dispatcher.cc:44
#31 0x7ff8405e563e in mojo::InterfaceEndpointClient::HandleIncomingMessage D:\chromium\src\mojo\public\cpp\bindings\lib\interface_endpoint_client.cc:747
#32 0x7ff846ee4166 in IPC::ChannelAssociatedGroupController::AcceptOnEndpointThread D:\chromium\src\ipc\ipc_mojo_bootstrap.cc:1199
#33 0x7ff846ee66a1 in base::internal::Invoker<...>::RunOnce D:\chromium\src\base\functional\bind_internal.h:982
#34 0x7ff8407c3d48 in base::TaskAnnotator::RunTaskImpl D:\chromium\src\base\task\common\task_annotator.cc:229
#35 0x7ff845f2c531 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl D:\chromium\src\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:475
#36 0x7ff845f2b393 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork D:\chromium\src\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:346
#37 0x7ff845f73c37 in base::MessagePumpDefault::Run D:\chromium\src\base\message_loop\message_pump_default.cc:42
#38 0x7ff845f2e27f in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run D:\chromium\src\base\task\sequence_manager\thread_controller_with_message_pump_impl.cc:650
#39 0x7ff840836dbc in base::RunLoop::Run D:\chromium\src\base\run_loop.cc:135
#40 0x7ff843e2043f in content::RendererMain D:\chromium\src\content\renderer\renderer_main.cc:332
#41 0x7ff83d18594f in content::RunOtherNamedProcessTypeMain D:\chromium\src\content\app\content_main_runner_impl.cc:762
#42 0x7ff83d1880bb in content::ContentMainRunnerImpl::Run D:\chromium\src\content\app\content_main_runner_impl.cc:1152
#43 0x7ff83d17beaf in content::RunContentProcess D:\chromium\src\content\app\content_main.cc:358
#44 0x7ff83d17c652 in content::ContentMain D:\chromium\src\content\app\content_main.cc:371
#45 0x7ff82ccf2b06 in ChromeMain D:\chromium\src\chrome\app\chrome_main.cc:191
#46 0x7ff710b04807 in MainDllLoader::Launch D:\chromium\src\chrome\app\main_dll_loader_win.cc:204
#47 0x7ff710b02074 in main D:\chromium\src\chrome\app\chrome_exe_main_win.cc:351
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: access-violation (C:\WINDOWS\System32\ucrtbase.dll+0x1800edc7c) in memcpy+0x17c
==13076==ABORTING
Credit
Please use c6eed09fc8b174b0f3eebedcceb1e792 as the credit for this vulnerability. Thank you.
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
UnmapBuffer calls RemoveMappedBufferRangeById unconditionally after UnmapReadbackShm has already freed the allocation, and because the stored subspan pointer is offset into the middle of the allocation, the allocator's lower_bound lookup frees the adjacent block instead; the only guard is a DCHECK stripped in release builds.
Impact
The overlapping allocation could let an attacker read or corrupt another buffer's contents, and the dangling pointer could crash the renderer; the text notes the bug is triggerable from any WebGL2 page without special flags, though the ASAN crash reproduction needs a tab switch.
What the attacker needed
WebGL2-capable browser; victim visits a malicious page; no special permissions
How it was found
- Build an ASAN release build of Chromium with the given args.gn settings.
- Serve the PoC page over a local HTTP server.
- Launch the browser with the listed flags and open the PoC page.
- Phase 1: after the mis-free, allocate a new buffer that reuses the freed block and read through the original buffer to see the new buffer's data.
- Phase 2: drain other allocations so bytes_in_use reaches zero, then force a tab switch via window.open to trigger a visibility change that unmaps the chunk.
- Observe the ASAN access-violation in memcpy during getBufferSubData.
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.
WebGL2 lets a web page draw 3D graphics and read data back from the graphics card. The browser keeps a copy of some buffers in ordinary memory so reads are fast, and a bookkeeping mistake frees the wrong piece of that memory while another buffer still uses it. A malicious page can then read or overwrite data it should not see, or crash the tab.
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.