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

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

A use-after-free exists in ANGLE's GL backend because an early return on a driver error skips cleanup of a paused query pointer. An attacker could potentially trigger a virtual call on freed memory, leading to memory corruption in the GPU process.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 2 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. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.

Overview: A potential Use-After-Free (UAF) vulnerability exists in ANGLE's GL backend because an early return on driver errors in BlitGL::generateMipmap skips ScopedGLState cleanup. This can leave a dangling QueryGL pointer in StateManagerGL::mTemporaryPausedQueries, leading to a UAF virtual call when the state is later resumed.

Affected files:

  • third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp
  • third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.h
  • third_party/angle/src/libANGLE/renderer/gl/BlitGL.cpp
  • third_party/angle/src/libANGLE/renderer/gl/QueryGL.cpp

Estimated timestamp from git blame: 2018-02-05

1. Summary of the Issue (Meant for Human Triage)

A potential Use-After-Free (UAF) vulnerability exists in the ANGLE OpenGL ES backend (which ships as a default or fallback on Android) within StateManagerGL::mTemporaryPausedQueries. During complex operations like intermediate mipmap generation in BlitGL::generateMipmap, currently running WebGL queries are temporarily paused using a ScopedGLState helper. This helper stashes raw pointers to the queries in mTemporaryPausedQueries via pauseAllQueries().

If a driver error (such as GL_OUT_OF_MEMORY or GL_INVALID_VALUE) occurs mid-scope, an early return via the ANGLE_GL_TRY_ALWAYS_CHECK macro bypasses the ScopedGLState::exit() call. Because the ~ScopedGLState destructor only contains a debug-only ASSERT(mExited) and performs no cleanup in release builds, the raw pointers remain dangling in the state manager's registry.

If the frontend WebGL query is subsequently deleted by the application, its backend destructor (~StandardQueryGL) fails to unregister itself from StateManagerGL because its active state was cleared to zero during the pause phase. A subsequent successful mipmap generation or state resume operation will call resumeAllQueries(), which retrieves the dangling pointer and invokes a virtual method (->resume()) on the deleted QueryGL object. In an unsandboxed GPU process environment (like Android), this memory corruption could potentially allow for a sandbox escape if the freed memory is reclaimed by an attacker.


2. Proof-of-Concept & Detailed Execution Flow

Note: The following steps describe a potential theoretical trigger path based on code analysis. Our tooling agent does not have the ability to run code or provide functional exploit primitives (like heap grooming).

Step 1: Query Creation and Registration

A WebGL2 application begins a query:

JavaScript
const q = gl.createQuery();
gl.beginQuery(gl.ANY_SAMPLES_PASSED, q);
  • In the backend, StandardQueryGL::begin registers the query: mQueries[AnySamples] points to the StandardQueryGL instance (qGL), and qGL->mActiveQuery holds the native GL query ID.

Step 2: Query Pausing and Stashing

The application triggers a mipmap generation on a texture configured to elicit a driver error during intermediate allocation:

JavaScript
gl.generateMipmap(gl.TEXTURE_2D);
  • Execution enters BlitGL::generateMipmap (third_party/angle/src/libANGLE/renderer/gl/BlitGL.cpp:1231).
  • A ScopedGLState scopedState; is instantiated, and scopedState.enter(...) is called.
  • This invokes StateManagerGL::pauseAllQueries(context) (StateManagerGL.cpp:810).
  • For the active query, previousQuery->pause(context) is called. Inside StandardQueryGL::pause (QueryGL.cpp:159), qGL->mActiveQuery is set to 0.
  • The raw pointer is stashed: mTemporaryPausedQueries[type] = previousQuery; (StateManagerGL.cpp:819).
  • The main registry is cleared: mQueries[type] = nullptr;.

Step 3: Mid-Scope Early Exit

  • During the mipmap generation loop (BlitGL.cpp:1280), ANGLE_GL_TRY_ALWAYS_CHECK executes texImage2D (line 1287).
  • If the driver returns an error (e.g., GL_OUT_OF_MEMORY), CheckError returns angle::Result::Stop (renderergl_utils.cpp:3236).
  • The macro triggers an early return from BlitGL::generateMipmap, completely skipping scopedState.exit(context) at line 1316.
  • ~ScopedGLState (BlitGL.cpp:76) runs but only executes ASSERT(mExited), doing nothing in release builds. The pointer qGL is left in mTemporaryPausedQueries.

Step 4: Query Deletion and Dangling Pointer Creation

The application deletes the query:

JavaScript
gl.endQuery(gl.ANY_SAMPLES_PASSED);
gl.deleteQuery(q);
  • endQuery() is a no-op on the backend because mActiveQuery is 0.
  • The query is deleted, invoking StandardQueryGL::~StandardQueryGL() (QueryGL.cpp:70).
  • This calls clearInternalQueries(). Because mActiveQuery was set to 0 in Step 2, the condition if (mActiveQuery != 0) is false.
  • The code completely skips calling mStateManager->endQuery(...). The object is freed, but mTemporaryPausedQueries[AnySamples] still points to its memory address.

Step 5: Triggering the Use-After-Free

The application could potentially reclaim the freed memory (e.g., via texture uploads) and then trigger another successful generateMipmap call:

  • scopedState.enter() runs. Since mQueries[AnySamples] is now nullptr, the stash is not overwritten.
  • The mipmap generation succeeds, and scopedState.exit(context) is called.
  • StateManagerGL::resumeAllQueries (StateManagerGL.cpp:841) retrieves the dangling pointer: QueryGL *pausedQuery = mTemporaryPausedQueries[type];.
  • It executes ANGLE_TRY(pausedQuery->resume(context));. This is a virtual call on a deleted object, leading to a Use-After-Free.

(Note: This cross-context variant works even if the original OOM caused a context loss, because StateManagerGL is owned by RendererEGL which is shared across all contexts in the same virtual group).

Suggested Fix

  1. Modify ~ScopedGLState to properly clean up in release builds if !mExited. It should notify the StateManagerGL to clear mTemporaryPausedQueries if an early exit occurred.
  2. Alternatively, ensure StateManagerGL::onMakeCurrent clears mTemporaryPausedQueries unconditionally, not just in debug builds.
  3. Change mTemporaryPausedQueries to hold safe references or IDs rather than bare raw pointers, or integrate it with MiraclePtr (raw_ptr<T>) if feasible within the ANGLE architecture.

3. Technical Verification Details (Automated Audit Logs)

Critic Verdict Verbatim

The report describes a UAF in StateManagerGL::mTemporaryPausedQueries within ANGLE's GL backend (third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp). When a query is paused by ScopedGLState::enter (e.g., during BlitGL::generateMipmap), a raw pointer to it is stashed in mTemporaryPausedQueries. If a subsequent driver call like glTexImage2D fails (which can be forced via GL_OUT_OF_MEMORY), ANGLE_GL_TRY_ALWAYS_CHECK returns Stop, skipping ScopedGLState::exit and leaving the raw pointer dangling in the registry. Upon query deletion, ~StandardQueryGL does not unregister itself because its mActiveQuery was cleared to 0. A subsequent successful generateMipmap call from a surviving context (since StateManagerGL is shared per virtualization group) will hit resumeAllQueries and invoke a virtual call (pausedQuery->resume) on the freed object. This is a GPU-process memory corruption (UAF with virtual dispatch, giving execution control) reachable by web content alone (A-SERVER) via standard WebGL2 API calls. As the ANGLE GL backend ships as a fallback/default on Android where the GPU process is unsandboxed, this is a sandbox escape. Furthermore, the mTemporaryPausedQueries array holds bare pointers and is not MiraclePtr-protected. Per the severity guidelines, an A-SERVER-reachable GPU-process UAF-write on Android is Critical (S0).

Verified Code Locations and State Flows

  • Registry Definition: third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.h:576 defines mTemporaryPausedQueries as an angle::PackedEnumMap<gl::QueryType, QueryGL *> (bare pointer).
  • Destructor Missing Release Cleanup: third_party/angle/src/libANGLE/renderer/gl/BlitGL.cpp:76 shows ~ScopedGLState() { ASSERT(mExited); }.
  • Early Exit Mechanism: third_party/angle/src/libANGLE/renderer/gl/renderergl_utils.h:100-102 defines ANGLE_GL_TRY_ALWAYS_CHECK which calls CheckError. renderergl_utils.cpp:3211-3240 shows HandleError returning angle::Result::Stop on error != GL_NO_ERROR.
  • Skipped Exit: third_party/angle/src/libANGLE/renderer/gl/BlitGL.cpp:1287-1316 demonstrates ANGLE_GL_TRY_ALWAYS_CHECK inside the mipmap loop, followed by ANGLE_TRY(scopedState.exit(context)); at the end, confirming the early return skips the exit.
  • Query Zeroing: third_party/angle/src/libANGLE/renderer/gl/QueryGL.cpp:159-167 shows mActiveQuery = 0; during pause().
  • Query Deletion Bypass: third_party/angle/src/libANGLE/renderer/gl/QueryGL.cpp:75-83 shows clearInternalQueries() only calls mStateManager->endQuery(...) if mActiveQuery != 0.
  • UAF Sink: third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp:841-853 shows resumeAllQueries dereferencing the pointer and calling ANGLE_TRY(pausedQuery->resume(context));.
  • Cross-Context Sharing: third_party/angle/src/libANGLE/renderer/gl/egl/DisplayEGL.cpp:534-558 and ui/gl/gl_context_egl.cc:348 verify RendererEGL (and thus StateManagerGL) is shared per EGL_CONTEXT_VIRTUALIZATION_GROUP_ANGLE.
  • Android Unsandboxed GPU: As per docs/security/process-sandboxes-by-platform.md and the severity guidelines, the GPU process is unsandboxed on Android.

Evaluated with Chrome root at commit: b96d2ec58f4f5f92b540a723966b199d6e9951b4


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.

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 destructor of ScopedGLState only asserts in debug builds and does not clean up the temporary paused query registry on early exit, leaving a dangling pointer.

Impact

This memory corruption could potentially allow for a sandbox escape on Android where the GPU process is unsandboxed, if the freed memory is reclaimed by an attacker.

What the attacker needed

WebGL2 support; Ability to trigger driver error; Android platform (unsandboxed GPU)

The fix

The destructor of ScopedGLState should perform cleanup in release builds if not exited, or the temporary paused queries should be cleared unconditionally on context switch, or use safe references instead of raw pointers.

How it was found

  1. Create a WebGL2 query and begin it.
  2. Trigger mipmap generation that causes a driver error, pausing the query and stashing its pointer.
  3. The error causes an early return, skipping cleanup and leaving the pointer dangling.
  4. Delete the query, which does not unregister itself because its active state was cleared.
  5. Trigger another successful mipmap generation to resume queries, causing a virtual call on the freed pointer.

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 keeps a pointer to memory it has already freed and later uses it. Here, a WebGL query is paused and its address is stored, but an error causes the cleanup to be skipped, so the address is left pointing to freed memory. When that memory is later used, it can crash or be exploited.

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.