Use after free in GPU (CVE-2026-9922)
A use-after-free was found in the macOS GPU process where a WebGL context could be destroyed without unregistering its GL debug callback when the context was lost. An attacker could keep the underlying GL context alive through a shared IOSurface-backed state and later trigger the stale callback, potentially leading to remote code execution.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 51 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 without the security team.
Overview: A Use-After-Free vulnerability exists in the macOS GPU process where a WebGL context can be destroyed without unregistering its GL debug callback if the context is lost. A shared IOSurfaceBackingEGLState can keep the underlying GL context alive, allowing a subsequent glDeleteTextures call on the lost context to trigger the stale callback, leading to RCE.
Affected files:
gpu/command_buffer/service/gles2_cmd_decoder_passthrough.ccgpu/command_buffer/service/shared_image/iosurface_image_backing.mmgpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc
Estimated timestamp from git blame: 2026-02-17
Description
A potential Use-After-Free (UAF) vulnerability has been identified in the GLES2 passthrough decoder, specifically affecting macOS via IOSurfaceBackingEGLState. The issue stems from a combination of GL context retention across different decoders and a failure to clear the KHR_debug callback during decoder destruction when a context is lost.
When a passthrough decoder imports a macOS IOSurface-backed SharedImage, IOSurfaceImageBacking::RetainGLTexture creates an IOSurfaceBackingEGLState object that holds a strong scoped_refptr to the decoder's gl::GLContext. This EGL state is cached in egl_state_map_ and shared across decoders on the same thread.
When a decoder is destroyed, GLES2DecoderPassthroughImpl::Destroy(bool have_context) skips unregistering the glDebugMessageCallbackKHR if have_context is false (e.g., if WEBGL_lose_context was previously called). This leaves a stale pointer to the freed decoder in ANGLE's C API.
If another decoder keeps the IOSurfaceBackingEGLState (and thus the underlying GL context) alive, releasing the SharedImage later will cause ~IOSurfaceBackingEGLState to call glDeleteTextures via ui::ScopedMakeCurrent. If a GPU reset is induced before this release, ANGLE emits a GL_CONTEXT_LOST error debug message during the delete call, synchronously invoking the stale callback and leading to a virtual call (GetLogger()) on the freed decoder memory.
Potential Attack Steps
These are suggested steps based on static analysis:
- Setup Contexts: In a compromised renderer, create two WebGL contexts (Decoder A and Decoder B) that map to separate passthrough decoders in the GPU process.
- Import SharedImage: Create an
IOSurface-backed SharedImage and import it into Decoder A. This causesIOSurfaceBackingEGLStateto capture a strong reference to Decoder A'sgl::GLContext. - Share EGL State: Import the same SharedImage into Decoder B. Decoder B now holds a reference to the same
IOSurfaceBackingEGLState. - Simulate Context Loss: Delete the texture in Decoder A and call
WEBGL_lose_context.loseContext()on Decoder A. This marks Decoder A as lost. - Destroy Decoder A: Destroy Decoder A. The cleanup skips unregistering the ANGLE debug callback because
have_contextis false. The callbackuser_paramis now a dangling pointer to the freed Decoder A. - Heap Spray: Spray the GPU process heap to place a fake vtable at Decoder A's old address.
- Induce Real Context Loss: Submit an expensive shader to induce a legitimate GPU hang, causing ANGLE to internally mark devices as lost.
- Trigger UAF: Delete the texture in Decoder B. Decoder B drops its reference, destroying
IOSurfaceBackingEGLState. Its destructor attempts to executeglDeleteTexturesusing Decoder A's resurrected context. ANGLE generates aGL_CONTEXT_LOSTerror, firing the stale callback with the dangling pointer and executing the fake vtable.
MiraclePtr bypass
The vulnerability bypasses MiraclePtr/BackupRefPtr because the user_param is registered as a const void* within ANGLE's C API structure, crossing an FFI boundary where C++ smart pointers cannot protect it.
Suggested Fix
Ensure that the GL debug callback is unconditionally cleared during the destruction of the passthrough decoder, regardless of whether the context is considered lost.
In gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc, modify GLES2DecoderPassthroughImpl::Destroy:
// Unconditionally clear the debug callback to prevent UAF.
if (api()) {
api()->glDebugMessageCallbackKHRFn(nullptr, nullptr);
}
Evaluated with Chrome root at commit: f200f57a19490707ff8bc7aa5de3cbc443a3afad
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 decoder's Destroy path skips clearing the KHR_debug callback when the context is already lost, leaving a dangling user_param pointer in ANGLE's C API while a shared EGL state keeps the GL context alive.
Impact
An attacker who already controls a renderer could potentially achieve remote code execution in the GPU process, though the report is based on static analysis and has not been confirmed.
What the attacker needed
Compromised renderer; macOS; ability to induce a GPU reset
The fix
The debug callback should be cleared unconditionally during decoder destruction, regardless of whether the context is considered lost.
How it was found
- Create two WebGL contexts mapping to separate passthrough decoders in the GPU process.
- Import an IOSurface-backed SharedImage into the first decoder so its EGL state holds a strong reference to that decoder's GL context.
- Import the same SharedImage into the second decoder so it shares the same EGL state.
- Delete the texture in the first decoder and call WEBGL_lose_context to mark it lost.
- Destroy the first decoder, which skips unregistering the debug callback and leaves a dangling pointer.
- Spray the heap, induce a real GPU context loss, then delete the texture in the second decoder to fire the stale callback.
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 frees some memory but keeps a pointer to it, that is a use-after-free: later use of the pointer touches memory that may now hold something else. Here a graphics context was cleaned up but a callback registered with the graphics library still pointed at the freed object. If that callback fires later, the program can be tricked into running attacker-controlled 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.