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

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.cc
  • cc/trees/layer_tree_impl.cc
  • cc/layers/layer_collections.cc
  • cc/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:

  1. Map Overwrite: When the colliding PictureLayer is added to the tree, LayerTreeHost::RegisterLayer() registers it. The uniqueness check DCHECK(!LayerById(layer->id())); is compiled out in release builds, allowing the new layer to overwrite the old entry in the main thread's layer_id_map. However, both layers physically remain in the layer tree.
  2. Tree Synchronization: During commit, TreeSynchronizer::SynchronizeTrees traverses the main thread's tree in drawing order. It creates LayerImpl objects for both the TextureLayer and the PictureLayer, assigning them both the identical ID. Both are pushed into the LayerTreeImpl's internal list.
  3. Map Initialization Bug: To facilitate fast lookups, OwnedLayerImplList::RebuildLayerMaps() creates a sorted vector of (layer_id, index) pairs. Because std::pair sorting is lexicographical, the layer that appeared earlier in the DOM (e.g., the TextureLayer) is stably sorted before the PictureLayer. This vector is used to initialize a base::flat_map using the base::sorted_unique tag. In release builds, base::flat_map skips duplicate removal, silently retaining both entries.
  4. Type Confusion: In LayerTreeImpl::PullPropertiesFrom, the compositor iterates over commit_state.picture_layer_ids_with_new_raster_source to update raster sources. When it queries LayerById(id) for the colliding ID, base::flat_map::find uses std::lower_bound, returning the first match. Due to the sorting order, it returns the TextureLayerImpl instead of the expected PictureLayerImpl.
  5. Exploitation: The returned pointer is unsafely cast: static_cast<PictureLayerImpl*>(LayerById(layer_id))->CommitPendingRasterSource(). Accessing fields like pending_raster_source_ (a scoped_refptr<RasterSource>) on the incompatible TextureLayerImpl object 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.

  1. Initialize a Web Worker that rapidly instantiates OffscreenCanvas objects and requests bitmaprenderer contexts to quickly increment the global g_next_layer_id.
  2. On the main thread, track the increments and create a target TextureLayer (e.g., via a <canvas> element) just before the ID generator overflows.
  3. Allow the generator to wrap around, stopping when it reaches the ID of the target layer.
  4. Create a PictureLayer (e.g., a <div> with will-change: transform). It receives the same ID as the TextureLayer.
  5. Ensure the DOM is structured such that the TextureLayer appears before the PictureLayer in pre-order traversal.
  6. Trigger a compositor commit, causing the renderer to execute the type confusion.

Suggested Fix

  1. Upgrade the global ID generator g_next_layer_id in cc/layers/layer.cc and the layer_id_ field in cc/layers/layer.h to use 64-bit integers (uint64_t) to make wraparound computationally infeasible.
  2. Implement a CHECK (not just a DCHECK) in LayerTreeHost::RegisterLayer to 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.

The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely 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

  1. Initialize a Web Worker that rapidly instantiates OffscreenCanvas objects and requests bitmaprenderer contexts to quickly increment the global g_next_layer_id.
  2. On the main thread, track the increments and create a target TextureLayer (e.g., via a <canvas> element) just before the ID generator overflows.
  3. Allow the generator to wrap around, stopping when it reaches the ID of the target layer.
  4. Create a PictureLayer (e.g., a <div> with will-change: transform). It receives the same ID as the TextureLayer.
  5. Ensure the DOM is structured such that the TextureLayer appears before the PictureLayer in pre-order traversal.
  6. 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.

More from Google Chrome

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.