Out of bounds memory access in ANGLE (CVE-2026-17801)
A logic flaw in ANGLE's shader translator means loop-based indirect indices into gl_FragData are not counted when dual-source blending is active, so the parser's size check passes. The generated backend shader then declares a one-element output array but clamps accesses to a range of eight, giving out-of-bounds GPU memory reads and writes that could potentially lead to a sandbox escape on platforms with an unsandboxed GPU process.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 2 months
Flapjack, 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 logic flaw in ANGLE's shader translator allows loop-based indirect indices to bypass array size tracking for gl_FragData when dual-source blending is active. This leads to incorrect clamping bounds being injected into the AST, resulting in potential out-of-bounds shader accesses in backend compilers like Metal or SPIR-V. On platforms with an unsandboxed GPU process (such as Android), this could potentially facilitate a sandbox escape.
Affected files:
third_party/angle/src/compiler/translator/ParseContext.cppthird_party/angle/src/compiler/translator/tree_ops/ClampIndirectIndices.cppthird_party/angle/src/compiler/translator/tree_ops/spirv/EmulateFragColorData.cppthird_party/angle/src/compiler/translator/msl/TranslatorMSL.cpp
Estimated timestamp from git blame: 2023-02-02
Background
In ANGLE, the gl_FragData built-in array typically has a size of MaxDrawBuffers (e.g., 8). However, when a shader uses the GL_EXT_blend_func_extended extension for dual-source blending (indicated by statically using gl_SecondaryFragDataEXT), the maximum number of draw buffers is reduced to MaxDualSourceDrawBuffers (typically 1).
Vulnerability Details
There is a potential vulnerability resulting from a mismatch between index validation, AST clamping, and backend code generation in ANGLE's translator:
- Validation Bypass: In
third_party/angle/src/compiler/translator/ParseContext.cpp(TParseContext::addIndexExpression), the variablemMaxFragDataArrayIndexUsedtracks the highest index used to accessgl_FragData. However, this tracker is only updated when the index is a literal constant (indexConstantUnionis non-null). In ESSL 100, loop indices are validconstant-index-expressions, meaning they are successfully compiled but bypass this tracking. Consequently,TParseContext::validateShaderLayoutincorrectly evaluatesmMaxFragDataArrayIndexUsed >= mResources.MaxDualSourceDrawBuffersas false (since it remains 0). - Incorrect AST Clamping: The AST transformation pass
ClampIndirectIndicesinjects clamping bounds for indirect array accesses. It determines the clamp range by querying the array type's size (ClampIndirectIndices.cpp:71). At this stage,gl_FragDatais still sized toMaxDrawBuffers(8). Therefore, the loop index is clamped to[0, 7]. - Backend Array Downsizing: Backend code generators (like
TranslatorMSL.cppfor Metal andEmulateFragColorData.cppfor SPIR-V) detect the dual-source blending state and shrink the actual outputgl_FragDataarray toMaxDualSourceDrawBuffers(1).
This sequence causes ANGLE to generate backend shader code (e.g., MSL) that declares an array of size 1, but accesses it using indices clamped to [0, 7] (e.g., gl_FragData[clamp(i, 0, 7)]).
Potential Impact
When the shader executes on the GPU, indices 1 through 7 will access memory outside the bounds of the generated output array. This provides an Out-of-Bounds (OOB) read/write primitive within the GPU's execution context. Because the GPU process is unsandboxed on platforms like Android, corrupting driver structures via shader memory could potentially lead to a sandbox escape and arbitrary code execution.
Suggested Attacker Steps
(Note: Our tooling agent cannot run code, so these are theoretical steps to trigger the issue.)
- Create a WebGL context and enable the
WEBGL_draw_buffersandEXT_blend_func_extendedextensions. - Provide a malicious ESSL 100 fragment shader that enables
GL_EXT_draw_buffersandGL_EXT_blend_func_extended. - Statically use
gl_SecondaryFragDataEXTin the shader (e.g., write togl_SecondaryFragDataEXT[0]) to force ANGLE into dual-source blending mode. - Write a
forloop that iterates from 0 to 7. Inside the loop, use the loop variable to index and write togl_FragData(e.g.,gl_FragData[i] = vec4(1.0);). - Compile the shader and issue a draw call to execute the OOB writes on the GPU.
Suggested Fix
- Parser Fix: Update the logic in
TParseContext::addIndexExpressionto correctly track or reject loop indices forgl_FragDatawhenGL_EXT_blend_func_extendedis active. If the index is not a literal constant, the parser should either determine the maximum loop bound or defensively flag it as potentially exceedingMaxDualSourceDrawBuffers. - Clamping Fix: Update
ClampIndirectIndicesto evaluate the effective runtime size of built-in output arrays taking active extensions into account, rather than relying exclusively on the symbol's initial type dimensions.
Evaluated with Chrome root at commit: b7d0c4d810da1b31400f198c70d9720fc8f0e5a0
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 parser only records the highest gl_FragData index when it is a literal constant, so loop indices bypass the dual-source draw-buffer limit check, while the clamping pass and the backends disagree on the array's effective size.
Impact
Indices beyond the array could read and write GPU memory, and on platforms with an unsandboxed GPU process such as Android this could potentially lead to a sandbox escape and arbitrary code execution; the steps are theoretical and were not executed.
What the attacker needed
WebGL with draw buffers and dual-source blending; Attacker-controlled shader compiled by ANGLE; Unsandboxed GPU process for escape impact
The fix
The parser should track or reject non-constant loop indices for gl_FragData when dual-source blending is active, and the clamping pass should use the effective runtime size of built-in output arrays rather than the symbol's initial type dimensions.
How it was found
- Create a WebGL context and enable the draw buffers and dual-source blending extensions.
- Supply a fragment shader that enables both extensions and statically uses the secondary fragment data output to force dual-source blending mode.
- Add a loop from 0 to 7 that indexes gl_FragData with the loop variable and writes to it.
- Compile the shader and issue a draw call so the out-of-bounds writes execute on the GPU.
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.
Shaders are small programs that run on the graphics card. ANGLE is the layer that translates them for different graphics backends. Here a check on how many output slots a shader uses was skipped for loop counters, so the translated program could write past the end of a small array in graphics memory, which on some systems might let an attacker break out of the browser's protection.
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.