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

Type Confusion in ANGLE (CVE-2026-13883)

A logic error in ANGLE's RewriteStructSamplers pass mishandles comma operators, causing type-confused AST nodes and malformed SPIR-V. An attacker could serve a crafted WebGL shader that reaches native Vulkan drivers, potentially causing memory corruption and sandbox escape.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 3 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: A logic error in ANGLE's RewriteStructSamplers AST pass causes incorrect traversal of EOpComma operators during struct field resolution. This results in type-confused AST nodes, which subsequently causes OutputSPIRV to generate structurally invalid SPIR-V instructions. Passing this malformed SPIR-V to native Vulkan drivers can cause memory corruption in the driver's shader compiler, leading to a potential sandbox escape from WebGL.

Affected files:

  • third_party/angle/src/compiler/translator/tree_ops/RewriteStructSamplers.cpp
  • third_party/angle/src/compiler/translator/ParseContext.cpp
  • third_party/angle/src/compiler/translator/IntermNode.cpp
  • third_party/angle/src/compiler/translator/spirv/OutputSPIRV.cpp

Estimated timestamp from git blame: 2024-07-30

Summary

A vulnerability exists in ANGLE's RewriteStructSamplers AST transformation pass. The function RewriteModifiedStructFieldSelectionExpression incorrectly assumes it can trace the base uniform of a struct field selection by repeatedly traversing the left child of binary nodes. When a comma operator (EOpComma) is present, it mistakenly traverses into the unevaluated left operand instead of the right operand. In release builds, an unhandled node type within a switch statement causes the comma operator to be silently dropped, leading to a type-confused AST and the generation of invalid SPIR-V bytecode.

Technical Details

  1. Incorrect Traversal: During the RewriteStructSamplers pass, ANGLE needs to trace field selections (e.g., (a[i++], b).s) back to their base uniform to extract samplers into global scope. RewriteModifiedStructFieldSelectionExpression uses a while loop that iterates using iter = iter->getLeft()->getAsBinaryNode(). For an EOpComma node, getLeft() returns the left operand (a[i++]), failing to traverse the semantically correct right operand (b) which holds the actual struct being accessed. This misidentifies the base uniform.
  2. Silently Dropping Nodes: During the rebuild phase, the code iterates over the collected nodes bottom-up. The switch (indexNode->getOp()) block lacks a case EOpComma:, falling through to default:, which calls UNREACHABLE(). In Chromium release builds, UNREACHABLE() expands to a no-op macro (ASSERT(false) becomes true ? static_cast<void>(0) : ...). As a result, the comma node and its correct right-hand side are silently dropped, and the incorrectly identified left-hand uniform is substituted in its place.
  3. AST Type Confusion: The parent TIntermAggregate node for an associated function call (e.g., texture()) is not updated. Its constant TFunction pointer still expects the original arguments (e.g., sampler2D), but its child node now evaluates to the incorrectly substituted type (e.g., samplerCube).
  4. Malformed SPIR-V Generation: During SPIR-V generation, OutputSPIRVTraverser::createImageTextureBuiltIn uses the original function signature to determine coordinate requirements (e.g., expecting vec2 coordinates for a 2D sampler) but loads the actual sampler ID from the rewritten, type-confused child node. This emits structurally invalid SPIR-V instructions, such as OpImageSampleImplicitLod attempting to sample a Cube image using 2-component coordinates.
  5. Validation Bypass: At the end of OutputSPIRV, ANGLE calls ASSERT(spirv::Validate(result)). Because ASSERT is compiled out in release builds, ANGLE fails to catch the malformed SPIR-V and passes it directly to vkCreateShaderModule.

Potential Exploitation Scenario

An attacker can construct a malicious WebGL 2.0 fragment shader to trigger this vulnerability:

GLSL
#version 300 es
precision highp float;
struct S1 { samplerCube s; };
struct S2 { sampler2D s; float pad; };
uniform S1 a[2];
uniform S2 b;
out vec4 fragColor;
int i = 0;
void main() {
    // The comma operator survives folding due to the side effect in a[i++].
    // The rewriter incorrectly extracts the sampler from 'a' instead of 'b'.
    fragColor = texture((a[i++], b).s, vec2(0.5));
}

By serving this shader via WebGL, the attacker forces the GPU process to send malformed SPIR-V to the underlying proprietary Vulkan driver (e.g., AMD, NVIDIA, Intel, Adreno, Mali). These drivers' JIT compilers are highly complex and often assume the incoming SPIR-V is strictly valid. Encountering instructions with mismatched image and coordinate dimensions can break compiler invariants, leading to out-of-bounds reads/writes during register allocation or code emission. This provides a direct vector for Remote Code Execution and Sandbox Escape within the highly privileged GPU process.

Note: These steps describe a potential exploitation path; our automated tooling does not currently run the exploit code to verify the final outcome in the Vulkan driver.

Suggested Fix

  1. Modify RewriteModifiedStructFieldSelectionExpression in RewriteStructSamplers.cpp to properly handle EOpComma. When tracing the base uniform, the traversal must correctly follow getRight() for EOpComma nodes, as the right operand determines the evaluated struct.
  2. Ensure that the rebuilding phase of RewriteModifiedStructFieldSelectionExpression properly reconstructs the EOpComma node, preserving both the left-hand side effects and the right-hand struct access.
  3. Consider enforcing a strict spirv::Validate check in release builds before passing shaders to Vulkan drivers, or emitting a safe default shader if validation fails, to harden the GPU process against driver-level compiler vulnerabilities.

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 RewriteStructSamplers pass follows the left operand of a comma operator instead of the right, and its rebuild switch has no case for comma nodes, so release builds silently drop them and substitute the wrong uniform.

Impact

The malformed SPIR-V could break compiler invariants in proprietary Vulkan drivers, potentially leading to memory corruption and sandbox escape, though the report notes the exploit was not run to verify the final outcome.

What the attacker needed

Victim visits a malicious web page; browser uses ANGLE with Vulkan backend; release build without assertions

The fix

The traversal should follow the right operand for comma nodes, the rebuild should preserve the comma node, and release builds should validate SPIR-V before passing it to drivers.

How it was found

  1. Craft a WebGL 2.0 fragment shader that uses a comma expression to select a struct field.
  2. Serve the shader through WebGL so ANGLE's RewriteStructSamplers pass processes it.
  3. The pass misidentifies the base uniform and drops the comma node in release builds.
  4. OutputSPIRV emits structurally invalid SPIR-V instructions.
  5. The malformed SPIR-V is passed to the native Vulkan driver without validation.

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 draw 3D graphics, and ANGLE is the part of the browser that translates shader code into a form the graphics driver understands. A mistake in that translation can produce invalid instructions that the driver is not prepared for, and a bad driver reaction could let a web page break out of its security sandbox.

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.