Inappropriate implementation in Tint (CVE-2026-7346)
Tint's LoopAnalysis misclassifies certain infinite loops as finite when they use degenerate bounds, bypassing the PreventInfiniteLoops transform. An attacker could craft a WGSL shader that triggers undefined behaviour optimisations in downstream driver compilers, potentially stripping security-critical bounds checks and leading to out-of-bounds memory access on the GPU.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 16 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 Chrome Security team.
Overview: Tint's LoopAnalysis misidentifies certain dynamically infinite loops as finite when they use degenerate bounds (e.g., i < 0u). This bypasses the PreventInfiniteLoops transform, allowing an attacker to trigger Undefined Behavior optimizations in downstream driver compilers that strip security-critical memory bounds checks.
Affected files:
third_party/dawn/src/tint/lang/core/ir/analysis/loop_analysis.cc
Estimated timestamp from git blame: 2025-07-21
Summary
Tint's LoopAnalysis, which determines if a loop is finite for the PreventInfiniteLoops security transform, contains a logic flaw that misclassifies certain infinite loops as finite. This occurs when a loop exit condition uses a strict inequality comparison (< or >) with a degenerate bound (e.g., idx < 0u for an unsigned index) and fails to verify if the exit branch is actually reachable. This flaw allows an attacker to bypass the mandatory 2^64-iteration cap injection, which in turn allows them to leverage Undefined Behavior (UB) optimizations in downstream driver compilers to bypass Robustness bounds checks.
Root Cause
The vulnerability arises from two interacting gaps in third_party/dawn/src/tint/lang/core/ir/analysis/loop_analysis.cc:
-
Missing Degenerate-Bound Checks for
<and>(lines 243-247): Theis_capable_binary_for_loop_exitfunction acceptskLessThanandkGreaterThanoperators if one operand is the loop index and the other is an immutable value. Unlike the implementation for<=and>=, it does not check if the bound value makes the comparison always false (e.g.,index < 0uis always false for au32index). -
Uncorrelated Exit Branch Polarity (line 313): The logic at line 313 considers a loop finite if either the True or False branch of an
ifinstruction leads to anExitLoop:return is_simple_loop_exit(i->True()) || is_simple_loop_exit(i->False());This does not account for the condition's polarity. Thus, anif (idx < 0u) { break; }statement is treated as a valid termination even though thebreak(the True branch) is never reachable.
Potential Attack Vector
An attacker can construct a WGSL shader that exploits this flaw to achieve out-of-bounds (OOB) memory access on the GPU. The following steps outline the theoretical attack mechanism:
- Attacker Input: The attacker provides a WGSL shader similar to the following:
WGSL var my_idx = user_provided_index; if (my_idx >= array_size) { // Syntactically "finite" but dynamically infinite loop for (var i: u32 = 1u; ; i = i + 1u) { if (i < 0u) { break; } } } // Access array my_array[my_idx] = 1; - Robustness Transform: Tint's
Robustnesstransform executes and replacesmy_array[my_idx]with clamped indexing:my_array[min(my_idx, array_size - 1)]. - PreventInfiniteLoops Bypass:
LoopAnalysismisclassifies the inner loop as finite. Consequently, thePreventInfiniteLoopstransform is bypassed, and no iteration cap is injected into the loop. - Driver Compiler UB Optimization: The emitted shader is handed to the downstream driver compiler (e.g., an LLVM-based compiler like Apple's Metal compiler or DXC). The driver compiler statically determines that the inner loop is infinite and has no side effects.
- Bounds Check Stripping: Under C++/LLVM semantics, an infinite loop without side effects is Undefined Behavior. The compiler assumes the program will never enter this UB state, marking the
if (my_idx >= array_size)branch as unreachable. It then propagates the inverse constraint (my_idx < array_size) globally. When evaluating the robustness checkmin(my_idx, array_size - 1), it determines theminoperation is redundant and optimizes it away to justmy_idx. - OOB Execution: The compiler removes the unreachable infinite loop. At runtime, if the attacker provides a
my_idxgreater than or equal toarray_size, execution falls through to the array access. Because theminclamping was stripped, the array access is performed out-of-bounds.
Proposed Fix
Update is_capable_binary_for_loop_exit in loop_analysis.cc to correctly reject degenerate bounds for kLessThan and kGreaterThan operations, similar to the existing logic for kLessThanEqual and kGreaterThanEqual. Additionally, IsBreakIfOnIndex should verify that the ExitLoop resides in the branch that corresponds to the index actually reaching the bound.
Evaluated with Chrome root at commit: 096fc8fdbfacf2546485756d03f160a3d04fcc9b
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.
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 fails to reject degenerate bounds for strict inequality comparisons and does not verify that the exit branch is actually reachable, so loops with conditions like `i < 0u` are incorrectly considered finite.
Impact
An attacker could achieve out-of-bounds memory access on the GPU, potentially leading to memory corruption or information disclosure, though the report notes this is a theoretical attack mechanism.
What the attacker needed
Ability to supply a WGSL shader; downstream driver compiler with UB optimisations
The fix
The fix should update `is_capable_binary_for_loop_exit` to reject degenerate bounds for strict inequalities and ensure `IsBreakIfOnIndex` verifies the exit branch is reachable.
How it was found
- Attacker provides a WGSL shader with a loop that has a degenerate bound, such as `if (i < 0u) { break; }`.
- Tint's Robustness transform replaces array accesses with clamped indexing.
- LoopAnalysis misclassifies the loop as finite, so PreventInfiniteLoops does not inject an iteration cap.
- The downstream driver compiler treats the infinite loop as undefined behaviour and may remove the robustness bounds check.
- At runtime, an out-of-bounds array access occurs if the attacker supplies an index beyond the array size.
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.
Tint is a compiler that translates shader code (WGSL) into a form that GPU drivers can understand. It has a safety feature that adds a limit to loops to prevent them from running forever, but a bug in how it checks loop conditions means some infinite loops are missed. If an infinite loop is not caught, the GPU driver's own compiler might make unsafe assumptions and remove important memory safety checks, potentially allowing out-of-bounds memory access.
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.