Type confusion in Compositing (CVE-2026-91731)
A 32-bit integer wraparound in the global layer ID generator allows an attacker to cause ID collisions between different cc::Layer subclasses. During synchronization, the compositor thread performs an unsafe static_cast on a collided ID, leading to type confusion and potential memory corruption in the renderer process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 3 months
Flapjack, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: A 32-bit integer wraparound in the global layer ID generator allows an attacker to cause ID collisions between different cc::Layer subclasses. During synchronization, the compositor thread performs an unsafe static_cast on a collided ID, leading to type confusion and potential memory corruption in the renderer process.
Affected files:
cc/layers/layer.cccc/trees/layer_tree_impl.cccc/layers/layer_collections.cccc/layers/layer.h
Estimated timestamp from git blame: Unknown (Google3 checkout)
Summary
A potential class hierarchy type confusion vulnerability exists in the Chrome Compositor (cc) due to a 32-bit integer wraparound in the global layer ID generator. By rapidly creating and destroying layers, an attacker can wrap the ID counter and cause newly created layers to share an ID with existing layers of a different subclass. During the compositor commit process, this duplicate ID causes LayerTreeImpl to retrieve the wrong layer object, leading to an unsafe static_cast and potential arbitrary code execution within the renderer process.
Vulnerability Details
Every compositor layer (cc::Layer) is assigned a unique ID upon creation using a global base::AtomicSequenceNumber defined in cc/layers/layer.cc. This generator utilizes a 32-bit signed integer (std::atomic_int), which wraps around after approximately 4.29 billion increments.
When the counter wraps, an attacker can cause a newly created layer (e.g., a PictureLayer) to be assigned the same ID as an existing, long-lived layer of a different subclass (e.g., a TextureLayer).
The vulnerability unfolds as follows:
- Map Overwrite: When the colliding
PictureLayeris added to the tree,LayerTreeHost::RegisterLayer()registers it. The uniqueness checkDCHECK(!LayerById(layer->id()));is compiled out in release builds, allowing the new layer to overwrite the old entry in the main thread'slayer_id_map. However, both layers physically remain in the layer tree. - Tree Synchronization: During commit,
TreeSynchronizer::SynchronizeTreestraverses the main thread's tree in drawing order. It createsLayerImplobjects for both theTextureLayerand thePictureLayer, assigning them both the identical ID. Both are pushed into theLayerTreeImpl's internal list. - Map Initialization Bug: To facilitate fast lookups,
OwnedLayerImplList::RebuildLayerMaps()creates a sorted vector of(layer_id, index)pairs. Becausestd::pairsorting is lexicographical, the layer that appeared earlier in the DOM (e.g., theTextureLayer) is stably sorted before thePictureLayer. This vector is used to initialize abase::flat_mapusing thebase::sorted_uniquetag. In release builds,base::flat_mapskips duplicate removal, silently retaining both entries. - Type Confusion: In
LayerTreeImpl::PullPropertiesFrom, the compositor iterates overcommit_state.picture_layer_ids_with_new_raster_sourceto update raster sources. When it queriesLayerById(id)for the colliding ID,base::flat_map::findusesstd::lower_bound, returning the first match. Due to the sorting order, it returns theTextureLayerImplinstead of the expectedPictureLayerImpl. - Exploitation: The returned pointer is unsafely cast:
static_cast<PictureLayerImpl*>(LayerById(layer_id))->CommitPendingRasterSource(). Accessing fields likepending_raster_source_(ascoped_refptr<RasterSource>) on the incompatibleTextureLayerImplobject leads to overlapping memory access and potential hijacked virtual method calls.
Suggested Steps to Trigger (Theoretical)
Note: These are potential steps; our tooling agent does not execute code to provide a working PoC.
- Initialize a Web Worker that rapidly instantiates
OffscreenCanvasobjects and requestsbitmaprenderercontexts to quickly increment the globalg_next_layer_id. - On the main thread, track the increments and create a target
TextureLayer(e.g., via a<canvas>element) just before the ID generator overflows. - Allow the generator to wrap around, stopping when it reaches the ID of the target layer.
- Create a
PictureLayer(e.g., a<div>withwill-change: transform). It receives the same ID as theTextureLayer. - Ensure the DOM is structured such that the
TextureLayerappears before thePictureLayerin pre-order traversal. - Trigger a compositor commit, causing the renderer to execute the type confusion.
Suggested Fix
- Upgrade the global ID generator
g_next_layer_idincc/layers/layer.ccand thelayer_id_field incc/layers/layer.hto use 64-bit integers (uint64_t) to make wraparound computationally infeasible. - Implement a
CHECK(not just aDCHECK) inLayerTreeHost::RegisterLayerto enforce ID uniqueness in release builds, preventing map collisions outright.
Evaluated with Chrome root at commit: 65b3256311f3ab6fb9870eaa522de7e6dd2663bb
Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:
- If you are familiar with the severity guidelines, you may adjust the severity.
- If this is a false positive, and there's no work to be done, please close as WAI.
- If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.
Data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a 32-bit signed integer counter for layer IDs wraps around, and release builds skip duplicate-ID checks, so a new layer can overwrite an existing entry in the ID map and later be confused with a different layer subclass.
Impact
The type confusion could lead to memory corruption and potential arbitrary code execution within the renderer process, though the report notes the steps are theoretical and no working proof of concept was executed.
What the attacker needed
Ability to run JavaScript in the browser; rapid creation of many layers; control over DOM order
The fix
The global ID generator and layer ID field should be upgraded to 64-bit integers, and a CHECK (not just a DCHECK) should enforce ID uniqueness in release builds.
How it was found
- Initialize a Web Worker that rapidly instantiates OffscreenCanvas objects and requests bitmaprenderer contexts to quickly increment the global g_next_layer_id.
- On the main thread, track the increments and create a target TextureLayer (e.g., via a <canvas> element) just before the ID generator overflows.
- Allow the generator to wrap around, stopping when it reaches the ID of the target layer.
- Create a PictureLayer (e.g., a <div> with will-change: transform). It receives the same ID as the TextureLayer.
- Ensure the DOM is structured such that the TextureLayer appears before the PictureLayer in pre-order traversal.
- Trigger a compositor commit, causing the renderer to execute the type confusion.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
The browser's compositor assigns each visual layer a unique number. If an attacker can make that number wrap around, two different kinds of layers can end up with the same number. The browser then treats one layer as if it were the other kind, which can corrupt memory and potentially let the attacker run code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.