Use after free in GPU (CVE-2026-17746)
A missing validation check during Mojo deserialization of SkColor4f allows a compromised renderer to send NaN values to the GPU process. On macOS, this corrupts a std::map's internal tree, leading to a use-after-free that could potentially be exploited for remote code execution.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 4 months
Project Fortify, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports without the security team.
Overview: A missing validation check during Mojo deserialization of SkColor4f allows a compromised renderer to send NaN values to the GPU process. On macOS, this corrupts the internal Red-Black tree of a std::map used for caching solid colors, leading to a Use-After-Free condition. An attacker can potentially exploit this dangling pointer to achieve Remote Code Execution via a hijacked CFRelease call.
Affected files:
skia/public/mojom/skcolor4f_mojom_traits.hservices/viz/public/cpp/compositing/quads_mojom_traits.ccui/accelerated_widget_mac/ca_renderer_layer_tree.mm
Estimated timestamp from git blame: 2024-10-09
Summary
A validation gap in the Mojo deserialization of skia::mojom::SkColor4f allows a compromised renderer to send non-finite floating-point values (NaN) to the GPU process. On macOS, these values reach the CARendererLayerTree, where they are used as keys in a std::map. Because NaN comparisons violate the strict weak ordering required by std::map, the internal tree structure becomes corrupted. This corruption causes node removal to fail silently, resulting in a Use-After-Free (UAF) condition that can potentially be leveraged for arbitrary code execution (RCE) in the GPU process.
Root Cause Analysis
- Mojo Deserialization: In
skia/public/mojom/skcolor4f_mojom_traits.h, theReadmethod copies RGBA components directly from the Mojo wire without verifying if the floats are finite usingstd::isfinite(). - Ineffective Clamping: In
services/viz/public/cpp/compositing/quads_mojom_traits.cc,SolidColorQuadStatedeserialization attempts to clamp the alpha component usingstd::clamp(quad->color.fA, 0.0f, 1.0f). BecauseNaN < 0.0fand1.0f < NaNboth evaluate tofalse,std::clampreturns theNaNvalue unmodified. - Strict Weak Ordering Violation: In
ui/accelerated_widget_mac/ca_renderer_layer_tree.mm,SolidColorContentsobjects are cached in astd::maputilizingComparatorSkColor4f. This comparator usesstd::tieto perform a lexicographical comparison on the float components. When comparingNaNto any finite value, both<and>returnfalse, causingstd::tieto treat the component as "equivalent" and fall through to the next component. This creates non-transitive cycles (e.g., A < B < C < A), thoroughly corrupting the map's underlying Red-Black tree during insertions.
Potential Exploitation Steps
Note: These are suggested steps based on static analysis. A working proof of concept has not yet been developed to run this code.
- Tree Corruption: A compromised renderer sends a sequence of
SolidColorDrawQuads with carefully chosenNaNand finite color values. This triggers insertions into thestd::mapin the GPU process, corrupting its internal tree structure. - Creating the UAF: The attacker causes one of the generated layers to be discarded. This drops the reference count of the corresponding
SolidColorContentsto zero, triggering its destructor. The destructor attempts to callmap->erase(color_). Because the tree is corrupted, the binary search takes the wrong path and fails to find the node.std::map::erasesilently returns 0 in Release builds (whereDCHECKs are stripped). The object's memory is freed, but a dangling raw pointer remains in the map. - Heap Grooming: The attacker leverages other GPU process IPCs to allocate controlled data into the exact PartitionAlloc slot previously occupied by the freed
SolidColorContents. - Triggering the Payload: The attacker sends another
SolidColorDrawQuaddesigned to navigate the corrupted tree and return the dangling pointer viaSolidColorContents::Get. - RCE via CFRelease: The GPU process wraps the dangling pointer in a new
scoped_refptr, which increments a fake reference count in the attacker's payload. When this layer is eventually discarded, the destructor is called on the fake object. This automatically invokes the destructor of theio_surface_member (base::apple::ScopedCFTypeRef<IOSurfaceRef>), which calls the system APICFRelease()on an attacker-controlled pointer. By forging an Objective-C object header (theisapointer), the attacker can hijack the method dispatch during deallocation, resulting in arbitrary code execution in the GPU process.
MiraclePtr / BRP Status
This vulnerability is not protected by MiraclePtr (BackupRefPtr). The std::map stores raw C++ pointers (SolidColorContents*). The SolidColorContents objects inherit from base::RefCounted and are managed by scoped_refptr. Chromium's scoped_refptr implementation explicitly excludes its internal pointer from MiraclePtr (RAW_PTR_EXCLUSION) for performance reasons, meaning the dangling pointer access goes unprotected.
Suggested Fix
- Mojo Validation: Add
std::isfinitechecks inStructTraits<skia::mojom::SkColor4fDataView, ::SkColor4f>::Readinsideskia/public/mojom/skcolor4f_mojom_traits.h. If any component isNaNor infinity, deserialization should fail (return false;). - Defense in Depth: Consider updating
ComparatorSkColor4fto usestd::partial_orderingor a custom float comparison that explicitly and safely handlesNaNvalues (e.g., treatingNaNas always less than or always greater than finite values, or rejecting them), to ensure strict weak ordering is never violated.
Evaluated with Chrome root at commit: 137d451a126685dd5010e6609db9f6d4a78d8234
Results so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; 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 the root cause is that the Mojo deserialization of SkColor4f does not check for non-finite floating-point values, and the subsequent use of these values as keys in a std::map violates the strict weak ordering requirement, corrupting the map's internal tree.
Impact
An attacker could potentially achieve remote code execution in the GPU process, but a working proof of concept has not yet been developed.
What the attacker needed
Compromised renderer; macOS; no working PoC yet
The fix
The fix should add std::isfinite checks in the Mojo deserialization and consider updating the comparator to handle NaN values safely.
How it was found
- A compromised renderer sends a sequence of SolidColorDrawQuads with carefully chosen NaN and finite colour values.
- The attacker causes one of the generated layers to be discarded, triggering the destructor of SolidColorContents.
- The destructor attempts to erase the colour from the corrupted map, but the erase fails silently, leaving a dangling pointer.
- The attacker uses other GPU process IPCs to allocate controlled data into the freed memory slot.
- The attacker sends another SolidColorDrawQuad to retrieve the dangling pointer via SolidColorContents::Get.
- The GPU process wraps the dangling pointer in a scoped_refptr, and when the layer is discarded, CFRelease is called on an attacker-controlled pointer, potentially leading to code execution.
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.
This report describes a bug in a web browser's graphics system. A compromised part of the browser (the renderer) can send special 'not a number' values to another part (the GPU process). These values confuse a data structure that stores colours, causing it to free memory but keep a pointer to it. An attacker might then reuse that freed memory to run their own 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.