Out of bounds read in GPU (CVE-2026-9895)
A range-for loop in the viz compositor iterates a flat_set while a callback synchronously erases an element from that same set, invalidating the captured end iterator. A compromised renderer can submit crafted compositor frames to make the GPU process read past the vector's logical end, causing a container-overflow crash.
86ac1f1587b71893ed2ad792cd7dde32 Follow
Originally disclosed on Chrome VRP
- Fix shipped in 3 months
Note
I reported this issue in the previous issue: https://issues.chromium.org/issues/489358139. Due to differences in my local environment, I made a small mistake that caused the PoC to fail to reproduce on ClusterFuzz, and the issue was closed. This issue will supplement the correct PoC.
Now I integrated the dependent MojoJS code into the HTML file to maintain its independence, and have successfully tested it on the official ASan-enabled Chromium builds for both Linux and macOS: https://commondatastorage.googleapis.com/chromium-browser-asan/index.html.
Summary
The SurfaceAllocationGroup::OnFirstSurfaceActivation function in the viz compositor service iterates over active_embedders_ using a C++ range-for loop while synchronously invoking callbacks on each embedder. These callbacks can trigger a reentrant call chain that ultimately calls UnregisterActiveEmbedder, which erases an element from the same base::flat_set being iterated. Because base::flat_set is backed by a sorted std::vector, the erase invalidates the captured iterators, causing the loop to read past the vector's logical size boundary. A compromised renderer can exploit this via SubmitCompositorFrame to attack the GPU process.
The vulnerable code resides in components/viz/service/surfaces/surface_allocation_group.cc, which is platform-independent and compiled on all Chromium desktop and mobile targets. This vulnerability affects all platforms where Chromium runs with the viz compositor service enabled, including Windows, Linux, macOS, ChromeOS, and Android. No specific GPU hardware is required to trigger the bug; the crash occurs on the VizCompositorThread in the GPU process during surface management logic that is independent of the graphics backend.
Bisect
Introducing Commit: a661cdf7498e "Add RegisterActiveEmbedder to SurfaceAllocationGroup"
- Date: 2019-03-11
- Author: Saman Sami [email protected]
- Review: https://chromium-review.googlesource.com/c/chromium/src/+/1506593
Root Cause
The vulnerability lies in SurfaceAllocationGroup::OnFirstSurfaceActivation, which uses a C++ range-for loop to iterate active_embedders_ and synchronously invoke OnChildActivatedForActiveFrame on each embedder surface. The active_embedders_ member is declared as a base::flat_set<raw_ptr<Surface, CtnExperimental>>, which is internally backed by a sorted std::vector.
// components/viz/service/surfaces/surface_allocation_group.h
base::flat_set<raw_ptr<Surface, CtnExperimental>> active_embedders_;
// components/viz/service/surfaces/surface_allocation_group.cc
void SurfaceAllocationGroup::OnFirstSurfaceActivation(Surface* surface) {
for (Surface* embedder : active_embedders_)
embedder->OnChildActivatedForActiveFrame(surface->surface_id());
// ...
}
The C++ range-for loop captures begin() and end() iterators at the start of iteration. Because base::flat_set is backed by a std::vector, any insertion or erasure invalidates these iterators.
The callback OnChildActivatedForActiveFrame can trigger a reentrant modification of active_embedders_ through the following call chain. When a surface activates for the first time, it calls OnFirstSurfaceActivation on its allocation group (GroupA). This function iterates GroupA's active_embedders_ and calls OnChildActivatedForActiveFrame on each embedder. The embedder then calls RecomputeActiveReferencedSurfaces, which evaluates all SurfaceRange entries in the embedder's active frame metadata.
// components/viz/service/surfaces/surface.cc
void Surface::OnChildActivatedForActiveFrame(const SurfaceId& activated_id) {
DCHECK(HasActiveFrame());
for (auto& surface_range : GetActiveFrame().metadata.referenced_surfaces) {
if (surface_range.IsInRangeInclusive(activated_id)) {
RecomputeActiveReferencedSurfaces();
return;
}
}
}
For a SurfaceRange with different embed tokens (a cross-group reference), RecomputeActiveReferencedSurfaces calls UpdateLastActiveReferenceAndMaybeActivate on the end allocation group (GroupB). This function can force-activate a pending surface via deadline inheritance.
// components/viz/service/surfaces/surface_allocation_group.cc
void SurfaceAllocationGroup::UpdateLastActiveReferenceAndMaybeActivate(
const SurfaceId& surface_id) {
// ...
auto it = FindLatestSurfaceUpTo(surface_id);
if (it != surfaces_.end() && !(*it)->HasActiveFrame())
(*it)->ActivatePendingFrameForInheritedDeadline();
// ...
}
When this pending surface in GroupB activates, it triggers GroupB's own OnFirstSurfaceActivation, which again calls OnChildActivatedForActiveFrame on the same embedder surface (E1). This recursive call to RecomputeActiveReferencedSurfaces re-evaluates E1's SurfaceRange. Now that GroupB has an active surface, GetLatestInFlightSurface resolves the range to GroupB's surface. Because the resolved surface's embed token no longer matches the start of the range, the start allocation group (GroupA) is dropped from the new referenced set.
// components/viz/service/surfaces/surface.cc
void Surface::RecomputeActiveReferencedSurfaces() {
// ...
for (const SurfaceRange& surface_range :
active_frame_data_->frame.metadata.referenced_surfaces) {
Surface* surface =
surface_manager_->GetLatestInFlightSurface(surface_range);
// ...
if (surface_range.HasDifferentEmbedTokens() &&
(!surface ||
surface->surface_id().HasSameEmbedTokenAs(*surface_range.start()))) {
// start allocation group is only referenced when resolved surface
// matches start's embed token
}
}
UpdateReferencedAllocationGroups(std::move(new_referenced_allocation_groups));
}
When UpdateReferencedAllocationGroups detects that GroupA is no longer in the new set, it calls GroupA->UnregisterActiveEmbedder(E1), which erases E1 from GroupA's active_embedders_.
// components/viz/service/surfaces/surface.cc
void Surface::UpdateReferencedAllocationGroups(
std::vector<SurfaceAllocationGroup*> new_referenced_allocation_groups) {
// ...
for (SurfaceAllocationGroup* group : referenced_allocation_groups_) {
if (!new_set.count(group))
group->UnregisterActiveEmbedder(this);
}
// ...
}
// components/viz/service/surfaces/surface_allocation_group.cc
void SurfaceAllocationGroup::UnregisterActiveEmbedder(Surface* surface) {
DCHECK(active_embedders_.count(surface));
active_embedders_.erase(surface);
MaybeMarkForDestruction();
}
This erase occurs while the outer OnFirstSurfaceActivation is still iterating over the same active_embedders_ container. The erase shifts all subsequent elements left in the underlying vector, invalidating the captured __end iterator and corrupting the iteration state. The loop skips the element that shifted into the erased position and eventually reads past the vector's logical end, producing a container-overflow.
With five active embedders (the root compositor plus four attacker-controlled surfaces E1 through E4), erasing E1 reduces the size from five to four. The stale __end iterator still points to index five, so after processing E3 and E4 (E2 is skipped due to the left-shift), the loop attempts to read index four of a size-four vector, triggering an out-of-bounds read.
A compromised renderer can construct this scenario because CompositorFrameMetadata::referenced_surfaces accepts arbitrary SurfaceRange values without any permission or ownership validation. The renderer controls multiple FrameSinks (obtained through OffscreenCanvas), can submit frames with cross-group SurfaceRange references, and can create pending surfaces with unresolvable activation dependencies to set up the precise timing required.
Reproduce
Run with the asan chromium using MojoJS:
# test on macOS
out/asan/Chromium.app/Contents/MacOS/Chromium --user-data-dir=./user --enable-blink-features=MojoJS,MojoJSTest --enable-logging=stderr poc_mojo_standalone.html
# test on Linux
out/asan/chrome --user-data-dir=./user --enable-blink-features=MojoJS,MojoJSTest --enable-logging=stderr poc_mojo_standalone.html
ASAN output
=================================================================
==35918==ERROR: AddressSanitizer: container-overflow on address 0x60600035cb60 at pc 0x00031b9e3ee8 bp 0x0001741d8850 sp 0x0001741d8848
READ of size 8 at 0x60600035cb60 thread T13
==35918==WARNING: invalid path to external symbolizer!
==35918==WARNING: Failed to use and restart external symbolizer!
#0 0x00031b9e3ee4 in viz::SurfaceAllocationGroup::OnFirstSurfaceActivation(viz::Surface*)+0x468 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9e3ee4)
#1 0x00031b9cbe98 in viz::Surface::ActivateFrame(viz::Surface::FrameData)+0x840 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9cbe98)
#2 0x00031b9ca254 in viz::Surface::CommitFrame(viz::Surface::FrameData)+0xd94 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9ca254)
#3 0x00031b9c9140 in viz::Surface::QueueFrame(viz::CompositorFrame, unsigned int, base::ScopedClosureRunner)+0x714 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9c9140)
#4 0x00031b771924 in viz::CompositorFrameSinkSupport::MaybeSubmitCompositorFrame(viz::LocalSurfaceId const&, viz::CompositorFrame, std::__Cr::optional<viz::HitTestRegionList>, unsigned long long)+0x1e44 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b771924)
#5 0x00031b788958 in viz::CompositorFrameSinkImpl::SubmitCompositorFrame(viz::LocalSurfaceId const&, viz::CompositorFrame, std::__Cr::optional<viz::HitTestRegionList>, unsigned long long)+0x19c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b788958)
#6 0x00030371e328 in viz::mojom::CompositorFrameSinkStubDispatch::Accept(viz::mojom::CompositorFrameSink*, mojo::Message*)+0x3cc (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x371e328)
#7 0x000312130064 in mojo::InterfaceEndpointClient::HandleValidatedMessage(mojo::Message*)+0x8fc (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12130064)
#8 0x000312144edc in mojo::MessageDispatcher::Accept(mojo::Message*)+0x2f0 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12144edc)
#9 0x000312135264 in mojo::InterfaceEndpointClient::HandleIncomingMessage(mojo::Message*)+0x148 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12135264)
#10 0x000312151cb8 in mojo::internal::MultiplexRouter::ProcessIncomingMessage(mojo::internal::MultiplexRouter::MessageWrapper*, mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*)+0x650 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12151cb8)
#11 0x000312150768 in mojo::internal::MultiplexRouter::Accept(mojo::Message*)+0x558 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12150768)
#12 0x000312144edc in mojo::MessageDispatcher::Accept(mojo::Message*)+0x2f0 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12144edc)
#13 0x000312123228 in mojo::Connector::DispatchMessage(mojo::ScopedHandleBase<mojo::MessageHandle>)+0x394 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12123228)
#14 0x0003121246f8 in mojo::Connector::ReadAllAvailableMessages()+0x23c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x121246f8)
#15 0x0003121241f8 in mojo::Connector::OnWatcherHandleReady(char const*, unsigned int)+0xe8 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x121241f8)
#16 0x000312125ce0 in base::internal::Invoker<base::internal::FunctorTraits<void (mojo::Connector::* const&)(char const*, unsigned int), mojo::Connector*, char const* const&>, base::internal::BindState<true, true, false, void (mojo::Connector::*)(char const*, unsigned int), base::internal::UnretainedWrapper<mojo::Connector, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>, base::internal::UnretainedWrapper<char const, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>>, void (unsigned int)>::Run(base::internal::BindStateBase*, unsigned int)+0x1b8 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12125ce0)
#17 0x0003039b4b50 in base::RepeatingCallback<void (unsigned int)>::Run(unsigned int) const &+0x148 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x39b4b50)
#18 0x0003039b492c in base::internal::Invoker<base::internal::FunctorTraits<void (* const&)(base::RepeatingCallback<void (unsigned int)> const&, unsigned int, mojo::HandleSignalsState const&), base::RepeatingCallback<void (unsigned int)> const&>, base::internal::BindState<false, true, false, void (*)(base::RepeatingCallback<void (unsigned int)> const&, unsigned int, mojo::HandleSignalsState const&), base::RepeatingCallback<void (unsigned int)>>, void (unsigned int, mojo::HandleSignalsState const&)>::Run(base::internal::BindStateBase*, unsigned int, mojo::HandleSignalsState const&)+0xf0 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x39b492c)
#19 0x000312903370 in base::RepeatingCallback<void (unsigned int, mojo::HandleSignalsState const&)>::Run(unsigned int, mojo::HandleSignalsState const&) const &+0x154 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12903370)
#20 0x000312902d8c in mojo::SimpleWatcher::OnHandleReady(int, unsigned int, mojo::HandleSignalsState const&)+0x398 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12902d8c)
#21 0x000312903ccc in base::internal::Invoker<base::internal::FunctorTraits<void (mojo::SimpleWatcher::*&&)(int, unsigned int, mojo::HandleSignalsState const&), base::WeakPtr<mojo::SimpleWatcher>&&, int&&, unsigned int&&, mojo::HandleSignalsState&&>, base::internal::BindState<true, true, false, void (mojo::SimpleWatcher::*)(int, unsigned int, mojo::HandleSignalsState const&), base::WeakPtr<mojo::SimpleWatcher>, int, unsigned int, mojo::HandleSignalsState>, void ()>::RunOnce(base::internal::BindStateBase*)+0x184 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12903ccc)
#22 0x000312322bb0 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&)+0x348 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12322bb0)
#23 0x00031238b0e4 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::LazyNow*)+0x88c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1238b0e4)
#24 0x00031238a430 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork()+0x138 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1238a430)
#25 0x0003124abb74 in base::MessagePumpCFRunLoopBase::RunWork()+0x1c8 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x124abb74)
#26 0x00031249d2a8 in base::apple::CallWithEHFrame(void () block_pointer)+0xc (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1249d2a8)
#27 0x0003124a9fac in base::MessagePumpCFRunLoopBase::RunWorkSource(void*)+0xec (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x124a9fac)
#28 0x00019b3549f4 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__+0x18 (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation:arm64e+0x5f9f4)
#29 0x00019b354988 in __CFRunLoopDoSource0+0xa8 (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation:arm64e+0x5f988)
#30 0x00019b3546f4 in __CFRunLoopDoSources0+0xe4 (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation:arm64e+0x5f6f4)
#31 0x00019b353384 in __CFRunLoopRun+0x330 (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation:arm64e+0x5e384)
#32 0x00019b40de30 in _CFRunLoopRunSpecificWithOptions+0x210 (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation:arm64e+0x118e30)
#33 0x00019d5a2960 in -[NSRunLoop(NSRunLoop) runMode:beforeDate:]+0xd0 (/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation:arm64e+0xa5b960)
#34 0x0003124accc4 in base::MessagePumpNSRunLoop::DoRun(base::MessagePump::Delegate*)+0xc8 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x124accc4)
#35 0x0003124a8d04 in base::MessagePumpCFRunLoopBase::Run(base::MessagePump::Delegate*)+0x290 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x124a8d04)
#36 0x00031238c444 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta)+0x32c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1238c444)
#37 0x0003122b1290 in base::RunLoop::Run(base::Location const&)+0x430 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x122b1290)
#38 0x000312401a24 in base::Thread::Run(base::RunLoop*)+0xd8 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12401a24)
#39 0x000312401eac in base::Thread::ThreadMain()+0x3d8 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12401eac)
#40 0x000312458b18 in base::(anonymous namespace)::ThreadFunc(void*)+0x154 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12458b18)
#41 0x000101221878 in __sanitizer_weak_hook_memcmp+0x3674c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Helpers/Chromium Helper.app/Contents/MacOS/libclang_rt.asan_osx_dynamic.dylib:arm64+0x51878)
#42 0x00019b2b5c04 in _pthread_start+0x84 (/usr/lib/system/libsystem_pthread.dylib:arm64e+0x6c04)
#43 0x00019b2b0ba4 in thread_start+0x4 (/usr/lib/system/libsystem_pthread.dylib:arm64e+0x1ba4)
0x60600035cb60 is located 32 bytes inside of 64-byte region [0x60600035cb40,0x60600035cb80)
allocated by thread T13 here:
#0 0x000101224fc0 in __asan_memmove+0x2fd0 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Helpers/Chromium Helper.app/Contents/MacOS/libclang_rt.asan_osx_dynamic.dylib:arm64+0x54fc0)
#1 0x0003288abff0 in operator new(unsigned long)+0x18 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x288abff0)
#2 0x00031b784488 in std::__Cr::__wrap_iter<base::raw_ptr<viz::Surface, (partition_alloc::internal::RawPtrTraits)1>*> std::__Cr::vector<base::raw_ptr<viz::Surface, (partition_alloc::internal::RawPtrTraits)1>, std::__Cr::allocator<base::raw_ptr<viz::Surface, (partition_alloc::internal::RawPtrTraits)1>>>::emplace<base::raw_ptr<viz::Surface, (partition_alloc::internal::RawPtrTraits)1>>(std::__Cr::__wrap_iter<base::raw_ptr<viz::Surface, (partition_alloc::internal::RawPtrTraits)1> const*>, base::raw_ptr<viz::Surface, (partition_alloc::internal::RawPtrTraits)1>&&)+0x160 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b784488)
#3 0x00031b78427c in std::__Cr::pair<std::__Cr::__wrap_iter<base::raw_ptr<viz::Surface, (partition_alloc::internal::RawPtrTraits)1>*>, bool> base::internal::flat_tree<base::raw_ptr<viz::Surface, (partition_alloc::internal::RawPtrTraits)1>, std::__Cr::identity, std::__Cr::less<void>, std::__Cr::vector<base::raw_ptr<viz::Surface, (partition_alloc::internal::RawPtrTraits)1>, std::__Cr::allocator<base::raw_ptr<viz::Surface, (partition_alloc::internal::RawPtrTraits)1>>>>::emplace_key_args<base::raw_ptr<viz::Surface, (partition_alloc::internal::RawPtrTraits)1>, base::raw_ptr<viz::Surface, (partition_alloc::internal::RawPtrTraits)1>>(base::raw_ptr<viz::Surface, (partition_alloc::internal::RawPtrTraits)1> const&, base::raw_ptr<viz::Surface, (partition_alloc::internal::RawPtrTraits)1>&&)+0x184 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b78427c)
#4 0x00031b9e29dc in viz::SurfaceAllocationGroup::RegisterActiveEmbedder(viz::Surface*)+0x54 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9e29dc)
#5 0x00031b9ce734 in viz::Surface::UpdateReferencedAllocationGroups(std::__Cr::vector<viz::SurfaceAllocationGroup*, std::__Cr::allocator<viz::SurfaceAllocationGroup*>>)+0x26c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9ce734)
#6 0x00031b9c8060 in viz::Surface::RecomputeActiveReferencedSurfaces()+0x58c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9c8060)
#7 0x00031b9cbc98 in viz::Surface::ActivateFrame(viz::Surface::FrameData)+0x640 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9cbc98)
#8 0x00031b9ca254 in viz::Surface::CommitFrame(viz::Surface::FrameData)+0xd94 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9ca254)
#9 0x00031b9c9140 in viz::Surface::QueueFrame(viz::CompositorFrame, unsigned int, base::ScopedClosureRunner)+0x714 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9c9140)
#10 0x00031b771924 in viz::CompositorFrameSinkSupport::MaybeSubmitCompositorFrame(viz::LocalSurfaceId const&, viz::CompositorFrame, std::__Cr::optional<viz::HitTestRegionList>, unsigned long long)+0x1e44 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b771924)
#11 0x00031b788958 in viz::CompositorFrameSinkImpl::SubmitCompositorFrame(viz::LocalSurfaceId const&, viz::CompositorFrame, std::__Cr::optional<viz::HitTestRegionList>, unsigned long long)+0x19c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b788958)
#12 0x00030371e328 in viz::mojom::CompositorFrameSinkStubDispatch::Accept(viz::mojom::CompositorFrameSink*, mojo::Message*)+0x3cc (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x371e328)
#13 0x000312130064 in mojo::InterfaceEndpointClient::HandleValidatedMessage(mojo::Message*)+0x8fc (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12130064)
#14 0x000312144edc in mojo::MessageDispatcher::Accept(mojo::Message*)+0x2f0 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12144edc)
#15 0x000312135264 in mojo::InterfaceEndpointClient::HandleIncomingMessage(mojo::Message*)+0x148 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12135264)
#16 0x000312151cb8 in mojo::internal::MultiplexRouter::ProcessIncomingMessage(mojo::internal::MultiplexRouter::MessageWrapper*, mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*)+0x650 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12151cb8)
#17 0x000312150768 in mojo::internal::MultiplexRouter::Accept(mojo::Message*)+0x558 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12150768)
#18 0x000312144edc in mojo::MessageDispatcher::Accept(mojo::Message*)+0x2f0 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12144edc)
#19 0x000312123228 in mojo::Connector::DispatchMessage(mojo::ScopedHandleBase<mojo::MessageHandle>)+0x394 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12123228)
#20 0x0003121246f8 in mojo::Connector::ReadAllAvailableMessages()+0x23c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x121246f8)
#21 0x0003121241f8 in mojo::Connector::OnWatcherHandleReady(char const*, unsigned int)+0xe8 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x121241f8)
#22 0x000312125ce0 in base::internal::Invoker<base::internal::FunctorTraits<void (mojo::Connector::* const&)(char const*, unsigned int), mojo::Connector*, char const* const&>, base::internal::BindState<true, true, false, void (mojo::Connector::*)(char const*, unsigned int), base::internal::UnretainedWrapper<mojo::Connector, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>, base::internal::UnretainedWrapper<char const, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>>, void (unsigned int)>::Run(base::internal::BindStateBase*, unsigned int)+0x1b8 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12125ce0)
#23 0x0003039b4b50 in base::RepeatingCallback<void (unsigned int)>::Run(unsigned int) const &+0x148 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x39b4b50)
#24 0x0003039b492c in base::internal::Invoker<base::internal::FunctorTraits<void (* const&)(base::RepeatingCallback<void (unsigned int)> const&, unsigned int, mojo::HandleSignalsState const&), base::RepeatingCallback<void (unsigned int)> const&>, base::internal::BindState<false, true, false, void (*)(base::RepeatingCallback<void (unsigned int)> const&, unsigned int, mojo::HandleSignalsState const&), base::RepeatingCallback<void (unsigned int)>>, void (unsigned int, mojo::HandleSignalsState const&)>::Run(base::internal::BindStateBase*, unsigned int, mojo::HandleSignalsState const&)+0xf0 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x39b492c)
#25 0x000312903370 in base::RepeatingCallback<void (unsigned int, mojo::HandleSignalsState const&)>::Run(unsigned int, mojo::HandleSignalsState const&) const &+0x154 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12903370)
#26 0x000312902d8c in mojo::SimpleWatcher::OnHandleReady(int, unsigned int, mojo::HandleSignalsState const&)+0x398 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12902d8c)
#27 0x000312903ccc in base::internal::Invoker<base::internal::FunctorTraits<void (mojo::SimpleWatcher::*&&)(int, unsigned int, mojo::HandleSignalsState const&), base::WeakPtr<mojo::SimpleWatcher>&&, int&&, unsigned int&&, mojo::HandleSignalsState&&>, base::internal::BindState<true, true, false, void (mojo::SimpleWatcher::*)(int, unsigned int, mojo::HandleSignalsState const&), base::WeakPtr<mojo::SimpleWatcher>, int, unsigned int, mojo::HandleSignalsState>, void ()>::RunOnce(base::internal::BindStateBase*)+0x184 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12903ccc)
#28 0x000312322bb0 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&)+0x348 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12322bb0)
#29 0x00031238b0e4 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::LazyNow*)+0x88c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1238b0e4)
Thread T13 created by T0 here:
#0 0x00010121b968 in __sanitizer_weak_hook_memcmp+0x3083c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Helpers/Chromium Helper.app/Contents/MacOS/libclang_rt.asan_osx_dynamic.dylib:arm64+0x4b968)
#1 0x0003124580dc in base::(anonymous namespace)::CreateThread(unsigned long, bool, base::PlatformThreadBase::Delegate*, base::PlatformThreadHandle*, base::ThreadType, base::MessagePumpType)+0x270 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x124580dc)
#2 0x000312400d5c in base::Thread::StartWithOptions(base::Thread::Options)+0x498 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12400d5c)
#3 0x00030ba32390 in viz::VizCompositorThreadRunnerImpl::VizCompositorThreadRunnerImpl()+0x228 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0xba32390)
#4 0x00030ba37abc in viz::VizMainImpl::VizMainImpl(viz::VizMainImpl::Delegate*, viz::VizMainImpl::ExternalDependencies, std::__Cr::unique_ptr<gpu::GpuInit, std::__Cr::default_delete<gpu::GpuInit>>)+0x7c8 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0xba37abc)
#5 0x00031b666c1c in content::GpuChildThread::GpuChildThread(base::RepeatingCallback<void ()>, content::ChildThreadImpl::Options, std::__Cr::unique_ptr<gpu::GpuInit, std::__Cr::default_delete<gpu::GpuInit>>)+0x1c0 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b666c1c)
#6 0x00031b6669a0 in content::GpuChildThread::GpuChildThread(base::RepeatingCallback<void ()>, std::__Cr::unique_ptr<gpu::GpuInit, std::__Cr::default_delete<gpu::GpuInit>>)+0x184 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b6669a0)
#7 0x00031b669bec in content::GpuMain(content::MainFunctionParams)+0x788 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b669bec)
#8 0x00030ea3a5f0 in content::RunOtherNamedProcessTypeMain(std::__Cr::basic_string<char, std::__Cr::char_traits<char>, std::__Cr::allocator<char>> const&, content::MainFunctionParams, content::ContentMainDelegate*)+0x420 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0xea3a5f0)
#9 0x00030ea3c770 in content::ContentMainRunnerImpl::Run()+0x53c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0xea3c770)
#10 0x00030ea382e0 in content::RunContentProcess(content::ContentMainParams, content::ContentMainRunner*)+0x858 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0xea382e0)
#11 0x00030ea387d0 in content::ContentMain(content::ContentMainParams)+0x190 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0xea387d0)
#12 0x000300005cb4 in ChromeMain+0x490 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x5cb4)
#13 0x000100d88ce4 in main+0x254 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Helpers/Chromium Helper.app/Contents/MacOS/Chromium Helper:arm64+0x100000ce4)
#14 0x00019aeedd50 in start+0x1c0c (/usr/lib/dyld:arm64e+0x8d50)
HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_container_overflow=0.
Or if supported by the container library, pass -D__SANITIZER_DISABLE_CONTAINER_OVERFLOW__ to the compiler to disable instrumentation.
If you suspect a false positive see also: https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow.
SUMMARY: AddressSanitizer: container-overflow (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9e3ee4) in viz::SurfaceAllocationGroup::OnFirstSurfaceActivation(viz::Surface*)+0x468
Shadow bytes around the buggy address:
0x60600035c880: fa fa f7 fa fd fd fd fd fd fd fd fa fa fa f7 fa
0x60600035c900: fd fd fd fd fd fd fd fa fa fa f7 fa fd fd fd fd
0x60600035c980: fd fd fd fa fa fa f7 fa fd fd fd fd fd fd fd fd
0x60600035ca00: fa fa f7 fa 00 00 00 00 00 00 00 00 fa fa f7 fa
0x60600035ca80: 00 00 00 00 00 00 00 00 fa fa f7 fa 00 00 00 00
=>0x60600035cb00: 00 00 00 00 fa fa f7 fa 00 00 00 00[fc]fc fc fc
0x60600035cb80: fa fa f7 fa fd fd fd fd fd fd fd fd fa fa f7 fa
0x60600035cc00: 00 00 00 00 00 00 00 00 fa fa f7 fa 00 00 00 00
0x60600035cc80: 00 00 00 00 fa fa f7 fa 00 00 00 00 00 00 00 00
0x60600035cd00: fa fa f7 fa 00 00 00 00 00 00 00 00 fa fa f7 fa
0x60600035cd80: fd fd fd fd fd fd fd fd fa fa f7 fa fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==35918==ADDITIONAL INFO
==35918==Note: Please include this section with the ASan report.
Task trace:
#0 0x000312903708 in mojo::SimpleWatcher::Context::Notify(unsigned int, MojoHandleSignalsState, unsigned int)+0x230 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12903708)
==35918==END OF ADDITIONAL INFO
==35918==ABORTING
[35850:53415468:0304/015935.928417:ERROR:content/browser/gpu/gpu_process_host.cc:999] GPU process exited unexpectedly: exit_code=256
References
components/viz/service/surfaces/surface_allocation_group.cc(OnFirstSurfaceActivation, UnregisterActiveEmbedder, UpdateLastActiveReferenceAndMaybeActivate)components/viz/service/surfaces/surface_allocation_group.h(active_embedders_ declaration)components/viz/service/surfaces/surface.cc(OnChildActivatedForActiveFrame, RecomputeActiveReferencedSurfaces, UpdateReferencedAllocationGroups, ActivateFrame)components/viz/service/frame_sinks/compositor_frame_sink_support.cc(MaybeSubmitCompositorFrame, no validation of referenced_surfaces)
Credit
86ac1f1587b71893ed2ad792cd7dde32
Context
This is an out-of-bounds read in Chromium's viz compositor service, tracked as CVE-2026-9895 and reported through the Chrome VRP. The affected component is the GPU process, specifically the surface management code in components/viz/service/surfaces/. The bug lives in SurfaceAllocationGroup::OnFirstSurfaceActivation, which iterates over the set of embedder surfaces registered against an allocation group while synchronously invoking callbacks on each of them. Those callbacks can re-enter the same data structure and erase an element from it, invalidating the iterators the loop is using.
The vulnerable file is platform-independent and compiled on every Chromium desktop and mobile target, so the issue affects Windows, Linux, macOS, ChromeOS and Android wherever the viz compositor service is enabled. No particular GPU hardware is needed: the crash happens on the VizCompositorThread inside the GPU process, in logic that does not depend on the graphics backend.
A compromised renderer can reach the bug through SubmitCompositorFrame, which means the attack crosses the renderer-to-GPU process boundary.
Setup
The researcher tested against the official ASan-enabled Chromium builds for Linux and macOS, published at https://commondatastorage.googleapis.com/chromium-browser-asan/index.html. The proof of concept is a standalone HTML file that uses MojoJS, with the dependent MojoJS code inlined into the HTML so the file is self-contained.
This report is a follow-up. The same issue had been reported earlier at https://issues.chromium.org/issues/489358139, but a small difference in the researcher's local environment made the earlier PoC fail to reproduce on ClusterFuzz, and that issue was closed. The current report supplies the corrected PoC, which the researcher says was successfully tested on the official ASan builds for both Linux and macOS.
Finding it
The researcher bisected the regression to a single introducing commit:
- Commit:
a661cdf7498e, "Add RegisterActiveEmbedder to SurfaceAllocationGroup" - Date: 2019-03-11
- Author: Saman Sami <[redacted]>
- Review: https://chromium-review.googlesource.com/c/chromium/src/+/1506593
The problem is a reentrancy hazard. OnFirstSurfaceActivation walks active_embedders_ with a C++ range-for loop and calls OnChildActivatedForActiveFrame on each embedder surface. That callback is not a leaf: it can lead, through a chain of surface activation logic, back to UnregisterActiveEmbedder, which erases an element from the very base::flat_set being iterated. Because base::flat_set is backed by a sorted std::vector, the erase shifts elements and invalidates the iterators captured by the range-for loop.
Exploitation
Step 1: understand the container and the loop
The member being iterated is declared as a base::flat_set of raw pointers to Surface:
// components/viz/service/surfaces/surface_allocation_group.h
base::flat_set<raw_ptr<Surface, CtnExperimental>> active_embedders_;
The loop that walks it is short:
// components/viz/service/surfaces/surface_allocation_group.cc
void SurfaceAllocationGroup::OnFirstSurfaceActivation(Surface* surface) {
for (Surface* embedder : active_embedders_)
embedder->OnChildActivatedForActiveFrame(surface->surface_id());
// ...
}
A range-for loop captures begin() and end() once, at the start of iteration. Since base::flat_set stores its elements in a sorted std::vector, any insertion or erasure invalidates those iterators.
Step 2: trigger the reentrant call chain
The callback OnChildActivatedForActiveFrame checks whether the newly activated surface falls inside any of the embedder's referenced SurfaceRange entries, and if so recomputes the embedder's active references:
// components/viz/service/surfaces/surface.cc
void Surface::OnChildActivatedForActiveFrame(const SurfaceId& activated_id) {
DCHECK(HasActiveFrame());
for (auto& surface_range : GetActiveFrame().metadata.referenced_surfaces) {
if (surface_range.IsInRangeInclusive(activated_id)) {
RecomputeActiveReferencedSurfaces();
return;
}
}
}
For a SurfaceRange whose ends carry different embed tokens (a cross-group reference), RecomputeActiveReferencedSurfaces calls UpdateLastActiveReferenceAndMaybeActivate on the end allocation group, GroupB. That function can force-activate a pending surface through deadline inheritance:
// components/viz/service/surfaces/surface_allocation_group.cc
void SurfaceAllocationGroup::UpdateLastActiveReferenceAndMaybeActivate(
const SurfaceId& surface_id) {
// ...
auto it = FindLatestSurfaceUpTo(surface_id);
if (it != surfaces_.end() && !(*it)->HasActiveFrame())
(*it)->ActivatePendingFrameForInheritedDeadline();
// ...
}
Step 3: recurse into the same embedder
When the pending surface in GroupB activates, GroupB runs its own OnFirstSurfaceActivation, which again calls OnChildActivatedForActiveFrame on the same embedder surface, E1. This recursive call re-evaluates E1's SurfaceRange. Now that GroupB has an active surface, GetLatestInFlightSurface resolves the range to GroupB's surface. Because the resolved surface's embed token no longer matches the start of the range, the start allocation group, GroupA, is dropped from the new referenced set:
// components/viz/service/surfaces/surface.cc
void Surface::RecomputeActiveReferencedSurfaces() {
// ...
for (const SurfaceRange& surface_range :
active_frame_data_->frame.metadata.referenced_surfaces) {
Surface* surface =
surface_manager_->GetLatestInFlightSurface(surface_range);
// ...
if (surface_range.HasDifferentEmbedTokens() &&
(!surface ||
surface->surface_id().HasSameEmbedTokenAs(*surface_range.start()))) {
// start allocation group is only referenced when resolved surface
// matches start's embed token
}
}
UpdateReferencedAllocationGroups(std::move(new_referenced_allocation_groups));
}
Step 4: erase from the set being iterated
When UpdateReferencedAllocationGroups sees that GroupA is no longer in the new set, it calls GroupA->UnregisterActiveEmbedder(E1), which erases E1 from GroupA's active_embedders_:
// components/viz/service/surfaces/surface.cc
void Surface::UpdateReferencedAllocationGroups(
std::vector<SurfaceAllocationGroup*> new_referenced_allocation_groups) {
// ...
for (SurfaceAllocationGroup* group : referenced_allocation_groups_) {
if (!new_set.count(group))
group->UnregisterActiveEmbedder(this);
}
// ...
}
// components/viz/service/surfaces/surface_allocation_group.cc
void SurfaceAllocationGroup::UnregisterActiveEmbedder(Surface* surface) {
DCHECK(active_embedders_.count(surface));
active_embedders_.erase(surface);
MaybeMarkForDestruction();
}
This erase happens while the outer OnFirstSurfaceActivation is still iterating the same container. The erase shifts all later elements one slot to the left in the underlying vector, invalidating the captured __end iterator and corrupting the iteration state. The loop skips the element that moved into the erased slot and eventually reads past the vector's logical end, producing a container-overflow.
Step 5: the concrete arithmetic
With five active embedders (the root compositor plus four attacker-controlled surfaces, E1 through E4), erasing E1 reduces the size from five to four. The stale __end iterator still points to index five, so after processing E3 and E4 (E2 is skipped because of the left shift), the loop tries to read index four of a size-four vector. That is the out-of-bounds read.
Step 6: what the renderer must control
A compromised renderer can build this scenario because CompositorFrameMetadata::referenced_surfaces accepts arbitrary SurfaceRange values without any permission or ownership validation. The renderer controls multiple FrameSinks, obtained through OffscreenCanvas, can submit frames carrying cross-group SurfaceRange references, and can create pending surfaces with unresolvable activation dependencies to arrange the timing the chain needs.
Step 7: reproduce
The PoC is run against the ASan build with MojoJS enabled:
# test on macOS
out/asan/Chromium.app/Contents/MacOS/Chromium --user-data-dir=./user --enable-blink-features=MojoJS,MojoJSTest --enable-logging=stderr poc_mojo_standalone.html
# test on Linux
out/asan/chrome --user-data-dir=./user --enable-blink-features=MojoJS,MojoJSTest --enable-logging=stderr poc_mojo_standalone.html
The PoC is launched with the MojoJS and MojoJSTest Blink features enabled.
Step 8: the ASan report
The crash is reported as a container-overflow, a read of size 8, on the VizCompositorThread (thread T13):
=================================================================
==35918==ERROR: AddressSanitizer: container-overflow on address 0x60600035cb60 at pc 0x00031b9e3ee8 bp 0x0001741d8850 sp 0x0001741d8848
READ of size 8 at 0x60600035cb60 thread T13
==35918==WARNING: invalid path to external symbolizer!
==35918==WARNING: Failed to use and restart external symbolizer!
#0 0x00031b9e3ee4 in viz::SurfaceAllocationGroup::OnFirstSurfaceActivation(viz::Surface*)+0x468 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9e3ee4)
#1 0x00031b9cbe98 in viz::Surface::ActivateFrame(viz::Surface::FrameData)+0x840 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9cbe98)
#2 0x00031b9ca254 in viz::Surface::CommitFrame(viz::Surface::FrameData)+0xd94 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9ca254)
#3 0x00031b9c9140 in viz::Surface::QueueFrame(viz::CompositorFrame, unsigned int, base::ScopedClosureRunner)+0x714 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9c9140)
#4 0x00031b771924 in viz::CompositorFrameSinkSupport::MaybeSubmitCompositorFrame(viz::LocalSurfaceId const&, viz::CompositorFrame, std::__Cr::optional<viz::HitTestRegionList>, unsigned long long)+0x1e44 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b771924)
#5 0x00031b788958 in viz::CompositorFrameSinkImpl::SubmitCompositorFrame(viz::LocalSurfaceId const&, viz::CompositorFrame, std::__Cr::optional<viz::HitTestRegionList>, unsigned long long)+0x19c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b788958)
#6 0x00030371e328 in viz::mojom::CompositorFrameSinkStubDispatch::Accept(viz::mojom::CompositorFrameSink*, mojo::Message*)+0x3cc (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x371e328)
#7 0x000312130064 in mojo::InterfaceEndpointClient::HandleValidatedMessage(mojo::Message*)+0x8fc (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12130064)
#8 0x000312144edc in mojo::MessageDispatcher::Accept(mojo::Message*)+0x2f0 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12144edc)
#9 0x000312135264 in mojo::InterfaceEndpointClient::HandleIncomingMessage(mojo::Message*)+0x148 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12135264)
#10 0x000312151cb8 in mojo::internal::MultiplexRouter::ProcessIncomingMessage(mojo::internal::MultiplexRouter::MessageWrapper*, mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*)+0x650 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12151cb8)
#11 0x000312150768 in mojo::internal::MultiplexRouter::Accept(mojo::Message*)+0x558 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12150768)
#12 0x000312144edc in mojo::MessageDispatcher::Accept(mojo::Message*)+0x2f0 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12144edc)
#13 0x000312123228 in mojo::Connector::DispatchMessage(mojo::ScopedHandleBase<mojo::MessageHandle>)+0x394 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12123228)
#14 0x0003121246f8 in mojo::Connector::ReadAllAvailableMessages()+0x23c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x121246f8)
#15 0x0003121241f8 in mojo::Connector::OnWatcherHandleReady(char const*, unsigned int)+0xe8 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x121241f8)
#16 0x000312125ce0 in base::internal::Invoker<base::internal::FunctorTraits<void (mojo::Connector::* const&)(char const*, unsigned int), mojo::Connector*, char const* const&>, base::internal::BindState<true, true, false, void (mojo::Connector::*)(char const*, unsigned int), base::internal::UnretainedWrapper<mojo::Connector, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>, base::internal::UnretainedWrapper<char const, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>>, void (unsigned int)>::Run(base::internal::BindStateBase*, unsigned int)+0x1b8 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12125ce0)
#17 0x0003039b4b50 in base::RepeatingCallback<void (unsigned int)>::Run(unsigned int) const &+0x148 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x39b4b50)
#18 0x000
The top frame is viz::SurfaceAllocationGroup::OnFirstSurfaceActivation, reached from Surface::ActivateFrame, Surface::CommitFrame, Surface::QueueFrame, CompositorFrameSinkSupport::MaybeSubmitCompositorFrame and CompositorFrameSinkImpl::SubmitCompositorFrame, then through the Mojo dispatch path. The allocation stack shows the vector being grown by SurfaceAllocationGroup::RegisterActiveEmbedder, called from Surface::UpdateReferencedAllocationGroups during RecomputeActiveReferencedSurfaces. The shadow bytes mark the read slot as fc, container overflow. The browser then logs that the GPU process exited unexpectedly with exit_code=256.
Root cause
The defect is a reentrancy bug in SurfaceAllocationGroup::OnFirstSurfaceActivation. It iterates active_embedders_, a base::flat_set backed by a sorted std::vector, with a range-for loop, and synchronously calls into embedder code on each iteration. That embedder code can, through the activation and reference-recomputation chain described above, call UnregisterActiveEmbedder on the same group and erase an element from the container under iteration. The erase shifts the remaining elements left, so the captured end iterator no longer matches the logical size, the loop skips one element, and it finally dereferences one slot past the end of the vector.
The DCHECK in UnregisterActiveEmbedder only asserts that the surface is present. The DCHECK in OnChildActivatedForActiveFrame only asserts that the embedder has an active frame. Neither check detects iterator invalidation, and in release builds the DCHECKs are compiled out anyway. The input that drives the chain, CompositorFrameMetadata::referenced_surfaces, is accepted from the renderer without permission or ownership validation. so a compromised renderer can supply the cross-group SurfaceRange values the chain needs.
Impact
The immediate effect is an out-of-bounds read in the GPU process, detected by ASan as a container-overflow and followed by the GPU process exiting unexpectedly. The bug is reachable from a compromised renderer through SubmitCompositorFrame, so it is a renderer-to-GPU process attack. It affects all platforms where Chromium runs with the viz compositor service enabled: Windows, Linux, macOS, ChromeOS and Android. No specific GPU hardware is required, because the crash occurs in surface management logic on the VizCompositorThread that is independent of the graphics backend.
The report classifies the weakness as an out-of-bounds read. The report does not describe a path beyond the out-of-bounds read, such as using the corrupted iteration for further memory corruption.
Fix
The report does not state what change was made to fix the issue. The structural problem is that OnFirstSurfaceActivation mutates its own container indirectly while iterating it, so a fix would need to make the iteration robust against reentrant erasure, for example by taking a snapshot of the embedders before invoking callbacks, or by deferring the unregistration until the loop completes.
Variants to test
- Other range-for loops over
base::flat_setorbase::flat_mapmembers in viz that synchronously call out to code able to insert or erase in the same container. A positive result is an ASan container-overflow report whose top frame is the iterating function. - Other callbacks reached from
OnFirstSurfaceActivationthat can re-enterRegisterActiveEmbedderorUnregisterActiveEmbedderon the same group. A positive result is a size change inactive_embedders_observed mid-iteration, visible as a skipped element or a read past the logical end. - Other renderer-supplied metadata fields accepted without validation in
CompositorFrameSinkSupport::MaybeSubmitCompositorFrame, particularly anything that influences allocation group membership. A positive result is a renderer-controlled value that changes group membership during activation. - The same cross-group
SurfaceRangepattern with different numbers of embedders, to see whether the skip and the over-read still occur when the erased element is not the first. A positive result is the same container-overflow signature at a different index. - The same activation chain on other platforms and builds, including ChromeOS and Android, to confirm the platform independence claimed in the report. A positive result is the same crash on the VizCompositorThread.
What happened, in plain words
A security researcher found a bug in Google Chrome. The bug is a memory-reading mistake inside a part of Chrome called the viz compositor service, which is the software that decides what pixels end up on your screen. The bug is tracked as CVE-2026-9895 and was reported through the Chrome VRP, Google's programme that pays people for finding and reporting security problems in Chrome.
The mistake is a specific kind called an out-of-bounds read. To understand it, imagine a row of numbered lockers. A program is only allowed to open lockers 1 to 5. An out-of-bounds read happens when the program, because of a logic slip, tries to peek into locker 6, which is outside the row it is supposed to use. It does not change anything in locker 6; it just reads whatever is there. That is why this class of bug is called a read: the program looks where it should not, instead of writing where it should not.
The bug lives in a file called surface_allocation_group.cc, in a function called SurfaceAllocationGroup::OnFirstSurfaceActivation. That function walks through a list of things called embedders (explained below) and, for each one, calls a piece of code that belongs to that embedder. The problem is that this called code can, in a roundabout way, come back and remove an entry from the very list that is being walked. Removing an entry while walking the list confuses the walk, and the walk ends up reading one slot past the end of the list.
The file is not tied to any one operating system. It is compiled into every Chromium desktop and mobile build, so the issue affects Windows, Linux, macOS, ChromeOS and Android wherever the viz compositor service is switched on. No special graphics card is needed: the crash happens on a background thread called the VizCompositorThread inside the GPU process, in bookkeeping code that does not depend on the graphics hardware at all.
A compromised renderer can reach the bug. Chrome splits its work across several processes. The renderer process runs the web page's code; the GPU process handles drawing. Normally the renderer is not allowed to harm the GPU process. Here, a renderer that has already been taken over by an attacker can send a specially crafted message, SubmitCompositorFrame, that crosses that boundary and triggers the bug. That crossing is what makes the bug interesting to security people.
Setting up the test
The researcher tested against the official ASan-enabled Chromium builds for Linux and macOS, published at https://commondatastorage.googleapis.com/chromium-browser-asan/index.html. ASan stands for AddressSanitizer: a tool built into a special test version of the browser that watches memory accesses and shouts loudly when a program reads or writes outside the area it owns. Think of it as a smoke alarm for memory mistakes. Normal Chrome does not have this alarm; the special build does, so bugs that would otherwise pass silently get caught.
The proof of concept (PoC) is a single standalone HTML file that uses MojoJS. Mojo is Chrome's internal messaging system, the plumbing that lets one part of the browser talk to another. MojoJS is a set of JavaScript bindings that expose those internal messages to a web page, but only when Chrome is started with a special flag. The researcher inlined the dependent MojoJS code into the HTML file so the file is self-contained: one file, no extra downloads.
This report is a follow-up. The same issue had been reported earlier at https://issues.chromium.org/issues/489358139, but a small difference in the researcher's local environment made the earlier PoC fail to reproduce on ClusterFuzz, Google's automated system that re-runs reported crashes. That earlier issue was closed. The current report supplies the corrected PoC, which the researcher says was successfully tested on the official ASan builds for both Linux and macOS.
Finding it
The researcher used a technique called bisecting to find when the bug was introduced. Bisecting means walking through the history of a codebase, checking a point in the middle, then narrowing down to the exact change that first caused the problem. It is like finding which day a leak started by checking the water meter every week and halving the range each time.
The result was a single introducing commit:
- Commit:
a661cdf7498e, "Add RegisterActiveEmbedder to SurfaceAllocationGroup" - Date: 2019-03-11
- Author: Saman Sami <[redacted]>
- Review: https://chromium-review.googlesource.com/c/chromium/src/+/1506593
A commit is a saved change to the source code, with a short identifier (here a661cdf7498e) and a message. The commit that introduced the bug is titled "Add RegisterActiveEmbedder to SurfaceAllocationGroup".
The underlying problem is called a reentrancy hazard. Reentrancy means that while one piece of code is running, something it calls ends up running the same code again, or touching the same data. Imagine you are reading a shopping list aloud and, halfway down, someone edits the list in your hand. You will read the wrong items. Here, OnFirstSurfaceActivation walks active_embedders_ with a C++ range-for loop and calls OnChildActivatedForActiveFrame on each embedder surface. That callback is not a dead end: through a chain of surface activation logic it can lead back to UnregisterActiveEmbedder, which erases an element from the very base::flat_set being iterated. Because base::flat_set is backed by a sorted std::vector, the erase shifts elements and invalidates the iterators captured by the range-for loop.
How the bug is triggered
Step 1: understand the container and the loop
The member being iterated is declared as a base::flat_set of raw pointers to Surface:
// components/viz/service/surfaces/surface_allocation_group.h
base::flat_set<raw_ptr<Surface, CtnExperimental>> active_embedders_;
Line by line:
base::flat_set<...>is a container type from Chromium's base library. A container is a data structure that holds a collection of items, like a box with compartments. A set holds each item at most once, and a flat_set stores its items in one contiguous, sorted block of memory, backed by astd::vector(a growable array).raw_ptr<Surface, CtnExperimental>is a pointer to aSurfaceobject. A pointer is a value that says where in memory an object lives, like an address on an envelope.raw_ptris Chromium's wrapper around a plain pointer that adds safety bookkeeping.active_embedders_is the name of the member. The trailing underscore is a Chromium naming convention for class members. An embedder here is a surface that displays another surface inside itself, like a picture frame holding a smaller picture.
The loop that walks it is short:
// components/viz/service/surfaces/surface_allocation_group.cc
void SurfaceAllocationGroup::OnFirstSurfaceActivation(Surface* surface) {
for (Surface* embedder : active_embedders_)
embedder->OnChildActivatedForActiveFrame(surface->surface_id());
// ...
}
Line by line:
void SurfaceAllocationGroup::OnFirstSurfaceActivation(Surface* surface)declares a function that returns nothing (void) and takes one argument, a pointer to aSurface. TheSurfaceAllocationGroup::prefix means the function belongs to theSurfaceAllocationGroupclass. A class is a bundle of data and functions that work on that data.for (Surface* embedder : active_embedders_)is a range-for loop. It visits each element ofactive_embedders_in turn, naming the current oneembedder. Crucially, a range-for loop captures the start and end positions of the container once, at the beginning, and then walks from one to the other. It does not re-check the container's size on every step.embedder->OnChildActivatedForActiveFrame(surface->surface_id());calls a function on the current embedder. The->means "call this function on the object the pointer points to".surface->surface_id()fetches the identifier of the surface that just activated and passes it along. This call is synchronous: the loop waits for it to finish before moving on. That waiting is what lets the called code run and, in this case, change the container underneath the loop.// ...marks code the report does not show.
A range-for loop captures begin() and end() once, at the start of iteration. Since base::flat_set stores its elements in a sorted std::vector, any insertion or erasure invalidates those iterators. An iterator is a cursor into a container, like a bookmark that says "you are here". If the container is rearranged, the bookmark may point at the wrong place.
Step 2: trigger the reentrant call chain
The callback OnChildActivatedForActiveFrame checks whether the newly activated surface falls inside any of the embedder's referenced SurfaceRange entries, and if so recomputes the embedder's active references:
// components/viz/service/surfaces/surface.cc
void Surface::OnChildActivatedForActiveFrame(const SurfaceId& activated_id) {
DCHECK(HasActiveFrame());
for (auto& surface_range : GetActiveFrame().metadata.referenced_surfaces) {
if (surface_range.IsInRangeInclusive(activated_id)) {
RecomputeActiveReferencedSurfaces();
return;
}
}
}
Line by line:
void Surface::OnChildActivatedForActiveFrame(const SurfaceId& activated_id)is a function on theSurfaceclass. It takes aSurfaceIdby constant reference, meaning it reads the identifier without copying it. A SurfaceId is a label that identifies one surface.DCHECK(HasActiveFrame());is a debug check.DCHECKonly does something in debug builds; in release builds it is compiled out. Here it asserts that the surface currently has an active frame. A frame is one picture the browser has prepared for display.for (auto& surface_range : GetActiveFrame().metadata.referenced_surfaces)walks the list ofSurfaceRangeentries recorded in the surface's active frame metadata.auto&means "take a reference to each element, whatever its type". A SurfaceRange describes a span of surfaces, from a start to an end. Metadata is extra information attached to a frame.if (surface_range.IsInRangeInclusive(activated_id))asks whether the newly activated surface's identifier falls inside this range, including both ends.RecomputeActiveReferencedSurfaces();is the important call. If the activated surface is inside the range, the embedder recalculates which surfaces it currently references. This is where the chain starts to bend back on itself.return;stops after the first matching range.
For a SurfaceRange whose ends carry different embed tokens (a cross-group reference), RecomputeActiveReferencedSurfaces calls UpdateLastActiveReferenceAndMaybeActivate on the end allocation group, GroupB. An embed token is a value that ties a surface to a particular embedding context; two surfaces with different embed tokens belong to different groups. An allocation group is a set of surfaces that share resources and activation rules. That function can force-activate a pending surface through deadline inheritance:
// components/viz/service/surfaces/surface_allocation_group.cc
void SurfaceAllocationGroup::UpdateLastActiveReferenceAndMaybeActivate(
const SurfaceId& surface_id) {
// ...
auto it = FindLatestSurfaceUpTo(surface_id);
if (it != surfaces_.end() && !(*it)->HasActiveFrame())
(*it)->ActivatePendingFrameForInheritedDeadline();
// ...
}
Line by line:
void SurfaceAllocationGroup::UpdateLastActiveReferenceAndMaybeActivate(const SurfaceId& surface_id)is a function on the allocation group that updates the last active reference and possibly activates something.auto it = FindLatestSurfaceUpTo(surface_id);looks up the latest surface at or before the given identifier and stores the result init, an iterator.if (it != surfaces_.end() && !(*it)->HasActiveFrame())checks two things: the lookup found something (the iterator is not the end marker), and that surface does not yet have an active frame.surfaces_is the group's own collection of surfaces.(*it)->ActivatePendingFrameForInheritedDeadline();activates the pending frame using a deadline inherited from elsewhere. Deadline inheritance means a surface that is waiting can be pushed to activate because a related surface has a deadline. This is the moment a surface that was not active suddenly becomes active, which is what the chain needs.
Step 3: recurse into the same embedder
When the pending surface in GroupB activates, GroupB runs its own OnFirstSurfaceActivation, which again calls OnChildActivatedForActiveFrame on the same embedder surface, E1. This recursive call re-evaluates E1's SurfaceRange. Now that GroupB has an active surface, GetLatestInFlightSurface resolves the range to GroupB's surface. Because the resolved surface's embed token no longer matches the start of the range, the start allocation group, GroupA, is dropped from the new referenced set:
// components/viz/service/surfaces/surface.cc
void Surface::RecomputeActiveReferencedSurfaces() {
// ...
for (const SurfaceRange& surface_range :
active_frame_data_->frame.metadata.referenced_surfaces) {
Surface* surface =
surface_manager_->GetLatestInFlightSurface(surface_range);
// ...
if (surface_range.HasDifferentEmbedTokens() &&
(!surface ||
surface->surface_id().HasSameEmbedTokenAs(*surface_range.start()))) {
// start allocation group is only referenced when resolved surface
// matches start's embed token
}
}
UpdateReferencedAllocationGroups(std::move(new_referenced_allocation_groups));
}
Line by line:
void Surface::RecomputeActiveReferencedSurfaces()is the function that recalculates which allocation groups a surface references.for (const SurfaceRange& surface_range : active_frame_data_->frame.metadata.referenced_surfaces)walks the referenced ranges in the active frame's metadata.active_frame_data_is a pointer to the active frame's data;->follows it.Surface* surface = surface_manager_->GetLatestInFlightSurface(surface_range);asks the surface manager for the latest surface that is in flight for this range. In flight means submitted but not yet fully settled. The result is stored insurface.if (surface_range.HasDifferentEmbedTokens() && (!surface || surface->surface_id().HasSameEmbedTokenAs(*surface_range.start())))is the condition that decides whether the start group stays referenced. It only stays if the range spans different embed tokens and either nothing resolved or the resolved surface has the same embed token as the range's start. The comment says exactly that: the start allocation group is only referenced when the resolved surface matches the start's embed token.UpdateReferencedAllocationGroups(std::move(new_referenced_allocation_groups));applies the newly computed set of referenced groups.std::movehands the vector over without copying it.
Step 4: erase from the set being iterated
When UpdateReferencedAllocationGroups sees that GroupA is no longer in the new set, it calls GroupA->UnregisterActiveEmbedder(E1), which erases E1 from GroupA's active_embedders_:
// components/viz/service/surfaces/surface.cc
void Surface::UpdateReferencedAllocationGroups(
std::vector<SurfaceAllocationGroup*> new_referenced_allocation_groups) {
// ...
for (SurfaceAllocationGroup* group : referenced_allocation_groups_) {
if (!new_set.count(group))
group->UnregisterActiveEmbedder(this);
}
// ...
}
Line by line:
void Surface::UpdateReferencedAllocationGroups(std::vector<SurfaceAllocationGroup*> new_referenced_allocation_groups)takes the new list of groups as a vector of pointers.for (SurfaceAllocationGroup* group : referenced_allocation_groups_)walks the old list of referenced groups.if (!new_set.count(group))checks whether the group is missing from the new set.countreturns how many times an item appears, so zero means absent.group->UnregisterActiveEmbedder(this);tells the group to unregister this surface as an active embedder.thisis the current surface, E1.
// components/viz/service/surfaces/surface_allocation_group.cc
void SurfaceAllocationGroup::UnregisterActiveEmbedder(Surface* surface) {
DCHECK(active_embedders_.count(surface));
active_embedders_.erase(surface);
MaybeMarkForDestruction();
}
Line by line:
void SurfaceAllocationGroup::UnregisterActiveEmbedder(Surface* surface)is the function that removes an embedder from the group.DCHECK(active_embedders_.count(surface));is a debug-only assertion that the surface really is in the set. It does nothing in release builds and, even in debug builds, it only checks presence, not whether the set is being iterated.active_embedders_.erase(surface);removes the surface from the set. This is the erase that happens while the outer loop is still walking the same set.MaybeMarkForDestruction();possibly marks the group for destruction if it is no longer needed.
This erase happens while the outer OnFirstSurfaceActivation is still iterating the same container. The erase shifts all later elements one slot to the left in the underlying vector, invalidating the captured __end iterator and corrupting the iteration state. The loop skips the element that moved into the erased slot and eventually reads past the vector's logical end, producing a container-overflow. A container-overflow is a specific kind of out-of-bounds access: the memory may still belong to the program, but it is outside the part of it that the container currently considers valid.
Step 5: the concrete arithmetic
With five active embedders (the root compositor plus four attacker-controlled surfaces, E1 through E4), erasing E1 reduces the size from five to four. The stale __end iterator still points to index five, so after processing E3 and E4 (E2 is skipped because of the left shift), the loop tries to read index four of a size-four vector. That is the out-of-bounds read.
In plain terms: the loop thinks there are still five items because it remembered the old end position. After one item is removed, the real list has four. The loop walks past the fourth and tries to read a fifth that no longer exists.
Step 6: what the renderer must control
A compromised renderer can build this scenario because CompositorFrameMetadata::referenced_surfaces accepts arbitrary SurfaceRange values without any permission or ownership validation. In other words, the renderer can claim that its frame references whatever surfaces it likes, and the GPU process believes it. The renderer controls multiple FrameSinks, obtained through OffscreenCanvas, can submit frames carrying cross-group SurfaceRange references, and can create pending surfaces with unresolvable activation dependencies to arrange the timing the chain needs.
- A FrameSink is an endpoint through which a client submits frames to the compositor.
- OffscreenCanvas is a web API that lets a page draw into a canvas that is not attached to the visible page. It is a legitimate feature, but it gives the page a way to obtain FrameSinks.
- Unresolvable activation dependencies means a surface is set up so that it cannot activate on its own, which lets the attacker control exactly when it activates later.
Step 7: reproduce
The PoC is run against the ASan build with MojoJS enabled:
# test on macOS
out/asan/Chromium.app/Contents/MacOS/Chromium --user-data-dir=./user --enable-blink-features=MojoJS,MojoJSTest --enable-logging=stderr poc_mojo_standalone.html
# test on Linux
out/asan/chrome --user-data-dir=./user --enable-blink-features=MojoJS,MojoJSTest --enable-logging=stderr poc_mojo_standalone.html
Line by line:
# test on macOSand# test on Linuxare comments, ignored by the shell.out/asan/Chromium.app/Contents/MacOS/Chromiumis the path to the ASan build of Chromium on macOS. On Linux the path isout/asan/chrome.--user-data-dir=./usertells the browser to keep its profile data in a folder calledusernext to where you run it, so the test does not touch your normal profile.--enable-blink-features=MojoJS,MojoJSTestturns on the MojoJS and MojoJSTest features in Blink, Chrome's rendering engine. Without this flag, the page could not send those messages.poc_mojo_standalone.htmlis the HTML file to open.
Step 8: the ASan report
The crash is reported as a container-overflow, a read of size 8, on the VizCompositorThread (thread T13):
=================================================================
==35918==ERROR: AddressSanitizer: container-overflow on address 0x60600035cb60 at pc 0x00031b9e3ee8 bp 0x0001741d8850 sp 0x0001741d8848
READ of size 8 at 0x60600035cb60 thread T13
==35918==WARNING: invalid path to external symbolizer!
==35918==WARNING: Failed to use and restart external symbolizer!
#0 0x00031b9e3ee4 in viz::SurfaceAllocationGroup::OnFirstSurfaceActivation(viz::Surface*)+0x468 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9e3ee4)
#1 0x00031b9cbe98 in viz::Surface::ActivateFrame(viz::Surface::FrameData)+0x840 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9cbe98)
#2 0x00031b9ca254 in viz::Surface::CommitFrame(viz::Surface::FrameData)+0xd94 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9ca254)
#3 0x00031b9c9140 in viz::Surface::QueueFrame(viz::CompositorFrame, unsigned int, base::ScopedClosureRunner)+0x714 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b9c9140)
#4 0x00031b771924 in viz::CompositorFrameSinkSupport::MaybeSubmitCompositorFrame(viz::LocalSurfaceId const&, viz::CompositorFrame, std::__Cr::optional<viz::HitTestRegionList>, unsigned long long)+0x1e44 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b771924)
#5 0x00031b788958 in viz::CompositorFrameSinkImpl::SubmitCompositorFrame(viz::LocalSurfaceId const&, viz::CompositorFrame, std::__Cr::optional<viz::HitTestRegionList>, unsigned long long)+0x19c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x1b788958)
#6 0x00030371e328 in viz::mojom::CompositorFrameSinkStubDispatch::Accept(viz::mojom::CompositorFrameSink*, mojo::Message*)+0x3cc (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x371e328)
#7 0x000312130064 in mojo::InterfaceEndpointClient::HandleValidatedMessage(mojo::Message*)+0x8fc (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12130064)
#8 0x000312144edc in mojo::MessageDispatcher::Accept(mojo::Message*)+0x2f0 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12144edc)
#9 0x000312135264 in mojo::InterfaceEndpointClient::HandleIncomingMessage(mojo::Message*)+0x148 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12135264)
#10 0x000312151cb8 in mojo::internal::MultiplexRouter::ProcessIncomingMessage(mojo::internal::MultiplexRouter::MessageWrapper*, mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*)+0x650 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12151cb8)
#11 0x000312150768 in mojo::internal::MultiplexRouter::Accept(mojo::Message*)+0x558 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12150768)
#12 0x000312144edc in mojo::MessageDispatcher::Accept(mojo::Message*)+0x2f0 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12144edc)
#13 0x000312123228 in mojo::Connector::DispatchMessage(mojo::ScopedHandleBase<mojo::MessageHandle>)+0x394 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12123228)
#14 0x0003121246f8 in mojo::Connector::ReadAllAvailableMessages()+0x23c (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x121246f8)
#15 0x0003121241f8 in mojo::Connector::OnWatcherHandleReady(char const*, unsigned int)+0xe8 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x121241f8)
#16 0x000312125ce0 in base::internal::Invoker<base::internal::FunctorTraits<void (mojo::Connector::* const&)(char const*, unsigned int), mojo::Connector*, char const* const&>, base::internal::BindState<true, true, false, void (mojo::Connector::*)(char const*, unsigned int), base::internal::UnretainedWrapper<mojo::Connector, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>, base::internal::UnretainedWrapper<char const, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>>, void (unsigned int)>::Run(base::internal::BindStateBase*, unsigned int)+0x1b8 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x12125ce0)
#17 0x0003039b4b50 in base::RepeatingCallback<void (unsigned int)>::Run(unsigned int) const &+0x148 (/Users/test/Desktop/src/chromium/src/out/asan/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7714.0/Chromium Framework:arm64+0x39b4b50)
#18 0x000
How to read this report:
- The first line says
AddressSanitizer: container-overflow, which is the alarm going off.READ of size 8means the program tried to read 8 bytes (the size of a pointer on a 64-bit machine) from a place it should not.thread T13names the thread where it happened. - The numbered lines starting with
#0,#1,#2and so on are the stack trace: the chain of function calls that led to the crash, with the most recent call at the top.#0isviz::SurfaceAllocationGroup::OnFirstSurfaceActivation, the function with the bug.#1isSurface::ActivateFrame,#2isSurface::CommitFrame,#3isSurface::QueueFrame,#4isCompositorFrameSinkSupport::MaybeSubmitCompositorFrameand#5isCompositorFrameSinkImpl::SubmitCompositorFrame. Below that come the Mojo dispatch functions, which show the message arriving from the renderer. - The second block, headed
allocated by thread T13 here, shows where the memory was allocated. The interesting frame is#4,SurfaceAllocationGroup::RegisterActiveEmbedder, called fromSurface::UpdateReferencedAllocationGroupsduringRecomputeActiveReferencedSurfaces. That is the vector being grown when the embedders were first registered. - The
Shadow bytessection is ASan's map of which memory is valid. The legend explains the codes:00means addressable,fcmeans container overflow. The arrow line=>0x60600035cb00marks the slot that was read, and the[fc]in it is the container-overflow marker. - The final line,
GPU process exited unexpectedly: exit_code=256, is the browser noticing that the GPU process died as a result of the crash.
Root cause
The defect is a reentrancy bug in SurfaceAllocationGroup::OnFirstSurfaceActivation. It iterates active_embedders_, a base::flat_set backed by a sorted std::vector, with a range-for loop, and synchronously calls into embedder code on each iteration. That embedder code can, through the activation and reference-recomputation chain described above, call UnregisterActiveEmbedder on the same group and erase an element from the container under iteration. The erase shifts the remaining elements left, so the captured end iterator no longer matches the logical size, the loop skips one element, and it finally dereferences one slot past the end of the vector.
The DCHECK in UnregisterActiveEmbedder only asserts that the surface is present. The DCHECK in OnChildActivatedForActiveFrame only asserts that the embedder has an active frame. Neither check detects iterator invalidation, and in release builds the DCHECKs are compiled out anyway. The input that drives the chain, CompositorFrameMetadata::referenced_surfaces, is accepted from the renderer without permission or ownership validation. so a compromised renderer can supply the cross-group SurfaceRange values the chain needs.
Impact
The immediate effect is an out-of-bounds read in the GPU process, detected by ASan as a container-overflow and followed by the GPU process exiting unexpectedly. The bug is reachable from a compromised renderer through SubmitCompositorFrame, so it is a renderer-to-GPU process attack. It affects all platforms where Chromium runs with the viz compositor service enabled: Windows, Linux, macOS, ChromeOS and Android. No specific GPU hardware is required, because the crash occurs in surface management logic on the VizCompositorThread that is independent of the graphics backend.
The report classifies the weakness as an out-of-bounds read. The report does not describe a path beyond the out-of-bounds read, such as using the corrupted iteration for further memory corruption.
Fix
The structural problem is that OnFirstSurfaceActivation mutates its own container indirectly while iterating it, so a fix would need to make the iteration robust against reentrant erasure, for example by taking a snapshot of the embedders before invoking callbacks, or by deferring the unregistration until the loop completes.
Variants to test
- Other range-for loops over
base::flat_setorbase::flat_mapmembers in viz that synchronously call out to code able to insert or erase in the same container. A positive result is an ASan container-overflow report whose top frame is the iterating function. - Other callbacks reached from
OnFirstSurfaceActivationthat can re-enterRegisterActiveEmbedderorUnregisterActiveEmbedderon the same group. A positive result is a size change inactive_embedders_observed mid-iteration, visible as a skipped element or a read past the logical end. - Other renderer-supplied metadata fields accepted without validation in
CompositorFrameSinkSupport::MaybeSubmitCompositorFrame, particularly anything that influences allocation group membership. A positive result is a renderer-controlled value that changes group membership during activation. - The same cross-group
SurfaceRangepattern with different numbers of embedders, to see whether the skip and the over-read still occur when the erased element is not the first. A positive result is the same container-overflow signature at a different index. - The same activation chain on other platforms and builds, including ChromeOS and Android, to confirm the platform independence claimed in the report. A positive result is the same crash on the VizCompositorThread.
Glossary
- API: a defined way for one piece of software to ask another piece of software to do something, like a menu of allowed requests.
- ASan (AddressSanitizer): a tool built into special test builds of a program that detects memory mistakes such as reads or writes outside valid memory.
- Allocation group: a set of surfaces that share resources and activation rules.
- Bisect: to find the exact change that introduced a bug by testing points in the middle of a range of code history and halving the range each time.
- Bounty: money paid by a company to a researcher who reports a valid security bug.
- Chrome VRP: Google's Vulnerability Reward Program for Chrome, which pays for security reports.
- Class: a bundle of data and functions that operate on that data in object-oriented programming.
- Commit: a saved change to a source code repository, identified by a short hash and a message.
- Compromised renderer: a renderer process that an attacker has taken over and can make send arbitrary messages.
- Container: a data structure that holds a collection of items.
- Container-overflow: a memory access outside the part of a container that is currently valid, even if the memory still belongs to the program.
- CVE: a public identifier for a known security vulnerability.
- Deadline inheritance: a rule that lets a waiting task be activated because a related task has a deadline.
- DCHECK: a debug-only assertion in Chromium that is compiled out in release builds.
- Embed token: a value that ties a surface to a particular embedding context, used to tell groups apart.
- Embedder: a surface that displays another surface inside itself.
- Flat_set: a set container that stores its items in one contiguous, sorted block of memory, backed by a vector.
- Frame: one picture the browser has prepared for display.
- FrameSink: an endpoint through which a client submits frames to the compositor.
- GPU process: the Chrome process that handles drawing and graphics work.
- In flight: submitted but not yet fully settled.
- Iterator: a cursor into a container that says where you are while walking it.
- Metadata: extra information attached to a frame.
- Mojo: Chrome's internal messaging system between processes.
- MojoJS: JavaScript bindings that expose Mojo messages to a web page, enabled by a special flag.
- OffscreenCanvas: a web API for drawing into a canvas that is not attached to the visible page.
- Out-of-bounds read: reading memory outside the area a program is allowed to access, without writing to it.
- Pointer: a value that says where in memory an object lives.
- PoC (proof of concept): a small program or file that demonstrates a bug.
- Range-for loop: a C++ loop that visits each element of a container, capturing the start and end positions once at the beginning.
- Reentrancy: when code that is already running is entered again, or when data being used is changed by code called from within that use.
- Renderer process: the Chrome process that runs a web page's code.
- Stack trace: the chain of function calls that led to a crash, with the most recent call at the top.
- Surface: a unit of drawable content managed by the compositor.
- SurfaceId: a label that identifies one surface.
- SurfaceRange: a description of a span of surfaces, from a start to an end.
- Synchronous call: a function call that waits for the called code to finish before continuing.
- Viz compositor service: the part of Chrome that decides what pixels end up on screen.
- VizCompositorThread: the background thread inside the GPU process where the viz compositor service runs.
- Vector: a growable array that stores its items contiguously in memory.