Use after free in Skia (CVE-2026-17653)
A heap use-after-free was identified in Skia's Graphite Dawn backend where a growable array of static sampler layouts can reallocate while pointers to its elements are still stored in a descriptor chain. An attacker who can reclaim the freed memory could potentially control the chained layout and achieve code execution in the GPU process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 55 days
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. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: A potential heap use-after-free vulnerability exists in Skia's Graphite Dawn backend (DawnGraphicsPipeline.cpp) due to the reallocation of a TArray holding static sampler layouts while pointers to its elements are still held in a descriptor chain. When the layout is subsequently processed during bind group layout creation, the deallocated memory is traversed, potentially leading to a GPU process crash or code execution.
Affected files:
third_party/skia/src/gpu/graphite/dawn/DawnGraphicsPipeline.cpp
Estimated timestamp from git blame: 2024-10-03
Description
A potential heap use-after-free (UAF) vulnerability has been identified in DawnGraphicsPipeline::Make() within Skia's Graphite Dawn backend (third_party/skia/src/gpu/graphite/dawn/DawnGraphicsPipeline.cpp).
The issue stems from the lifecycle management of skia_private::TArray<wgpu::StaticSamplerBindingLayout> staticSamplerLayouts during the creation of a bind group layout.
Detailed Analysis
In DawnGraphicsPipeline::Make(), a local vector is declared to hold static sampler layouts:
skia_private::TArray<wgpu::StaticSamplerBindingLayout> staticSamplerLayouts;
As the loop iterates over textures and samplers, if a sampler is immutable, a layout is added to the array and its address is saved into the stack-allocated entries array:
wgpu::StaticSamplerBindingLayout& immutableSamplerBinding =
staticSamplerLayouts.emplace_back();
...
entries[i].nextInChain = &immutableSamplerBinding;
Because staticSamplerLayouts is default-constructed with a capacity of 0 and is not pre-reserved, appending elements can trigger a vector reallocation. When TArray::emplace_back() exhausts its capacity, it reallocates the underlying buffer via growAndConstructAtEnd() -> installDataAndUpdateCapacity(), move-constructs elements to the new buffer, and frees the old buffer via sk_free().
If a reallocation occurs, any pointers already stored in entries[*].nextInChain pointing to the previous array storage become dangling.
Later, Dawn processes these entries inside device.CreateBindGroupLayout(&groupLayoutDesc). In release builds, DeviceBase::CreateBindGroupLayout calls ConvertAndExpandBGLEntries(), which invokes the generated Unpack<BindGroupLayoutEntry>() function. This function traverses the linked list starting at the dangling nextInChain pointer.
If an attacker is able to reclaim and populate the freed heap memory before the unpack traversal, they could control the structure's sType and sampler pointer. When StaticSamplerBindingInfo::From() is called, it constructs a Ref<SamplerBase>{layout.sampler}, which increments and decrements the reference count at an attacker-controlled offset and potentially triggers a virtual method call on destruction, leading to arbitrary code execution within the GPU process.
Triggering Preconditions
On 64-bit systems, the first allocation of staticSamplerLayouts is rounded up to a minimum capacity of 8 elements (256 bytes, fitting PartitionAlloc's 256-byte bucket). Thus, a pipeline containing 9 or more immutable (Vulkan YCbCr) samplers is required to trigger a reallocation. Under normal operation, immutable samplers are typically produced only for textures backed by a YCbCr descriptor (such as Android AHardwareBuffer SharedImages).
Potential Steps to Reproduce (Theoretical)
Note: These are potential steps based on source code analysis; our tools do not currently have the capability to run code or verify this dynamically.
- From a compromised renderer, serialize OOP-R paint commands that reference 9 or more distinct, unique
AHardwareBuffer-backed YCbCr images in a single paint shader/filter tree. - Ensure the resulting pipeline description is unique to prevent hitting the pipeline cache.
- Once the raster command is executed, the GPU process calls
DawnGraphicsPipeline::Make(). On the 9th immutable sampler,staticSamplerLayoutsreallocates, leaving dangling pointers inentries[0..7].nextInChain. - Concurrently, spray the PartitionAlloc 256-byte bucket to reclaim the freed block and overwrite its contents with forged layout descriptions.
- When
device.CreateBindGroupLayout()parses the entries, it traverses the forged chained layouts, performing refcount increments and virtual calls.
Suggested Fix
To resolve this issue, reserve sufficient capacity in staticSamplerLayouts prior to entering the loop. Since the maximum possible number of static samplers is bounded by numTexturesAndSamplers / 2, pre-allocating or reserving this capacity prevents any subsequent reallocation:
skia_private::TArray<wgpu::StaticSamplerBindingLayout> staticSamplerLayouts;
staticSamplerLayouts.reserve(numTexturesAndSamplers / 2);
Evaluated with Chrome root at commit: e9507a33bb4148ee071aaaf8a7e9ad68770359bf
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 the array holding static sampler layouts was not reserved before appending, so reallocation invalidated pointers stored in the descriptor chain.
Impact
An attacker could potentially crash the GPU process or achieve arbitrary code execution within it, though the report notes the steps are theoretical and have not been dynamically verified.
What the attacker needed
Compromised renderer; nine or more YCbCr immutable samplers; 64-bit system; ability to spray the 256-byte allocator bucket
The fix
The array should be reserved with a capacity of half the number of textures and samplers before the loop so it never reallocates.
How it was found
- From a compromised renderer, send paint commands referencing nine or more distinct YCbCr images backed by Android hardware buffers.
- Make the pipeline description unique so it is not served from the pipeline cache.
- When the GPU process builds the pipeline, the ninth immutable sampler causes the array to reallocate, leaving dangling pointers.
- Spray the allocator bucket to reclaim the freed block and place forged layout descriptions there.
- When the bind group layout is created, the forged chained layouts are traversed, causing refcount changes and virtual calls.
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.
When a program stores a list of items in a growable container, adding more items can move the whole list to a new memory location. If the program kept the old address of an item, that address now points to freed memory. Here, an attacker might fill that freed memory with their own data, and the program would then trust it, which could crash the browser's graphics process or 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.