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

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

ANGLE's loop forward-progress mitigation assumes signed integer overflow wraps, so it treats a loop like a signed counter incrementing from zero as finite and skips injecting a side effect. LLVM then deletes the loop as undefined behaviour, leaving the induction variable as poison, which bypasses array index clamping and could allow out-of-bounds GPU memory access.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 6 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 without the security team.

Overview: ANGLE's EnsureLoopForwardProgress pass incorrectly assumes signed integer overflow is defined, classifying certain infinite loops as finite. When compiled by the Metal backend, LLVM optimizes away these loops due to signed integer Undefined Behavior, leaving the induction variable as a poison value. This poison value propagates through ANGLE's array index clamping, leading to potential out-of-bounds GPU memory access.

Affected files:

  • src/compiler/translator/tree_ops/msl/EnsureLoopForwardProgress.cpp
  • src/compiler/translator/msl/EmitMetal.cpp
  • src/libANGLE/renderer/metal/ShaderMtl.mm
  • src/libANGLE/renderer/metal/DisplayMtl.mm

Estimated timestamp from git blame: 2025-06-16

Summary

There is a potential out-of-bounds (OOB) GPU memory access vulnerability in ANGLE's Metal backend. The vulnerability stems from a mismatch between ANGLE's AST analysis assumptions regarding signed integer overflow and the actual Undefined Behavior (UB) semantics of the Metal Shading Language (MSL).

Technical Details

The ensureLoopForwardProgress mitigation is designed to prevent driver-level miscompilations by injecting a side-effect (ANGLE_loopForwardProgress(), a volatile write) into loops that cannot be statically proven to terminate.

However, computeFiniteLoopVariable in src/compiler/translator/tree_ops/msl/EnsureLoopForwardProgress.cpp explicitly documents and assumes that "ints wrap around in a defined way." Because of this, it classifies loops like for (int i = 0; i >= 0; i++) {} as finite, assuming i will eventually wrap around to a negative value. Consequently, the volatile side-effect is not injected into the loop body.

During code generation, EmitMetal.cpp emits this loop using raw signed MSL arithmetic without casting to unsigned types. In MSL (which is based on C++14 and compiled via LLVM), signed integer overflow is Undefined Behavior. LLVM's optimizer performs range analysis, determines that i cannot legally become negative, and statically proves the loop condition i >= 0 is always true. Because the loop now appears to be an infinite loop with zero side-effects, LLVM invokes the C++ forward progress guarantee and aggressively deletes the loop entirely via dead code elimination.

Execution falls through to the post-loop code, but the induction variable i is now treated by LLVM as poison (an undefined value).

Crucially, ANGLE's array bounds clamping logic (ANGLE_int_clamp, defined using ternary operators) fails to contain poison values. In LLVM, ternary operators compile to select instructions. According to LLVM's poison propagation rules, select poison, ... evaluates to poison. Therefore, an array access like a[ANGLE_int_clamp(i, 0, max)] evaluates to a[poison].

At the machine code level, a poison index translates to the use of whatever value happens to be in an uninitialized physical register, leading to arbitrary OOB access.

Potential Attack Steps

Note: These are suggested theoretical steps based on static analysis, as our tooling agent cannot execute arbitrary code.

  1. Prime the Register: The attacker executes a "primer" WebGL workload that leaves a highly controlled, large offset value in the target physical GPU register.
  2. Trigger the Vulnerability: The attacker executes a WebGL2 fragment shader containing the vulnerable loop (for(int i=0; i>=0; i++) {}), immediately followed by a Shader Storage Buffer Object (SSBO) or array access using i as the index.
  3. Achieve OOB Access: The Metal compiler deletes the loop, leaving i as poison. The subsequent clamped array access uses the attacker-controlled value from the uninitialized register, completely bypassing the ANGLE_int_clamp bounds check.
  4. Exploit: The attacker gains arbitrary read/write access to GPU memory. On architectures like Apple Silicon with Unified Memory, this could be leveraged to overwrite CPU data structures and achieve a GPU process sandbox escape.

Suggested Fix

The assumption in computeFiniteLoopVariable that signed integers wrap around is invalid for the Metal backend.

  • Option 1: Update computeFiniteLoopVariable (or the logic driving it) to only assume wrap-around semantics for uint types. Signed integer loops should be treated as potentially infinite if their termination relies on overflow.
  • Option 2: Modify EmitMetal.cpp to explicitly cast signed arithmetic to unsigned types (e.g., using as_type<uint>) before performing increment/addition, ensuring the wrap-around behavior is strictly defined and matches ANGLE's AST assumptions.

Evaluated with Chrome root at commit: f200f57a19490707ff8bc7aa5de3cbc443a3afad


Results so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; 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 loop analysis assumes signed integer overflow is defined and wraps, while the Metal backend emits raw signed arithmetic where overflow is undefined behaviour, so the optimiser removes the loop and leaves a poison induction variable that the clamp cannot contain.

Impact

Could allow arbitrary read/write to GPU memory and, on unified-memory architectures, a GPU process sandbox escape; the report notes these are theoretical steps from static analysis and may be a false positive.

What the attacker needed

WebGL2 shader execution; Metal backend; Attacker controls shader source; Theoretical, not demonstrated

The fix

Should be fixed by restricting the wrap-around assumption to unsigned types or by casting signed arithmetic to unsigned before incrementing in the Metal emitter.

How it was found

  1. Run a primer WebGL workload to place a controlled large offset in a target physical GPU register.
  2. Run a WebGL2 fragment shader containing the vulnerable signed loop followed by an array or SSBO access indexed by the loop variable.
  3. The Metal compiler deletes the loop, leaving the index as poison, and the clamped array access uses the attacker-controlled register value.
  4. Gain arbitrary read/write to GPU memory, potentially escaping the GPU process sandbox on unified-memory architectures.

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 shader compiler tried to stop infinite loops by adding a marker, but it wrongly believed that a signed number would wrap around to negative. The optimiser then removed the loop entirely and left the index as an undefined value, so a later array access could read or write outside the intended 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.

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.