Out of bounds write in ANGLE (CVE-2026-130971)
In ANGLE's Vulkan backend, the code that flushes and invalidates non-coherent mapped memory builds memory ranges whose offset is not aligned to the device's nonCoherentAtomSize and whose end can run past the mapped block. On drivers where that atom size is larger than the default buffer alignment, these invalid ranges reach the driver unchecked, which could corrupt host memory through out-of-bounds cache invalidation.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 4 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: In ANGLE's Vulkan backend, BufferSuballocation::flush and invalidate construct spec-invalid VkMappedMemoryRange structures. The offset is not aligned to nonCoherentAtomSize, and offset+size can exceed the mapped block boundaries. On certain drivers, this may lead to host memory corruption via out-of-bounds cache invalidation.
Affected files:
third_party/angle/src/libANGLE/renderer/vulkan/Suballocation.cppthird_party/angle/src/libANGLE/renderer/vulkan/vk_renderer.cppthird_party/angle/src/libANGLE/renderer/vulkan/vk_helpers.cppthird_party/angle/src/libANGLE/renderer/vulkan/BufferVk.cpp
Estimated timestamp from git blame: 2025-02-05
1. Summary of the Issue (Meant for Human Triage)
In ANGLE's Vulkan backend, a validating-layer gap exists where BufferSuballocation::flush() and BufferSuballocation::invalidate() construct and submit a VkMappedMemoryRange to vkFlushMappedMemoryRanges and vkInvalidateMappedMemoryRanges that can violate key Vulkan specification guarantees.
Specifically, the structure can violate:
- VUID-VkMappedMemoryRange-offset-00687: The
offsetmust be a multiple ofVkPhysicalDeviceLimits::nonCoherentAtomSize. - VUID-VkMappedMemoryRange-size-00685: If
sizeis notVK_WHOLE_SIZE, it must be less than or equal to the size of the currently mapped range ofmemoryminusoffset.
This occurs because the backend computes the alignment constraint for user GL buffers (mDefaultBufferAlignment) without factoring in nonCoherentAtomSize. When a GL buffer is suballocated, its virtual offset is aligned only to mDefaultBufferAlignment. When flushing or invalidating non-coherent memory, the backend rounds up the suballocation size to nonCoherentAtomSize but fails to align the offset. If this is a tail suballocation, rounding up the size causes the resulting range (offset + size) to extend beyond the mapped memory boundary of the underlying BufferBlock.
The only validation in place is a debug-only ASSERT() with an incorrect predicate: it checks size <= allocated_size instead of offset + size <= allocated_size. This means even in debug builds, the out-of-bounds parameters are not caught.
On Vulkan drivers where nonCoherentAtomSize > mDefaultBufferAlignment and a non-coherent, host-visible memory type is allocated, the resulting spec-invalid parameters reach the driver unchecked. Passing an out-of-bounds memory range can trigger cache-invalidation commands spanning adjacent, unrelated host heap pages, resulting in a potential cross-allocation write-discard primitive within the unsandboxed GPU process host address space.
2. Proof-of-Concept & Detailed Execution Flow
Note: The following steps are a potential sequence an attacker would follow to trigger the vulnerability. Our tooling agent does not have the ability to run code to produce a live PoC, but the execution trace is confirmed via static analysis.
Step 1: Alignment Calculation and Suballocation
User GL buffers created via WebGL (glBufferData) are allocated from a shared virtual allocator pool. In third_party/angle/src/libANGLE/renderer/vulkan/BufferVk.cpp:1350, the suballocation alignment is queried: size_t alignment = renderer->getDefaultBufferAlignment();.
In third_party/angle/src/libANGLE/renderer/vulkan/vk_renderer.cpp:2873-2878, mDefaultBufferAlignment is defined as:
mDefaultBufferAlignment = std::max({
static_cast<size_t>(limitsVk.minUniformBufferOffsetAlignment),
static_cast<size_t>(limitsVk.minStorageBufferOffsetAlignment),
static_cast<size_t>(limitsVk.minTexelBufferOffsetAlignment),
static_cast<size_t>(limitsVk.minMemoryMapAlignment),
static_cast<size_t>(defaultBufferMemoryRequirements.alignment)
});
Crucially, this does not fold in limitsVk.nonCoherentAtomSize. On devices where nonCoherentAtomSize > mDefaultBufferAlignment, suballocations will have offsets that are multiples of mDefaultBufferAlignment but potentially not of nonCoherentAtomSize.
Step 2: Memory Type Selection
For a dynamic read buffer (GL_DYNAMIC_READ), BufferVk::GetPreferredMemoryType (BufferVk.cpp:69-107) yields kHostCachedFlags or kHostCachedNonCoherentFlags. BufferVk::GetMemoryTypeIndex (BufferVk.cpp:237-271) sets requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, making HOST_COHERENT merely preferred. The Vulkan Memory Allocator (VMA) may select a non-coherent type if a combined coherent+cached heap is unavailable or not preferred by the driver/ANGLE configuration.
Step 3: Crafting the Misaligned Tail Suballocation
The attacker issues multiple gl.bufferData(gl.COPY_READ_BUFFER, 68, gl.DYNAMIC_READ) calls from JavaScript. VMA suballocates these sequentially from the same BufferBlock (vk_helpers.cpp:3388, 3455-3457). The attacker ensures one suballocation receives a misaligned offset (relative to nonCoherentAtomSize) sitting exactly at the tail end of the BufferBlock mapped range where offset + mSize == mBufferBlock->getAllocatedBufferSize().
Step 4: Triggering the Vulnerable Sink via Read-back
The attacker forces an invalidation by reading back the buffer: gl.getBufferSubData(gl.COPY_READ_BUFFER, 0, dst).
- This routes to
BufferVk::getSubData(BufferVk.cpp:954-966), which callsmapRangeForReadAccessOnly. - Inside
mapRangeImpl(BufferVk.cpp:839), it branches tomapHostVisibleBuffer(BufferVk.cpp:691-704). - Because the memory is non-coherent and mapped for reading, it executes:
ANGLE_TRY(mBuffer.invalidate(contextVk->getRenderer()));. BufferHelper::invalidate(vk_helpers.cpp:5229-5233) ignores its offset/size arguments and callsmSuballocation.invalidate(renderer).
Step 5: The Spec-Violating Vulkan Call
In third_party/angle/src/libANGLE/renderer/vulkan/Suballocation.cpp:201-216:
void BufferSuballocation::invalidate(Renderer *renderer) {
if (!isCoherent()) {
const VkDeviceSize nonCoherentAtomSize = renderer->getPhysicalDeviceProperties().limits.nonCoherentAtomSize;
VkMappedMemoryRange mappedRange = {};
mappedRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
mappedRange.memory = mBufferBlock->getDeviceMemory().getHandle();
mappedRange.offset = getOffset(); // NOT aligned to nonCoherentAtomSize
mappedRange.size = roundUp<VkDeviceSize>(mSize, nonCoherentAtomSize); // Unclamped round-up
ASSERT(mappedRange.size <= mBufferBlock->getAllocatedBufferSize()); // FLAWED PREDICATE
mBufferBlock->getDeviceMemory().invalidate(renderer->getDevice(), mappedRange);
}
}
mappedRange.offsetviolatesVUID-VkMappedMemoryRange-offset-00687.mappedRange.offset + mappedRange.sizestrictly exceeds the block size, violatingVUID-VkMappedMemoryRange-size-00685.- The
ASSERTpasses trivially because it checkssize <= blockSizerather thanoffset + size <= blockSize. DeviceMemory::invalidatedirectly passes this tovkInvalidateMappedMemoryRanges(vk_wrapper.h:1736-1739), leading to undefined driver behavior and potential host memory corruption.
Suggested Fix
- In
third_party/angle/src/libANGLE/renderer/vulkan/vk_renderer.cpp:2873, addstatic_cast<size_t>(mPhysicalDeviceProperties.limits.nonCoherentAtomSize)to thestd::maxlist calculatingmDefaultBufferAlignment. - In
third_party/angle/src/libANGLE/renderer/vulkan/Suballocation.cpplines 196 and 214, correct the assertions to:ASSERT(mappedRange.offset + mappedRange.size <= mBufferBlock->getAllocatedBufferSize());. - Implement proper offset alignment and size clamping in
flushandinvalidateto strictly guarantee valid ranges even if buffer alignments change.
3. Technical Verification Details (Automated Audit Logs - Reviewers may skip this section)
Prior Critic Verdict Verbatim:
Severity: Medium (S2) Brief Notes / Reasoning: The vulnerability describes a GPU validating-layer gap in ANGLE's Vulkan backend where
BufferSuballocation::flushandinvalidatefail to align the offset tononCoherentAtomSizeand fail to clampoffset + sizeto the mapped region. This results in a violation of Vulkan Valid Usage clauses VUID-VkMappedMemoryRange-offset-00687 and VUID-VkMappedMemoryRange-size-00685. The unaligned/unclampedVkMappedMemoryRangeis passed directly to the driver viavkFlush/InvalidateMappedMemoryRanges. The only guard is a debug-onlyASSERTwith a flawed predicate. The code path from WebGL2'sgetBufferSubDatato this sink is fully confirmed.Per the severity guidelines: This is a GPU validating-layer gap where a spec-invalid value reaches the driver. However, because it requires a specific device configuration (
nonCoherentAtomSize > mDefaultBufferAlignmentand a non-coherent memory type) and no specific driver is shown to exhibit host memory corruption (driver misbehavior is undefined but not proven to be exploitable here), it falls perfectly under the Medium (S2) row: 'A GPU validating-layer gap (per the S1 row) where the spec-invalid value reaches the driver but the shown consequence... requires a specific driver version / vendor'. Therefore, S2 is the correct severity.
Codebase Investigator Raw Ledger:
third_party/angle/src/libANGLE/renderer/vulkan/Suballocation.cpp:201-217explicitly confirmed to constructVkMappedMemoryRangeusinggetOffset()androundUp<VkDeviceSize>(mSize, nonCoherentAtomSize).third_party/angle/src/libANGLE/renderer/vulkan/vk_renderer.cpp:2873-2878confirmed to omitnonCoherentAtomSizefrommDefaultBufferAlignmentcalculation.third_party/angle/src/libANGLE/renderer/vulkan/BufferVk.cpp:954-966and:839confirmed to trace WebGL'sgetBufferSubDatatomapHostVisibleBuffer.third_party/angle/src/libANGLE/renderer/vulkan/BufferVk.cpp:691-704confirmed to triggermBuffer.invalidate(contextVk->getRenderer())if!mBuffer.isCoherent().third_party/angle/src/libANGLE/renderer/vulkan/vk_helpers.cpp:5215-5233confirmedBufferHelper::flushandinvalidatediscard caller arguments and invalidate the whole suballocation viamSuballocation.invalidate(renderer);.vk_wrapper.h:1736-1739confirmed to be a direct wrapper aroundvkInvalidateMappedMemoryRanges.
Evaluated with Chrome root at commit: b96d2ec58f4f5f92b540a723966b199d6e9951b4
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
Likely the default buffer alignment omits the device's nonCoherentAtomSize, and the flush/invalidate code rounds the size up without aligning the offset or clamping the end to the mapped block, with only a debug assertion using the wrong comparison.
Impact
On drivers where the atom size exceeds the default alignment and a non-coherent host-visible memory type is used, the invalid range could cause cache invalidation across adjacent host pages, a potential cross-allocation write-discard within the GPU process; no specific driver is shown to be affected.
What the attacker needed
WebGL2 in the browser; driver with large nonCoherentAtomSize; non-coherent host-visible memory type
The fix
The report suggests including nonCoherentAtomSize in the default buffer alignment, correcting the assertions, and properly aligning and clamping the ranges in flush and invalidate.
How it was found
- Create several small dynamic read buffers from JavaScript so they are suballocated from one block.
- Arrange for one suballocation to sit at the tail of the block with an offset not aligned to the atom size.
- Read the buffer back with getBufferSubData to force an invalidate on non-coherent memory.
- The invalidate builds a memory range with an unaligned offset and an over-long size and passes it to the driver.
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.
A web page can ask the browser's graphics layer to read data back from a buffer it created. That layer, ANGLE, sometimes has to tell the graphics driver to refresh a slice of memory before reading it. Here the slice it describes is misaligned and can extend past the memory it actually owns, so the driver may touch memory belonging to something else.
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.