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

Use after free in ANGLE (CVE-2026-9877)

A use-after-free write exists in ANGLE's EGL image creation because a deferred lambda captures a member variable by reference and runs after the global EGL lock is released. A concurrent thread can destroy the object and cause a write into freed memory, potentially leading to arbitrary read/write and sandbox escape.

Google Chrome

Originally disclosed on Chrome VRP

Critical View original
  • Fix shipped in 2 months

Project Fortify, an experimental security project, has identified the following potential security issue.

Overview: A potential Use-After-Free (UAF) write vulnerability exists in ANGLE's EGL image creation logic. A deferred lambda captures a member variable by reference and executes after the global EGL lock is released, allowing a concurrent thread to destroy the object and trigger a write into freed memory.

Affected files:

  • third_party/angle/src/libANGLE/renderer/gl/egl/ImageEGL.cpp
  • third_party/angle/src/libGLESv2/entry_points_egl_autogen.cpp
  • third_party/angle/src/libGLESv2/entry_points_egl_ext_autogen.cpp
  • third_party/angle/src/libANGLE/renderer/gl/egl/ImageEGL.h

Estimated timestamp from git blame: 2024-04-29

Vulnerability Details

In ANGLE's GL/EGL backend, ImageEGL::initialize defers the actual driver-level image creation using UnlockedTailCall to avoid holding the global EGL lock during potentially slow operations. The deferred lambda captures the mImage member variable by reference (&image = mImage):

C++
// third_party/angle/src/libANGLE/renderer/gl/egl/ImageEGL.cpp
egl::Display::GetCurrentThreadUnlockedTailCall()->add([egl = mEGL, &image = mImage, ...](void *resultOut) {
    image = egl->createImageKHR(context, target, buffer, attributes.data());
    // ...
});

In the autogenerated EGL entry points (e.g., EGL_CreateImage), the ANGLE_SCOPED_GLOBAL_LOCK() is released just before UnlockedTailCall::run() is invoked.

Because the newly created frontend egl::Image is inserted into the display's global mImageMap before the lock is released, it becomes visible to other threads. A concurrent thread can guess the predictable ImageID (allocated sequentially by HandleAllocator) and call eglDestroyImage. This destroys the egl::Image and its backend ImageEGL object, freeing its memory. When the original thread resumes and executes the tail call lambda, it writes the newly created 8-byte driver handle into the image reference, resulting in a Use-After-Free write.

Potential Trigger Steps

Note: These are suggested steps generated by an AI agent that does not have the ability to run or verify code. They represent a theoretical exploitation sequence.

  1. Predict ID: An attacker in the Renderer process predicts the next ImageID to be allocated, as ANGLE's HandleAllocator allocates IDs sequentially from 1.
  2. Trigger Creation: The attacker triggers an IPC call that invokes EGL_CreateImage on Thread A in the GPU process. Thread A allocates the object, queues the lambda, adds the image to mImageMap, and releases the global EGL lock.
  3. Concurrent Destruction: Before Thread A executes the tail call, the attacker uses a concurrent Web Worker to trigger eglDestroyImage on Thread B, providing the predicted ImageID.
  4. Free Memory: Thread B successfully acquires the lock, finds the image in mImageMap, and destroys it. The memory for ImageEGL (which falls into the 64-byte PartitionAlloc bucket) is freed.
  5. Heap Grooming: The attacker immediately allocates controlled data of the same size (e.g., by supplying a 16-element attribute list to another EGL function or using WebGL queries) to reclaim the freed 64-byte chunk.
  6. UAF Write: Thread A executes the pending UnlockedTailCall lambda. The native driver creates the EGL image and writes its 8-byte handle into the captured &image reference, corrupting the attacker's overlapping object.

Impact

This flaw provides a controlled 8-byte UAF write in the GPU process. An attacker can overlap the freed ImageEGL object with another object to overwrite a critical pointer or size field, leading to arbitrary read/write and potentially a sandbox escape (Remote Code Execution in the GPU process). MiraclePtr (BackupRefPtr) does not mitigate this because the dangling pointer is held as a native C++ reference inside the std::function closure.

Suggested Fix

There are a few ways to resolve this race condition:

  1. Extend Lifetime: Have the lambda capture a strong reference to the frontend egl::Image object to keep the ImageEGL backend object alive until the tail call completes.
  2. Avoid Reference Captures: Do not capture mImage by reference. Instead, have the tail call return the driver handle via the resultOut pointer, and let the caller assign it safely if the object still exists.
  3. Defer Map Insertion: Do not insert the newly created egl::Image into the global mImageMap until after the UnlockedTailCall has successfully finished executing.

Evaluated with Chrome root at commit: 0eb4855bda702feaaa8b899336664f97e3df88b8


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. Please feel free to reach out to me if you have concerns or feedback.

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 the deferred lambda captures the mImage member by reference and the frontend image is inserted into the global map before the lock is released, so another thread can destroy it before the lambda writes to the captured reference.

Impact

This flaw provides a controlled 8-byte UAF write in the GPU process, which could lead to arbitrary read/write and potentially a sandbox escape (Remote Code Execution in the GPU process).

What the attacker needed

Attacker in the Renderer process; ability to trigger EGL_CreateImage; concurrent Web Worker; predictable ImageID

The fix

The race condition should be fixed by extending the lifetime of the frontend image, avoiding reference captures, or deferring map insertion until after the tail call completes.

How it was found

  1. Predict the next ImageID to be allocated, since IDs are sequential.
  2. Trigger EGL_CreateImage on Thread A, which allocates the object, queues the lambda, adds it to the map, and releases the lock.
  3. Use a concurrent Web Worker to call eglDestroyImage on Thread B with the predicted ID before Thread A runs the tail call.
  4. Thread B destroys the image, freeing the ImageEGL memory in the 64-byte bucket.
  5. Heap groom by allocating controlled data of the same size to reclaim the freed chunk.
  6. Thread A executes the pending lambda, writing the 8-byte driver handle into the freed memory.

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 creates an image, it briefly unlocks a shared resource so other threads can run. One thread can then delete the image while the first thread still holds a pointer to it, and when the first thread writes to that pointer, it writes into memory that has been freed. This is called a use-after-free bug, and it can let an attacker control what gets written where.

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.