Use after free in Dawn (CVE-2026-6310)
A race condition in Dawn's Metal backend allows a use-after-free when a Queue is destroyed while a background completion handler still holds a raw pointer to it. A compromised renderer could potentially exploit this to achieve arbitrary code execution in the GPU process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 16 days
Project Fortify, an experimental security project, has identified the following potential security issue.
Overview: A race condition in Dawn's Metal backend can lead to a potential Use-After-Free (UAF) vulnerability when a Queue is destroyed. An Objective-C completion handler captures a raw this pointer to the Queue object, which can be freed by the main thread before the background handler finishes executing. A compromised renderer could potentially exploit this to achieve arbitrary code execution in the highly privileged GPU process.
Affected files:
third_party/dawn/src/dawn/native/ExecutionQueue.cppthird_party/dawn/src/dawn/native/metal/QueueMTL.mmthird_party/dawn/src/dawn/native/ExecutionQueue.h
Estimated timestamp from git blame: 2026-03-02
Vulnerability Details
A potential Use-After-Free (UAF) vulnerability exists in the Dawn GPU process when using the Metal backend on macOS.
In third_party/dawn/src/dawn/native/metal/QueueMTL.mm, the SubmitPendingCommandBuffer function registers an MTLCommandBuffer completion handler. This Objective-C block inherently captures the C++ this pointer as a raw pointer, bypassing Dawn's Ref<T> reference counting and MiraclePtr (raw_ptr<T>) protections:
// QueueMTL.mm
[*pendingCommands addCompletedHandler:^(id<MTLCommandBuffer>) {
// `this` is captured as a raw pointer
this->UpdateCompletedSerialTo(QueuePriority::Lowest, pendingSerial);
}];
When the GPU command finishes, this block executes on a background Metal driver thread, calling ExecutionQueueBase::UpdateCompletedSerialToInternal in ExecutionQueue.cpp. This function relies on two distinct mutex-protected scopes:
mCompletedSerial.Use(...): Updates the completed serial and signals a condition variable (notify_all()).mState.Use(...): Accesses internal queue state and fires waiting callbacks/processors.
A race condition occurs because signaling the condition variable at the end of the first scope can wake up the main thread if it is currently waiting in WaitForIdleForDestruction (invoked during device teardown).
If the main thread wakes up, it can complete the destruction of the Device and Queue. It sets mQueue = nullptr, dropping the last reference to the queue, causing it to be deleted. If the background thread is preempted by the OS exactly between the two lock scopes, it will resume execution with a dangling this pointer when it attempts to enter the mState.Use(...) scope.
Suggested Steps to Trigger
(Note: These are potential steps as our tooling agent does not yet have the ability to run or verify arbitrary exploit code.)
- Setup: From a compromised renderer process, create a WebGPU
DeviceandQueue. - Submit Work: Submit a WebGPU command buffer that takes a predictable amount of time to execute.
- Trigger Teardown: Immediately drop all renderer-side references to the WebGPU device, prompting the GPU process to call
DeviceBase::WillDropLastExternalRef()and subsequentlyWaitForIdleForDestruction(). - Heap Spray: Rapidly spray the GPU process heap via other WebGPU allocations (e.g., buffer creations) sized perfectly to reclaim the
Queueobject's memory once it is freed. - Win the Race: The background thread signals the condition variable and the OS preempts it. The main thread wakes up, frees the
Queue, and the attacker's heap spray reclaims the memory, setting up a fakemStateobject with a forgedmWaitingProcessorsvector. - Hijack Control Flow: The background thread resumes, accesses the sprayed
mStatememory, and iterates over the fakemWaitingProcessors. It executesprocessor->UpdateCompletedSerialTo(serial);, which is a virtual function call. This dereferences the attacker-controlled vtable, leading to arbitrary Remote Code Execution (RCE) in the GPU process.
Suggested Fix
To fix this issue, the Objective-C completion handler must keep the Queue object alive for the duration of its execution, or safely check if it has been destroyed.
The most straightforward fix is to capture a strongly-referenced Ref<Queue> inside the Objective-C block instead of relying on the implicit raw this pointer:
// In QueueMTL.mm
Ref<Queue> selfRef = this;
[*pendingCommands addCompletedHandler:^(id<MTLCommandBuffer>) {
selfRef->UpdateCompletedSerialTo(QueuePriority::Lowest, pendingSerial);
}];
This ensures the Queue's reference count remains elevated until the completion handler fully finishes executing, preventing the main thread from deleting the object prematurely.
Evaluated with Chrome root at commit: a9cbf6e8b275fe4147435aa905f3b7f5a656f5f0
Results from 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
The Objective-C completion handler captures a raw `this` pointer to the Queue instead of a reference-counted smart pointer, so the Queue can be freed while the handler still uses it.
Impact
A compromised renderer could potentially achieve arbitrary code execution in the highly privileged GPU process.
What the attacker needed
Compromised renderer process; macOS with Metal backend; win a timing race
The fix
The completion handler should capture a strongly-referenced Ref<Queue> so the Queue stays alive until the handler finishes.
How it was found
- From a compromised renderer, create a WebGPU Device and Queue.
- Submit a command buffer that takes a predictable time to execute.
- Drop all renderer-side references to the device to trigger teardown and WaitForIdleForDestruction.
- Spray the GPU process heap with WebGPU allocations sized to reclaim the freed Queue.
- Win the race: the background thread is preempted after signalling, the main thread frees the Queue, and the spray reclaims it.
- The background thread resumes, accesses the fake state, and makes a virtual call through an attacker-controlled vtable.
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.
A use-after-free happens when a program frees memory but keeps using it, like deleting a file and then trying to open it. Here, a background task keeps a pointer to a queue object that the main thread can delete at the same time. An attacker who controls the freed memory could make the program 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.