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

Out of bounds write in ANGLE (CVE-2026-79048)

ANGLE's HLSL translator emits an out-of-bounds array access when a WebGL 1 shader dynamically indexes gl_FragData without enabling GL_EXT_draw_buffers, because the AST retains a size of 8 while the emitted array has size 1. An attacker could serve a web page that compiles such a shader, potentially causing memory corruption in the sandboxed GPU process via D3DCompile.

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: ANGLE's HLSL translator generates out-of-bounds array accesses in emitted HLSL when a WebGL 1 shader dynamically indexes gl_FragData without enabling GL_EXT_draw_buffers. The translator declares a size-1 array but clamps dynamic indices to [0, 7], allowing out-of-bounds index writes to be passed to D3DCompile. This exposes the sandboxed GPU process to potential memory corruption within the shader compiler.

Affected files:

  • third_party/angle/src/compiler/translator/hlsl/OutputHLSL.cpp

Estimated timestamp from git blame: 2013-06-20

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

An issue in ANGLE's D3D11 HLSL translator allows untrusted shaders (e.g., from WebGL 1 content) to cause out-of-bounds array writes in generated HLSL code, which is then passed directly to the D3DCompile API in the sandboxed GPU process.

When an ESSL 1.00 shader dynamically indexes gl_FragData without enabling the GL_EXT_draw_buffers extension, the OutputHLSL generator declares the backing static array gl_Color with a size of 1. However, the AST representation of gl_FragData maintains an array size equal to the backend's MaxDrawBuffers (which is 8 on D3D11). Consequently, the ClampIndirectIndices pass clamps the indirect access index to the range [0, 7] instead of [0, 0].

When this HLSL is emitted, it results in code like gl_Color[clamped_index] = ... where clamped_index can be up to 7 while gl_Color has a size of only 1. This malformed HLSL is sent to D3DCompile, exposing the underlying text-based shader compiler to memory corruption within the sandboxed GPU process on Windows (High Severity / S1).

2. Proof-of-Concept & Detailed Execution Flow

Potential Trigger Path (WebGL 1): An attacker can trigger this vulnerability by serving a web page that creates a WebGL 1 context and compiles a specific fragment shader:

JavaScript
const gl = canvas.getContext('webgl');
const fs = gl.createShader(gl.FRAGMENT_SHADER);
// The shader uses a dynamic loop index to access gl_FragData without enabling GL_EXT_draw_buffers
gl.shaderSource(fs,
  'precision mediump float;\n' +
  'uniform sampler2D s; varying vec2 v;\n' +
  'void main(){\n' +
  '  for(int i=0;i<8;i++)\n' +
  '    gl_FragData[i] = texture2D(s, v);\n' +
  '}');
gl.compileShader(fs);

(Note: These are potential steps to trigger the vulnerability based on static code analysis; our tooling has not executed this code.)

Detailed Step-by-Step Execution Trace:

  1. Attacker Setup: The attacker serves a web page that creates a WebGL 1 context (gl = canvas.getContext('webgl')) and supplies a fragment shader.
  2. Shader Characteristics: The attacker's shader dynamically indexes the built-in output array gl_FragData using a loop counter variable (e.g., gl_FragData[i]).
  3. Extension Omission: Crucially, the attacker does not enable the multiple render targets extension in the shader source (i.e., they omit #extension GL_EXT_draw_buffers : enable).
  4. Context Initialization: When the context is initialized on the D3D11 backend (Windows), libANGLE/renderer/d3d/d3d11/renderer11_utils.cpp:1148 sets caps->maxDrawBuffers to GetMaximumSimultaneousRenderTargets(), which is 8 on feature level 10+.
  5. Context Extensions: Additionally, :1305 sets extensions->drawBuffersEXT to true because the underlying hardware supports it, even though the shader hasn't explicitly enabled it.
  6. Compiler Initialization: In libANGLE/Compiler.cpp:67, mResources.MaxDrawBuffers is initialized to caps.maxDrawBuffers (8). The fallback to 1 at :247 (which checks !extensions.drawBuffersEXT) is skipped because the hardware extension is enabled. Thus, resources.MaxDrawBuffers remains 8.
  7. Type Assignment: When the ANGLE parser runs (third_party/angle/src/compiler/translator/SymbolTable_autogen.cpp:23784), it initializes the AST type for gl_FragData. Because it is WebGL 1 (SH_WEBGL_SPEC), it sets the array size to resources.MaxDrawBuffers, which is 8.
  8. Constant Index Check: The attacker's dynamic index i passes the WebGL 1 ESSL 100 constant-index validation (ParseContext::checkESSL100ConstantIndex at ParseContext.cpp:4123) because it is a loop counter (permitted per Appendix A). The AST node EOpIndexIndirect is successfully created.
  9. Built-in Desync Flaw: During the first use of gl_FragData, TParseContext::declareBuiltInOnFirstUse (ParseContext.cpp:3469) is called. It checks if the EXT_draw_buffers extension is enabled in the shader. Since it isn't, it creates a new type with size 1 (:3494) to declare the variable in the IR builder. However, it fails to mutate the TType on the original TVariable. The AST TIntermSymbol for gl_FragData retains the original array size of 8.
  10. AST Clamping Pass: After parsing, ANGLE runs the ClampIndirectIndices pass over the AST to enforce bounds-checking on dynamic array accesses (Compiler.cpp:1041).
  11. Clamp Bound Evaluation: ClampIndirectIndicesTraverser examines the gl_FragData node. It calls leftType.getOutermostArraySize() (tree_ops/ClampIndirectIndices.cpp:74), which reads the size from the unmodified TIntermSymbol type. This evaluates to 8.
  12. Clamp Insertion: The pass clamps the dynamic index to arraySize - 1 (:82). The AST for i is replaced with int(clamp(float(i), 0.0, 7.0)).
  13. HLSL Header Generation: The clamped AST is handed to OutputHLSL to generate the D3D11 HLSL string. In the header generation (OutputHLSL.cpp:696), it checks IsExtensionEnabled(..., TExtension::EXT_draw_buffers) for the shader. Since it's false, numColorValues evaluates to 1.
  14. OOB Declaration: OutputHLSL emits the static backing array for gl_FragData named gl_Color: static float4 gl_Color[1] = ... (OutputHLSL.cpp:698).
  15. HLSL Body Generation: OutputHLSL traverses the AST body. It emits gl_Color for EvqFragData (OutputHLSL.cpp:1195) and emits the clamped index for the array access.
  16. Malformed Array Access: The resulting HLSL statement emitted is gl_Color[int(clamp(float(_i), 0.0, 7.0))] = ..., demonstrating an out-of-bounds access up to index 7 on the size-1 array gl_Color.
  17. HLSL Compilation: This malformed HLSL string is dispatched to D3DCompile in the GPU process (libANGLE/renderer/d3d/HLSLCompiler.cpp).
  18. Unrolling Prevention: To prevent static analysis from folding the loop and emitting an X3504 compile-time error, Renderer11.cpp:3108 unconditionally passes the macro ANGLE_ENABLE_LOOP_FLATTEN=1 to D3DCompile, which expands LOOP to [loop].
  19. Vulnerability Realized: D3DCompile is forced to parse, optimize, and compile a dynamic out-of-bounds array write into a static size-1 array. Per the Knowledge Base, feeding such out-of-bounds arrays to D3DCompile from attacker GLSL is an established vector for triggering memory corruption within the text-based shader compiler itself (running inside the sandboxed GPU process).

Suggested Fix: In third_party/angle/src/compiler/translator/ParseContext.cpp, declareBuiltInOnFirstUse should correctly propagate the shrunken array size to the TVariable or TIntermSymbol nodes when EXT_draw_buffers is missing. Alternatively, ClampIndirectIndices should correctly account for the runtime-declared size of gl_FragData based on extension presence, rather than unconditionally trusting the MaxDrawBuffers-sized AST type.

3. Technical Verification Details (Automated Audit Logs - Reviewers may skip this section)

Prior Critic Verdict Verbatim:

The report identifies a bug where ANGLE's translator generates HLSL with an out-of-bounds array access. In WebGL 1, when a shader dynamically indexes gl_FragData[i] without the GL_EXT_draw_buffers extension, OutputHLSL declares gl_Color with size 1. However, the AST node retains its array size of 8 (MaxDrawBuffers), causing the ClampIndirectIndices pass to only clamp the index to [0, 7]. This results in the emitted HLSL accessing up to index 7 on a size-1 array, which is then handed to D3DCompile.

The AI rewriter incorrectly downgraded the severity from High to Medium (S2) by arguing that the runtime execution of the resulting DXBC is bounded to shader-local registers per the D3D11.3 spec, and therefore doesn't corrupt host memory.

However, this overlooks the explicit rule in the Knowledge Base under High Severity (S1): 'ANGLE shader translator emits SPIR-V/HLSL with an OOB OpAccessChain / array index from attacker GLSL (built-in redeclared with a smaller size, ClampIndirectIndices pass not run for a backend, constant-fold past declared bound). The emitted IR reaches vkCreateShaderModule/D3DCompile in the GPU process. This is web-content-reachable.'

Our finding is an exact match for this S1 rule (a built-in redeclared with a smaller size resulting in an OOB array index in the HLSL fed to D3DCompile). The vulnerability is that the text-based shader compiler (D3DCompile) is forced to parse and optimize malformed arrays, which is a known vector for triggering memory corruption within the compiler itself (running in the GPU process).

Because D3D11 is Windows-only, the GPU process is sandboxed, so this avoids the Critical (S0) rating applied to unsandboxed Android GPU issues, and correctly caps at High (S1).

Mitigations / Validators Checked:

  • ANGLE_ENABLE_LOOP_FLATTEN: This is unconditionally passed as "1" to D3DCompile inside Renderer11.cpp:3108 which confirms that LOOP expands to [loop] and forces the compiler to parse dynamic indices without compile-time folding.
  • D3DCompile OOB Memory Limits: While runtime bounds might be constrained by DXBC specifications, parsing and optimization of such OOB indices in the HLSL compiler frontend or optimizer represents a high-risk attack surface within the GPU process.
  • WebGL 2 Check (ParseContext.cpp:7169): This check only prevents dynamic gl_FragData[i] in WebGL 2 contexts, leaving WebGL 1 contexts fully vulnerable to this out-of-bounds code generation.
  • ClampIndirectIndices Enforcement: Verified that isWebGL() || isHardenedContext() enforces the execution of the clamp pass (ShaderD3D.cpp:289-293), leading directly to the 7.0 max bound.

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 built-in gl_FragData is declared with a smaller array size in the emitted HLSL but the AST type used by the clamping pass still reports the larger MaxDrawBuffers size, so the index is clamped to the wrong range.

Impact

This could cause memory corruption within the sandboxed GPU process on Windows, but the report notes the GPU process is sandboxed and the trigger is based on static analysis, not execution.

What the attacker needed

Victim visits a malicious web page; browser uses ANGLE with D3D11 backend; WebGL 1 context is available

The fix

The built-in declaration should propagate the shrunken array size to the variable and symbol nodes, or the clamping pass should use the runtime-declared size of gl_FragData based on extension presence.

How it was found

  1. Serve a web page that creates a WebGL 1 context and supplies a fragment shader.
  2. The shader dynamically indexes gl_FragData using a loop counter.
  3. The shader does not enable the GL_EXT_draw_buffers extension.
  4. On the D3D11 backend, the context sets maxDrawBuffers to 8 and enables the drawBuffersEXT extension.
  5. The parser sets the AST array size for gl_FragData to 8, and the clamping pass clamps the index to [0, 7].
  6. The HLSL translator emits a size-1 array but uses the clamped index, producing an out-of-bounds access that is passed to D3DCompile.

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 called shaders on the graphics card. ANGLE translates these shaders into another language (HLSL) for Windows. A mistake in that translation can produce code that reads or writes past the end of an array, which might crash or corrupt the program that compiles it.

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.