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.cppthird_party/angle/src/libANGLE/renderer/gl/StateManagerGL.hthird_party/angle/src/libANGLE/renderer/gl/BlitGL.cppthird_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:
const q = gl.createQuery();
gl.beginQuery(gl.ANY_SAMPLES_PASSED, q);
- In the backend,
StandardQueryGL::beginregisters the query:mQueries[AnySamples]points to theStandardQueryGLinstance (qGL), andqGL->mActiveQueryholds 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:
gl.generateMipmap(gl.TEXTURE_2D);
- Execution enters
BlitGL::generateMipmap(third_party/angle/src/libANGLE/renderer/gl/BlitGL.cpp:1231). - A
ScopedGLState scopedState;is instantiated, andscopedState.enter(...)is called. - This invokes
StateManagerGL::pauseAllQueries(context)(StateManagerGL.cpp:810). - For the active query,
previousQuery->pause(context)is called. InsideStandardQueryGL::pause(QueryGL.cpp:159),qGL->mActiveQueryis set to0. - 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_CHECKexecutestexImage2D(line 1287). - If the driver returns an error (e.g.,
GL_OUT_OF_MEMORY),CheckErrorreturnsangle::Result::Stop(renderergl_utils.cpp:3236). - The macro triggers an early return from
BlitGL::generateMipmap, completely skippingscopedState.exit(context)at line 1316. ~ScopedGLState(BlitGL.cpp:76) runs but only executesASSERT(mExited), doing nothing in release builds. The pointerqGLis left inmTemporaryPausedQueries.
Step 4: Query Deletion and Dangling Pointer Creation
The application deletes the query:
gl.endQuery(gl.ANY_SAMPLES_PASSED);
gl.deleteQuery(q);
endQuery()is a no-op on the backend becausemActiveQueryis0.- The query is deleted, invoking
StandardQueryGL::~StandardQueryGL()(QueryGL.cpp:70). - This calls
clearInternalQueries(). BecausemActiveQuerywas set to0in Step 2, the conditionif (mActiveQuery != 0)is false. - The code completely skips calling
mStateManager->endQuery(...). The object is freed, butmTemporaryPausedQueries[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. SincemQueries[AnySamples]is nownullptr, 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
- Modify
~ScopedGLStateto properly clean up in release builds if!mExited. It should notify theStateManagerGLto clearmTemporaryPausedQueriesif an early exit occurred. - Alternatively, ensure
StateManagerGL::onMakeCurrentclearsmTemporaryPausedQueriesunconditionally, not just in debug builds. - Change
mTemporaryPausedQueriesto 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::mTemporaryPausedQuerieswithin ANGLE's GL backend (third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp). When a query is paused byScopedGLState::enter(e.g., duringBlitGL::generateMipmap), a raw pointer to it is stashed inmTemporaryPausedQueries. If a subsequent driver call likeglTexImage2Dfails (which can be forced viaGL_OUT_OF_MEMORY),ANGLE_GL_TRY_ALWAYS_CHECKreturnsStop, skippingScopedGLState::exitand leaving the raw pointer dangling in the registry. Upon query deletion,~StandardQueryGLdoes not unregister itself because itsmActiveQuerywas cleared to 0. A subsequent successfulgenerateMipmapcall from a surviving context (sinceStateManagerGLis shared per virtualization group) will hitresumeAllQueriesand 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, themTemporaryPausedQueriesarray 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:576definesmTemporaryPausedQueriesas anangle::PackedEnumMap<gl::QueryType, QueryGL *>(bare pointer). - Destructor Missing Release Cleanup:
third_party/angle/src/libANGLE/renderer/gl/BlitGL.cpp:76shows~ScopedGLState() { ASSERT(mExited); }. - Early Exit Mechanism:
third_party/angle/src/libANGLE/renderer/gl/renderergl_utils.h:100-102definesANGLE_GL_TRY_ALWAYS_CHECKwhich callsCheckError.renderergl_utils.cpp:3211-3240showsHandleErrorreturningangle::Result::Stoponerror != GL_NO_ERROR. - Skipped Exit:
third_party/angle/src/libANGLE/renderer/gl/BlitGL.cpp:1287-1316demonstratesANGLE_GL_TRY_ALWAYS_CHECKinside the mipmap loop, followed byANGLE_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-167showsmActiveQuery = 0;duringpause(). - Query Deletion Bypass:
third_party/angle/src/libANGLE/renderer/gl/QueryGL.cpp:75-83showsclearInternalQueries()only callsmStateManager->endQuery(...)ifmActiveQuery != 0. - UAF Sink:
third_party/angle/src/libANGLE/renderer/gl/StateManagerGL.cpp:841-853showsresumeAllQueriesdereferencing the pointer and callingANGLE_TRY(pausedQuery->resume(context));. - Cross-Context Sharing:
third_party/angle/src/libANGLE/renderer/gl/egl/DisplayEGL.cpp:534-558andui/gl/gl_context_egl.cc:348verifyRendererEGL(and thusStateManagerGL) is shared perEGL_CONTEXT_VIRTUALIZATION_GROUP_ANGLE. - Android Unsandboxed GPU: As per
docs/security/process-sandboxes-by-platform.mdand 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.
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
- Create a WebGL2 query and begin it.
- Trigger mipmap generation that causes a driver error, pausing the query and stashing its pointer.
- The error causes an early return, skipping cleanup and leaving the pointer dangling.
- Delete the query, which does not unregister itself because its active state was cleared.
- 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.