Out of bounds write in ANGLE (CVE-2026-79188)
A WebGL2 vertex shader can access gl_ClipDistance at a large index before redeclaring the array with a smaller size, causing ANGLE to emit SPIR-V with an out-of-bounds constant index into the Output storage class. In release builds this unvalidated SPIR-V reaches the Vulkan driver, potentially causing a GPU-process driver memory corruption.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 38 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. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: A WebGL2 vertex shader can trigger a potential out-of-bounds write in ANGLE by indexing gl_ClipDistance before redeclaring it with a smaller size. This creates two distinct AST variables, causing variable replacement to miss the original access and emit an out-of-bounds constant index into the Output storage class in SPIR-V. In release builds, this unvalidated SPIR-V reaches the Vulkan driver where robustBufferAccess does not protect output storage, leading to a potential GPU-process driver memory corruption.
Affected files:
third_party/angle/src/compiler/translator/tree_util/ReplaceClipCullDistanceVariable.cppthird_party/angle/src/compiler/translator/ParseContext.cppthird_party/angle/src/compiler/translator/ParseContext.hthird_party/angle/src/compiler/translator/tree_ops/DeclarePerVertexBlocks.cppthird_party/angle/src/compiler/translator/spirv/OutputSPIRV.cpp
Estimated timestamp from git blame: Unknown (Google3 checkout)
1. Summary of the Issue (Meant for Human Triage)
There is a potential out-of-bounds (OOB) write vulnerability in ANGLE's Vulkan backend caused by an identity mismatch during AST variable replacement. When a WebGL2 vertex shader accesses a built-in array like gl_ClipDistance textually before redeclaring it with a smaller, explicit size, ANGLE's parser instantiates two distinct TVariable objects: one for the implicit, larger global built-in array, and another for the user-redeclared array.
During the ReplaceClipCullDistanceVariable transformation pass, ANGLE attempts to replace references to the built-in array using strict pointer-identity checks. Because the pre-redeclaration access points to the original built-in TVariable and not the newly allocated redeclared TVariable, it survives the replacement pass. Subsequently, the DeclarePerVertexBlocks pass merges this surviving built-in symbol into the gl_PerVertex structure field, which was appropriately downsized to the redeclared size.
As a result, the code generator (OutputSPIRV) emits a direct index operation (EOpIndexDirect) using the original large constant index against the new, smaller output interface block array. In release builds, AST and SPIR-V validation are compiled out. This allows the spec-invalid SPIR-V to reach the Vulkan driver (vkCreateShaderModule). Because the Vulkan robustBufferAccess feature explicitly does not cover the Output storage class, this results in an unmitigated driver-level OOB write within the GPU process.
2. Proof-of-Concept & Detailed Execution Flow
Suggested Attacker Steps (Potential Proof-of-Concept): Note: Our tooling agent does not have the ability to run code, so these are suggested steps based on static analysis.
-
The attacker serves a malicious webpage containing a WebGL2 context that requests the
WEBGL_clip_cull_distanceextension. -
This extension is registered without a draft flag and is enabled by default on Vulkan backends if the physical device supports
shaderClipDistancewithmaxClipDistances >= 8(e.g.,third_party/blink/renderer/modules/webgl/webgl2_rendering_context.cc:106andlibANGLE/renderer/vulkan/vk_caps_utils.cpp:1300-1308). -
The attacker provides the following malicious vertex shader string that contains an early access to a large index of
gl_ClipDistance, followed by a redeclaration with a smaller size:GLSL #version 300 es #extension GL_ANGLE_clip_cull_distance : require void f() { gl_ClipDistance[7] = 1.0; } out highp float gl_ClipDistance[2]; void main() { f(); gl_ClipDistance[0] = 0.0; gl_Position = vec4(1); }
Detailed Execution Flow:
- Parsing Phase & Bounds Check: During parsing of the function
f(),parseVariableIdentifier(inthird_party/angle/src/compiler/translator/ParseContext.cpp) resolves the first accessgl_ClipDistance[7]. - Since the redeclared variable does not exist yet,
getNamedVariablesearches the symbol table and returns the implicit built-inTVariablem_gl_ClipDistance, which is defined with array sizeMaxClipDistances(e.g., 8) viathird_party/angle/src/compiler/translator/SymbolTable_autogen.cpp. - The parser performs an index bounds check for the direct index
[7]atParseContext.cpp:7276. It checks this against theTVariable's array size (baseExpression->getOutermostArraySize(), which is 8).checkIndexLessThan(7, 8)successfully passes. - Redeclaration & Tracking Gap: Later, the parser encounters the redeclaration:
out highp float gl_ClipDistance[2];. - In
ParseContext.cpp:2172,declareVariableprocesses this redeclaration and allocates a completely newTVariableinstance on the heap (new TVariable(...)) with array size 2. - The redeclaration logic calls
MarkClipCullRedeclaredSize(ParseContext.cpp:292-298), which setsinfo->size = 2directly, without validating it againstinfo->maxIndex(which is tracked as 7 from the earlier access). - The new
TVariable(size 2) is inserted into the symbol table viasymbolTable.declare(*variable)(ParseContext.cpp:2280), shadowing the built-in definition. - Bypassing Normalization: At the end of parsing,
TCompiler::compilesetsmClipDistanceSizeto 2 (Compiler.cpp:544) viaparseContext.getClipDistanceArraySize(). - At
Compiler.cpp:795-805, the translator checks whether to run theSizeClipCullDistancepass (which normalizes and resizes implicit built-in arrays). - Because
parseContext.isClipDistanceRedeclared()returnstrue(sincemClipDistanceInfo.size > 0), the condition short-circuits and theSizeClipCullDistancepass is skipped. - Pointer Identity Mismatch: The AST proceeds with two divergent
TVariablereferences.TranslatorSPIRV.cppinvokesReplaceClipDistanceAssignments->ReplaceClipCullDistanceAssignmentsImpl. - In
ReplaceClipCullDistanceVariable.cpp:508-513,builtInVaris strictly assigned the pointer of the user-redeclaredTVariable(builtInVar = &redeclaredBuiltIn->variable();). ReplaceVariableExceptOneTraverser::visitSymbol(ReplaceClipCullDistanceVariable.cpp:188-194) attempts to match nodes using pointer identity:if (&node->variable() == mToBeReplaced).- When the traverser visits
f()'sgl_ClipDistance[7],&node->variable()points to the implicit size-8TVariable, whilemToBeReplacedpoints to the new size-2TVariable. The identity check fails. The pre-redeclaration symbol node survives unmodified. - Per-Vertex Merging: The pipeline runs
DeclarePerVertexBlocksTraverser(tree_ops/DeclarePerVertexBlocks.cpp). It creates thegl_PerVertexblock with agl_ClipDistancefield sized to 2 (DeclarePerVertexBlocks.cpp:346-372). DeclarePerVertexBlocksTraverser::visitSymbol(DeclarePerVertexBlocks.cpp:227-274) encounters the survivingm_gl_ClipDistancenode. It matches by qualifier (EvqClipDistance) rather than pointer identity, successfully resolving it to field index 2 of thegl_PerVertexblock.- This generates an
EOpIndexDirectoperation where the base isgl_PerVertexfield 2 (typefloat[2]), but the direct index child node retains the original literal7. - Unvalidated SPIR-V Emission: During SPIR-V code generation,
OutputSPIRV::visitBinary(spirv/OutputSPIRV.cpp:5208-5219) processes theEOpIndexDirectnode. - The AST transformation
ClampIndirectIndices(tree_ops/ClampIndirectIndices.cpp:37-40) is explicitly bypassed because it only operates onEOpIndexIndirect(non-constant indices). visitBinaryextracts the constant literal 7 (OutputSPIRV.cpp:5207) and callsaccessChainOnPush(OutputSPIRV.cpp:808-830). Since the parent is an array type, it blindly accepts the literal index without any bounds checking or clamping.- The generator emits the literal index verbatim (
accessChainPushLiteral). The output module now contains anOpAccessChainwith a constant index of 7 accessing aOpTypeArray %float %uint_2inside theOutputstorage class. - Driver Sink Reached: In Chromium Release builds,
ANGLE_ENABLE_ASSERTSis disabled (third_party/angle/src/common/log_utils.h:209-211), meaningoptions.validateASTis false (libANGLE/Shader.cpp:666-668). - Because
validateASTis false, AST validation immediately returns true, andspirv::Validateis compiled out inside theASSERTmacro. - The spec-invalid SPIR-V is passed unvalidated to
vkCreateShaderModule. Under Vulkan spec,robustBufferAccessmitigates OOB writes onUniform,StorageBuffer, and vertex inputs, but does not cover theOutputstorage class, granting a driver-resident GPU memory out-of-bounds write primitive.
Suggested Fix:
To mitigate this issue, ensure that ANGLE correctly handles built-in array redeclarations that shrink the size of the array after it has been indexed. This can be resolved by modifying ParseContext.cpp inside MarkClipCullRedeclaredSize or during post-parse validation to emit a compilation error if the user-redeclared size is strictly less than the tracked maxIndex + 1. Alternatively, update ReplaceVariableExceptOneTraverser (ReplaceClipCullDistanceVariable.cpp:188) to match EvqClipDistance nodes by qualifier rather than strict pointer identity so the prior accesses are properly replaced or unified.
3. Technical Verification Details (Automated Audit Logs - Reviewers may skip this section)
Prior Critic Verdict:
"The vulnerability report correctly identifies an issue where ANGLE's SPIR-V translator emits an out-of-bounds
OpAccessChainwrite.
- By accessing
gl_ClipDistance[K]before redeclaring it with a smaller sizeN(whereN <= K < gl_MaxClipDistances), two distinctTVariableobjects exist in the AST.ReplaceClipCullDistanceVariablereplaces the redeclared variable using pointer identity (&node->variable() == mToBeReplaced), leaving the built-in variable referencing the larger array size in the AST.DeclarePerVertexBlocksprocesses the remaining built-in variable by qualifier (EvqClipDistance), converting it into an access to thegl_PerVertexblock's field2, which was sized toN.OutputSPIRVthen emitsOpAccessChainfor the constant indexKinto thefloat[N]array without any clamping, sinceClampIndirectIndicesonly handles non-constant indices.- In release builds,
spirv::ValidateandvalidateASTareASSERT-only. Thus, the spec-invalid SPIR-V containing the OOBOpStoreinto theOutputstorage class reachesvkCreateShaderModuleon the Vulkan backend.Severity Justification: High (S1). Per the security severity guidelines:
- "ANGLE shader translator emits SPIR-V/HLSL with an OOB OpAccessChain / array index from attacker GLSL ... The emitted IR reaches vkCreateShaderModule/D3DCompile in the GPU process. This is web-content-reachable (shader source is page-supplied). -> S1"
- The OOB write is in driver-managed GPU memory (vertex output storage) rather than Chrome's host memory heap. Therefore, it qualifies as High (S1) rather than Critical (S0), even on Android where the GPU process is unsandboxed.
- The report accurately notes that
robustBufferAccessdoes not cover theOutputstorage class, leaving the OOB write unmitigated in the driver."
Automated Execution Log / Code Reachability Proofs:
ParseContext.cpp:7276: Bounds check validates againstgetOutermostArraySize()(8). Verified by investigation ofTParseContext::addIndexExpressionandcheckIndexLessThan.ParseContext.cpp:2172:declareVariableallocatesnew TVariable(&symbolTable, identifier, type, symbolType);. Verified that pre-redeclaration accesses point to a different heap object than post-redeclaration accesses.ParseContext.cpp:292-298:MarkClipCullRedeclaredSizesetsinfo->size = arraySizewith no check againstinfo->maxIndex.Compiler.cpp:804:parseContext.isClipDistanceRedeclared()evaluates to true, skippingSizeClipCullDistance.ReplaceClipCullDistanceVariable.cpp:188-194: Pointer identity check&node->variable() == mToBeReplaced. Verified to fail for pre-redeclarationgl_ClipDistancesymbols.DeclarePerVertexBlocks.cpp:227-274: Merge by qualifier (variable->symbolType() == SymbolType::BuiltInandGetPerVertexFieldIndexmappingEvqClipDistanceto field 2).OutputSPIRV.cpp:5208-5219:EOpIndexDirecthandler. Extracting literal viagetAsConstantUnion()->getIConst(0), passing directly toaccessChainOnPushandaccessChainPushLiteralwith no bounds assertions.- Release Checks:
libANGLE/Shader.cpp:666-668andcommon/log_utils.h:209-211verify thatANGLE_ENABLE_ASSERTSdrivesvalidateAST. WithoutNDEBUGoverridden, it is false.Compiler.cpp:689-710skips validation if false.
Environmental Assumptions:
- Platform: Vulkan backend (default on Android, Linux, ChromeOS).
- Build Target: Chromium Release build where
ANGLE_ENABLE_ASSERTSis disabled, allowing bypassed AST validation. - Spec Design Reference: Vulkan
robustBufferAccessrestricts toUniform,StorageBuffer, and input attributes.Outputclass is explicitly unmanaged. SPIR-V Validation constraints (spirv-val) are bypassed as they run strictly in debug paths.
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 parser creates two separate variable objects for gl_ClipDistance when it is accessed before being redeclared with a smaller size, and the replacement pass matches by pointer identity so the earlier access survives and is later emitted with an out-of-bounds constant index.
Impact
Could cause a driver-level out-of-bounds write in GPU memory within the GPU process; robustBufferAccess does not cover the Output storage class, so the write is unmitigated.
What the attacker needed
Vulkan backend with clip distance support; Release build without AST validation; Victim loads a malicious webpage
The fix
Should be fixed by rejecting a redeclaration whose size is smaller than the highest index already used, or by matching clip-distance nodes by qualifier rather than pointer identity.
How it was found
- Serve a malicious webpage that creates a WebGL2 context and requests the WEBGL_clip_cull_distance extension.
- Provide a vertex shader that accesses gl_ClipDistance at a large index before redeclaring it with a smaller size.
- The shader is compiled and the invalid SPIR-V reaches the Vulkan driver in release builds.
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.
WebGL lets web pages run small programs on the graphics card. ANGLE translates these programs into a form the graphics driver understands. A bug in that translation can produce an instruction that writes past the end of an array, and the driver may not stop it, which could corrupt graphics memory.
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.