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

Type confusion in ANGLE (CVE-2026-78904)

A type mismatch in ANGLE's SPIR-V backend occurs when dual-source blending is used and gl_FragData is passed by value to a function, causing the compiler to generate an invalid OpStore instruction. This invalid SPIR-V bypasses validation in release builds and reaches the Vulkan driver, potentially leading to out-of-bounds reads or memory corruption.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 35 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: A potential type mismatch exists in ANGLE's Vulkan/SPIR-V backend during the EmulateFragColorData pass. When gl_SecondaryFragDataEXT is used, gl_FragData is resized to MaxDualSourceDrawBuffers, but corresponding formal function parameter types are not updated. This leads to the generation of a type-mismatched OpStore in OutputSPIRV, which bypasses validation in release builds and reaches the Vulkan driver.

Affected files:

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

Estimated timestamp from git blame: 2023-07-14

Description

A potential vulnerability has been identified in ANGLE's SPIR-V translator backend. When translating fragment shaders that use both dual-source blending (gl_SecondaryFragDataEXT or similar) and pass the gl_FragData array by-value as an in parameter to a function, ANGLE can generate type-mismatched and spec-invalid SPIR-V.

Our tooling agents have statically analyzed the codebase but have not executed a live proof-of-concept. The analysis suggests the following sequence of events:

Root Cause Analysis

  1. EmulateFragColorData Resizing: When dual-source blending is active, the AST translation pass EmulateFragColorData replaces all occurrences of gl_FragData with a resized output variable webgl_FragData of size MaxDualSourceDrawBuffers (typically 1 or 2, which is smaller than the default MaxDrawBuffers of 4 or 8). Reference: third_party/angle/src/compiler/translator/tree_ops/spirv/EmulateFragColorData.cpp (Lines 80-83)

  2. Parameter Type Discrepancy: EmulateFragColorData overrides visitSymbol to replace the variables at the reference sites but does not modify the formal parameter lists stored within TFunction definitions in the symbol table. Consequently:

    • The function parameter type remains declared as vec4[MaxDrawBuffers] (larger size).
    • The call-site argument type has been rewritten to vec4[MaxDualSourceDrawBuffers] (smaller size).
  3. Type-Mismatched Instruction Generation: In OutputSPIRVTraverser::createFunctionCall (third_party/angle/src/compiler/translator/spirv/OutputSPIRV.cpp), the compiler generates code to copy the parameter values to temporary variables for in qualifiers:

    • The destination variable (tempVarIds[paramIndex]) is declared using the formal parameter type (vec4[MaxDrawBuffers]).
    • The source value (paramValue) is loaded using the actual argument type (vec4[MaxDualSourceDrawBuffers]).
    • These are written together via spirv::WriteStore, resulting in a type-mismatched OpStore (storing a smaller array object directly into a pointer to a larger array type), violating SPIR-V specification §3.42.8.
  4. Validation Bypass in Release Builds: In production builds of Chromium, AST validation (validateAST) and output validation (spirv::Validate) are disabled because they are gated under ANGLE_ENABLE_ASSERTS. The invalid SPIR-V bytecode is therefore passed directly to the GPU driver's vkCreateShaderModule API within the GPU process.

Potential Impact

If the Vulkan driver's shader compiler processes this mismatched OpStore instruction:

  • It may read out-of-bounds on the source stack/registers when compiling based on the destination pointer's width, leaking adjacent graphics memory contents.
  • It may leave elements of the local variable uninitialized, resulting in cross-origin/previously used register information leaks when read back.
  • On Android, where the GPU process is unsandboxed, severe compiler-level mishandling by the proprietary GPU driver could lead to out-of-bounds memory corruption.

Potential Steps to Reproduce

An attacker could potentially trigger this by compiling a WebGL shader with the following structure:

  1. Request a WebGL 1.0 context and ensure the WEBGL_blend_func_extended extension is enabled.
  2. Compile a fragment shader enabling the extension and utilizing a helper function:
GLSL
#extension GL_EXT_blend_func_extended : require

// Formal parameter is vec4[gl_MaxDrawBuffers]
void f(in vec4 d[gl_MaxDrawBuffers]) {
    gl_FragData[0] = d[0];
}

void main() {
    gl_FragData[0] = vec4(1.0);
    f(gl_FragData);
    gl_SecondaryFragDataEXT[0] = vec4(0.0);
}
  1. In a debug build with assertions enabled, this should trigger the ASSERT(spirv::Validate(result)) assertion in OutputSPIRV.cpp.

Suggested Fix

To prevent this discrepancy, the EmulateFragColorData transformation pass (or another early translation pass) must ensure that any formal parameter types of user-defined functions that accept gl_FragData are either updated to match the emulated/resized output type or that the relevant functions are monomorphized/inlined prior to code generation.

Evaluated with Chrome root at commit: 5a99d0c5d2ec6c066f5131e7868ff637440cc3dc


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 EmulateFragColorData pass resizes gl_FragData but does not update the formal parameter types of functions that receive it, leading to a type-mismatched OpStore.

Impact

The invalid SPIR-V could cause the Vulkan driver to read out-of-bounds or leave data uninitialized, potentially leaking graphics memory or, on Android where the GPU process is unsandboxed, leading to memory corruption.

What the attacker needed

WebGL 1.0 context; WEBGL_blend_func_extended extension enabled; Ability to compile a fragment shader

The fix

The EmulateFragColorData pass should update formal parameter types to match the resized output type, or the relevant functions should be inlined before code generation.

How it was found

  1. Request a WebGL 1.0 context and enable the WEBGL_blend_func_extended extension.
  2. Compile a fragment shader that uses gl_SecondaryFragDataEXT and passes gl_FragData as an in parameter to a helper function.
  3. In a debug build with assertions, observe the spirv::Validate assertion failure.

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.

When a WebGL shader uses a special feature called dual-source blending, the browser's shader compiler (ANGLE) rewrites the shader code. A mistake in this rewriting causes the compiler to produce an instruction that stores data of the wrong size, which the graphics driver may mishandle. This could let an attacker read leftover graphics memory or, on some devices, corrupt 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.