Out of bounds read in ANGLE (CVE-2026-78978)
A validation loop in ANGLE's D3D11 translation path returned true as soon as one field of a uniform block structure was supported, so later unsupported fields such as column-major mat3 matrices were never checked. This could create a mismatch between the CPU-calculated std140 stride and the HLSL structure size, potentially causing an out-of-bounds GPU memory read at high array indices.
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. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: An inverted loop condition in ANGLE allows structures containing unsupported types to be translated to D3D11 StructuredBuffers. This leads to a mismatch between the calculated D3D11 buffer stride and the compiled HLSL structure size. The resulting layout discrepancy can potentially trigger an out-of-bounds memory read on the GPU.
Affected files:
third_party/angle/src/compiler/translator/tree_ops/hlsl/RecordUniformBlocksWithLargeArrayMember.cppthird_party/angle/src/compiler/translator/hlsl/StructureHLSL.cpp
Estimated timestamp from git blame: 2020-11-20
Description
A potential vulnerability exists in ANGLE's D3D11 translation path due to an existential-instead-of-universal check in IsSupportedTypeForStructuredBuffer. When translating std140 uniform blocks to StructuredBuffers, ANGLE is supposed to ensure that all fields inside the block structure are supported. However, the loop logic returns true on the very first field that satisfies the compatibility criteria, leaving subsequent unsupported fields (such as column-major mat3 matrices) unvalidated.
Root Cause
In third_party/angle/src/compiler/translator/tree_ops/hlsl/RecordUniformBlocksWithLargeArrayMember.cpp at lines 79-92:
const TFieldList &fields = structure->fields();
for (size_t i = 0; i < fields.size(); i++)
{
const TType &fieldType = *fields[i]->type();
if (!fieldType.isArray() && !fieldType.getStruct() &&
(fieldType.isScalar() || fieldType.isVector() ||
(fieldType.isMatrix() &&
((matrixPacking != EmpRowMajor && fieldType.getRows() == 4) ||
(matrixPacking == EmpRowMajor && fieldType.getCols() == 4)))))
{
return true;
}
}
return false;
If the first field is compatible (e.g., a vec4), the function immediately returns true, and any subsequent fields are never evaluated.
Downstream Stride Mismatch
Because the unsupported fields are not filtered out:
-
The shader translator uses HLSL structure generation logic that forces padding (
std140ForcePaddingString), yielding an HLSL structure definition such as:HLSL struct std_rm_fp__S { float4 _a; float3x3 _b; float pad_0; }; -
When compiled by
fxc, the structure size inside theStructuredBufferis calculated using HLSL default layout rules (e.g., 56 or 68 bytes). -
On the host side, ANGLE's CPU-side logic calculates the
std140stride as exactly 64 bytes and configures the D3D11StructureByteStridedescriptor using this value. -
When a draw call executes, the discrepancy between the shader's internal stride and the D3D11 descriptor's stride can result in out-of-bounds indexing. At high indices, this divergence can cause the GPU to read past the allocated buffer bounds.
Potential Steps to Reproduce (Unverified)
These are potential/suggested steps to reproduce the issue, as our analysis has been conducted statically without runtime verification:
-
On Windows 10+ using the D3D11 backend, create a WebGL2 context.
-
Compile and link a fragment shader with a
std140uniform block containing a structure array of at least 50 elements where the structure is defined as{ vec4 a; mat3 b; }:GLSL #version 300 es precision highp float; struct S { vec4 a; mat3 b; }; layout(std140) uniform Block { S buf[50]; }; out vec4 fragColor; void main() { int i = int(gl_FragCoord.x) % 50; fragColor = buf[i].a + vec4(buf[i].b[0], 0.0); } -
Set up the uniform buffer with a size matching the CPU-calculated size of $50 \times 64 = 3200$ bytes.
-
Bind the buffer and initiate a draw call. Under a mismatched stride, dynamic lookups at higher array indices (e.g., index 49) may result in OOB memory reads that are observable via render-to-texture and
glReadPixelsoperations.
Suggested Fix
Correct the validation logic in IsSupportedTypeForStructuredBuffer so that the loop returns false if any field fails to meet the criteria. Only return true if all fields pass the checks successfully:
const TFieldList &fields = structure->fields();
for (size_t i = 0; i < fields.size(); i++)
{
const TType &fieldType = *fields[i]->type();
if (fieldType.isArray() || fieldType.getStruct() ||
!(fieldType.isScalar() || fieldType.isVector() ||
(fieldType.isMatrix() &&
((matrixPacking != EmpRowMajor && fieldType.getRows() == 4) ||
(matrixPacking == EmpRowMajor && fieldType.getCols() == 4)))))
{
return false;
}
}
return true;
Evaluated with Chrome root at commit: e9507a33bb4148ee071aaaf8a7e9ad68770359bf
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.
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 validation function used an existential check (return true on the first supported field) instead of a universal check (return false on any unsupported field), so unsupported fields were never rejected.
Impact
At high array indices the stride divergence could cause the GPU to read past the allocated buffer bounds, potentially leaking data observable through render-to-texture and pixel readback; the report notes the analysis was static and unverified.
What the attacker needed
Windows with D3D11 backend; WebGL2 context in the browser; Attacker-controlled shader
The fix
The validation loop should be inverted so it returns false when any field fails the criteria and only returns true when all fields pass.
How it was found
- On Windows with the D3D11 backend, create a WebGL2 context.
- Compile and link a fragment shader with a std140 uniform block holding an array of structures that mix a vec4 and a mat3.
- Set up the uniform buffer with a size matching the CPU-calculated std140 size.
- Bind the buffer and issue a draw call, then look for out-of-bounds reads via render-to-texture and pixel readback.
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 web page draws 3D graphics, the browser translates shader code into a form the graphics card driver understands. A checking function here was meant to confirm every item in a data block was a type it could handle, but it stopped checking after the first good item. That let an unsupported item through, so the browser and the graphics card disagreed about how big each block entry was, which could make the card read memory beyond the buffer.
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.