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

Inappropriate implementation in ANGLE (CVE-2026-9913)

The EnsureLoopForwardProgress pass in ANGLE only traverses the body of a loop, skipping its init, condition, and expression subtrees. An attacker could craft a WebGL shader that hides a write to an outer loop's induction variable inside a nested loop's initialisation, bypassing infinite loop detection and potentially causing out-of-bounds memory access in the GPU process.

Google Chrome

Originally disclosed on Chrome VRP

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

Overview: The EnsureLoopForwardProgress pass in ANGLE fails to traverse loop initialization, condition, and expression subtrees. This allows WebGL shaders to hide induction variable writes inside nested loops, bypassing infinite loop detection and potentially leading to out-of-bounds memory access in the GPU process.

Affected files:

  • third_party/angle/src/compiler/translator/tree_ops/msl/EnsureLoopForwardProgress.cpp

Estimated timestamp from git blame: 2025-06-16

Background

ANGLE includes a security mitigation (EnsureLoopForwardProgress) for the macOS/Metal backend to prevent the Apple Metal compiler (which is LLVM-based) from aggressively optimizing away side-effect-free infinite loops. Under LLVM semantics, an infinite loop without side effects is undefined behavior. If a shader contains such a loop, the compiler may assume the code following the loop is unreachable or elide bounds checks that ANGLE inserts for safety. This optimization bug has historically led to out-of-bounds (OOB) memory access and crashes in the GPU process (e.g., crbug.com/41486305). To prevent this, ANGLE injects a volatile variable access (ANGLE_loopForwardProgress()) into loops it cannot prove are finite.

Description of the Vulnerability

The vulnerability lies in how EnsureLoopForwardProgressTraverser::traverseLoop traverses the Abstract Syntax Tree (AST). The pass is designed to monitor loop induction variables to ensure they are not modified outside of the expected increment/decrement step. If a modification is detected via visitSymbol, the loop is marked as non-finite.

However, the custom traverseLoop implementation in third_party/angle/src/compiler/translator/tree_ops/msl/EnsureLoopForwardProgress.cpp is flawed:

C++
void EnsureLoopForwardProgressTraverser::traverseLoop(TIntermLoop *node)
{
    // ... setup ...
    node->getBody()->traverse(this); // <-- ONLY traverses the body
    // ... mitigation injection ...
}

Unlike the default TIntermTraverser::traverseLoop, which traverses all children of a loop (init, cond, expr, and body), this custom implementation explicitly skips traversing the initialization (init), condition (cond), and expression (expr) subtrees.

Additionally, the helper function computeFiniteLoopVariable (used to initially identify simple finite loops) only inspects the cond and expr nodes, completely ignoring the init node.

Potential Attack Steps

An attacker can construct a WebGL shader to hide a write to an outer loop's induction variable inside the initialization of a nested inner loop:

GLSL
for (int i = 0; i != 10; i++) {           // Outer loop
    for (int j = (i = 0); j != 5; j++) {  // Inner loop resets 'i'
        // Inner loop body
    }
}
  1. The traverser evaluates the outer loop and marks it as finite based on i != 10 and i++.
  2. The traverser traverses the outer loop's body and encounters the inner loop.
  3. The traverser evaluates the inner loop and marks it as finite based on j != 5 and j++. It ignores the j = (i = 0) initialization.
  4. The traverser traverses the inner loop's body. Crucially, it skips traversing the inner loop's initialization.
  5. Because the init block is never traversed, the TLValueTrackingTraverser never sees the i = 0 assignment. visitSymbol is bypassed for this modification.
  6. Both loops are incorrectly finalized as finite, and the ANGLE_loopForwardProgress() mitigation is not injected into either loop.
  7. The resulting Metal Shading Language (MSL) code contains a side-effect-free infinite loop. The Apple Metal compiler optimizes this loop, potentially eliding subsequent bounds checks and leading to out-of-bounds memory access in the GPU process.

Note: These are suggested steps based on static analysis. Our tooling agent does not currently have the ability to run code to produce a working proof of concept.

Proposed Fix

Modify EnsureLoopForwardProgressTraverser::traverseLoop to ensure that all subtrees of the loop are traversed, not just the body. It should call traverse(node) (which relies on the base class's generic traversal logic that visits all children) instead of node->getBody()->traverse(this).

Care must be taken to ensure that the traversal of the loop's own expr block (e.g., i++) does not incorrectly flag the loop as non-finite. The traverser might need to temporarily suppress setNotFinite for the current loop's expected induction variable when traversing its own expr node.

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

The custom traverseLoop implementation only traverses the loop body, skipping the init, cond, and expr subtrees, so modifications to induction variables in those parts are not detected.

Impact

The resulting Metal Shading Language (MSL) code contains a side-effect-free infinite loop. The Apple Metal compiler optimizes this loop, potentially eliding subsequent bounds checks and leading to out-of-bounds memory access in the GPU process.

What the attacker needed

Ability to supply a WebGL shader; macOS/Metal backend

The fix

Modify EnsureLoopForwardProgressTraverser::traverseLoop to traverse all subtrees of the loop, not just the body, while ensuring that traversal of the loop's own expr block does not incorrectly flag the loop as non-finite.

How it was found

  1. The traverser evaluates the outer loop and marks it as finite based on i != 10 and i++.
  2. The traverser traverses the outer loop's body and encounters the inner loop.
  3. The traverser evaluates the inner loop and marks it as finite based on j != 5 and j++. It ignores the j = (i = 0) initialization.
  4. The traverser traverses the inner loop's body. Crucially, it skips traversing the inner loop's initialization.
  5. Because the init block is never traversed, the TLValueTrackingTraverser never sees the i = 0 assignment. visitSymbol is bypassed for this modification.
  6. Both loops are incorrectly finalized as finite, and the ANGLE_loopForwardProgress() mitigation is not injected into either loop.

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.

ANGLE is a component that translates WebGL shaders for different graphics backends. A security check meant to stop infinite loops from being optimised away only looks at part of each loop, so a cleverly written shader can sneak a loop-modifying statement past it. This could let a malicious shader cause memory errors in the graphics process.

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.