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

Out of bounds read in GPU (CVE-2026-9113)

The ANGLE Metal backend's ConvertUniformBufferData function performs an insufficient bounds check when converting std140 boolean uniform values, allowing a 1 to 3 byte heap out-of-bounds read in the GPU process. An attacker could trigger this from any WebGL2 page on macOS using the Metal backend, potentially reading adjacent heap memory.

c6eed09fc8b174b0f3eebedcceb1e792 Follow

Originally disclosed on Chrome VRP

Bounty$3,000 High View original
  • Fix shipped in 3 months

Insufficient bounds check in ANGLE Metal UBO bool conversion leads to heap OOB read in GPU process on Mac

Summary

The ANGLE Metal backend's ConvertUniformBufferData function performs an insufficient bounds check when converting std140 boolean uniform values to Metal's 1-byte representation. The check validates only that the source pointer falls within the buffer, but does not account for the full 4-byte dereference that follows, allowing a 1 to 3 byte heap out-of-bounds read in the GPU process. The bug is reachable from any WebGL2 page on macOS using the Metal backend.

Platform: macOS (Metal backend). Affects both Intel and Apple Silicon Macs.

Bisect

Introducing Commit: b23bf47c9e999532a684beab9ac901552420b0b8

A subsequent commit f7d7be8d2ff0bbee438b6030419a0b13082de198 ("Metal: upstream 'UBO convert only whole block'") added the srcBool < maxSrcPtr bounds check to this code path, but the check is insufficient as described below.

Root Cause

When a WebGL2 shader uses a uniform block containing a bool field, the ANGLE Metal backend must convert between the std140 layout (where bools occupy 4 bytes) and Metal's native layout (where bools occupy 1 byte). This conversion happens in ConvertUniformBufferData, called from legalizeUniformBufferOffsets at draw time.

The function computes sizeToCopy as the full buffer size minus the initial source offset, then divides by the block's std140 size to determine how many block instances to process:

C++
// ProgramExecutableMtl.mm — legalizeUniformBufferOffsets
size_t sizeToCopy = bufferMtl->size() - conversion->initialSrcOffset();

// ProgramExecutableMtl.mm — ConvertUniformBufferData
const uint8_t *maxSrcPtr = sourceData + sizeToCopy;
size_t numBlocksToCopy =
    (sizeToCopy + blockConversionInfo.stdSize() - 1) / blockConversionInfo.stdSize();

This ceiling division means that if the buffer size is not an exact multiple of stdSize, the function will process a partial final block. When this partial block contains a boolean field, the following code runs:

C++
// ProgramExecutableMtl.mm — ConvertUniformBufferData, bool branch
const uint8_t *srcBool =
    (sourceData + stdIterator->offset + stdArrayOffset +
     blockConversionInfo.stdSize() * i +
     gl::VariableComponentSize(GL_BOOL) * boolCol);
unsigned int srcValue =
    srcBool < maxSrcPtr ? *((unsigned int *)(srcBool)) : 0;

The guard srcBool < maxSrcPtr checks that the start of the 4-byte value is within bounds, but *((unsigned int *)(srcBool)) reads 4 bytes starting at srcBool. When srcBool points to, say, the last byte of the buffer, the check passes (the pointer is less than maxSrcPtr) but the dereference reads 3 bytes past the end of the allocation.

To trigger the partial block, the buffer must be created with a size that is not a multiple of the block's std140 size. ANGLE's Metal backend rounds up buffer sizes to 16 bytes when the buffer is first created as UNIFORM_BUFFER, but this round-up does not apply when the buffer is initially created as ARRAY_BUFFER and later bound to a uniform buffer binding point. This is a known gap acknowledged in a TODO comment in BufferMtl::setDataImpl:

C++
// BufferMtl.mm — setDataImpl
if (target == gl::BufferBinding::Uniform)
{
    // This doesn't work! A buffer can be allocated on ARRAY_BUFFER and used in UNIFORM_BUFFER
    // TODO(anglebug.com/42266052)
    adjustedSize = roundUpPow2(adjustedSize, (size_t)16);
}

When useShadowBuffersWhenAppropriate is enabled (default on Intel Macs, can be force-enabled elsewhere), getBufferDataReadOnly returns a pointer to a malloc-backed shadow copy whose size matches the exact buffer allocation. This makes the OOB read land on a precisely sized heap allocation where ASAN can detect it. Without shadow buffers, the read targets a Metal buffer mapping with driver-level alignment padding, so the OOB still occurs but may not trigger ASAN.

The concrete trigger sequence: a uniform block layout(std140) uniform U { bool b; } has stdSize = 4. A buffer created as ARRAY_BUFFER with 5 bytes, then bound via bindBufferRange to a uniform buffer binding, produces sizeToCopy = 5, numBlocksToCopy = ceil(5/4) = 2. The second block iteration sets srcBool = sourceData + 4. Since 4 < 5, the check passes, but the 4-byte read at offset 4 reaches bytes [4..7], overflowing the 5-byte allocation by 3 bytes.

Reproduce

Tested on Chromium commit d0f83d769eeed, macOS with Metal backend. The ASAN build must have the useShadowBuffersWhenAppropriate ANGLE feature enabled at runtime so that UBO shadow copies go through malloc, which ASAN can track. Without this, Metal buffer mappings are used and the OOB read still occurs but escapes ASAN detection.

Build Chromium with ASAN enabled. A minimal args.gn for out/asan-release:

is_asan = true
is_debug = false
is_component_build = false
symbol_level = 1

Then build:

autoninja -C ~/chromium/src/out/asan-release chrome

Launch Chrome with the PoC, forcing the Metal backend and the shadow buffer feature:

ANGLE_FEATURE_OVERRIDES_ENABLED=useShadowBuffersWhenAppropriate \
ASAN_OPTIONS=detect_odr_violation=0 \
~/chromium/src/out/asan-release/Chromium.app/Contents/MacOS/Chromium \
  --no-sandbox --use-angle=metal \
  --user-data-dir=/tmp/poc-$(date +%s) \
  poc.html

The GPU process will report a heap-buffer-overflow in rx::ProgramExecutableMtl::legalizeUniformBufferOffsets with a READ of size 4. The shadow byte pattern [05] confirms a 5-byte allocation where a 4-byte read starting at offset 4 overflows by 3 bytes. On Intel Macs, useShadowBuffersWhenAppropriate is enabled by default, so the environment variable override is not needed.

ASAN output:

=================================================================
==11248==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000010014 at pc 0x000307933094 bp 0x00016bccbcb0 sp 0x00016bccbca8
READ of size 4 at 0x602000010014 thread T0
==11248==WARNING: invalid path to external symbolizer!
==11248==WARNING: Failed to use and restart external symbolizer!
    #0 0x000307933090 in rx::ProgramExecutableMtl::legalizeUniformBufferOffsets(rx::ContextMtl*)+0x1580 (/Users/user/chromium/src/out/asan-release/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7702.0/Libraries/libGLESv2.dylib:arm64+0x933090)
    #1 0x0003079308a4 in rx::ProgramExecutableMtl::updateUniformBuffers(rx::ContextMtl*, rx::mtl::RenderCommandEncoder*, rx::mtl::RenderPipelineDesc const&)+0x1a4 (/Users/user/chromium/src/out/asan-release/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7702.0/Libraries/libGLESv2.dylib:arm64+0x9308a4)
    #2 0x00030792ea94 in rx::ProgramExecutableMtl::setupDraw(gl::Context const*, rx::mtl::RenderCommandEncoder*, rx::mtl::RenderPipelineDesc const&, bool, bool, bool)+0x340 (/Users/user/chromium/src/out/asan-release/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7702.0/Libraries/libGLESv2.dylib:arm64+0x92ea94)
    #3 0x0003078fd4b0 in rx::ContextMtl::setupDrawImpl(gl::Context const*, gl::PrimitiveMode, int, int, int, gl::DrawElementsType, void const*, bool, bool*)+0xb28 (/Users/user/chromium/src/out/asan-release/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7702.0/Libraries/libGLESv2.dylib:arm64+0x8fd4b0)
    #4 0x0003078efbc0 in rx::ContextMtl::drawArraysImpl(gl::Context const*, gl::PrimitiveMode, int, int, int, unsigned int)+0x2cc (/Users/user/chromium/src/out/asan-release/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7702.0/Libraries/libGLESv2.dylib:arm64+0x8efbc0)
    #5 0x0003078f1ad4 in rx::ContextMtl::drawArrays(gl::Context const*, gl::PrimitiveMode, int, int)+0x158 (/Users/user/chromium/src/out/asan-release/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7702.0/Libraries/libGLESv2.dylib:arm64+0x8f1ad4)
    #6 0x000307033f3c in GL_DrawArrays+0x4f0 (/Users/user/chromium/src/out/asan-release/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7702.0/Libraries/libGLESv2.dylib:arm64+0x33f3c)
    #7 0x00010b06457c in gl::RealGLApi::glDrawArraysFn(unsigned int, int, int)+0x19c (/Users/user/chromium/src/out/asan-release/libgl_wrapper.dylib:arm64+0xc857c)
    #8 0x00014777ec50 in gpu::gles2::GLES2DecoderPassthroughImpl::DoDrawArrays(unsigned int, int, int)+0x94 (/Users/user/chromium/src/out/asan-release/libgpu_gles2.dylib:arm64+0xd2c50)
    #9 0x0001477496cc in gpu::error::Error gpu::gles2::GLES2DecoderPassthroughImpl::DoCommandsImpl<false>(unsigned int, void const volatile*, int, int*)+0x1a4 (/Users/user/chromium/src/out/asan-release/libgpu_gles2.dylib:arm64+0x9d6cc)
    #10 0x00013e936b44 in gpu::CommandBufferService::Flush(int, gpu::AsyncAPIInterface*)+0x4bc (/Users/user/chromium/src/out/asan-release/libgpu_command_buffer_service.dylib:arm64+0xab44)
    #11 0x000142ee616c in gpu::CommandBufferStub::OnAsyncFlush(int, unsigned int, std::__Cr::vector<gpu::SyncToken, std::__Cr::allocator<gpu::SyncToken>> const&)+0x450 (/Users/user/chromium/src/out/asan-release/libgpu_ipc_service.dylib:arm64+0x616c)
    #12 0x000142ee52ec in gpu::CommandBufferStub::ExecuteDeferredRequest(gpu::mojom::DeferredCommandBufferRequestParams&, gpu::FenceSyncReleaseDelegate*)+0x468 (/Users/user/chromium/src/out/asan-release/libgpu_ipc_service.dylib:arm64+0x52ec)
    #13 0x000142f099fc in gpu::GpuChannel::ExecuteDeferredRequest(mojo::StructPtr<gpu::mojom::DeferredRequestParams>, gpu::FenceSyncReleaseDelegate*)+0x290 (/Users/user/chromium/src/out/asan-release/libgpu_ipc_service.dylib:arm64+0x299fc)
    #14 0x000142f15aa8 (/Users/user/chromium/src/out/asan-release/libgpu_ipc_service.dylib:arm64+0x35aa8)
    #15 0x000142f158c0 (/Users/user/chromium/src/out/asan-release/libgpu_ipc_service.dylib:arm64+0x358c0)
    #16 0x00013e97dafc (/Users/user/chromium/src/out/asan-release/libgpu_command_buffer_service.dylib:arm64+0x51afc)
    #17 0x00013e95200c in gpu::Scheduler::ExecuteSequence(base::IdType<gpu::SyncPointOrderData, unsigned int, 0u, 1u>)+0x634 (/Users/user/chromium/src/out/asan-release/libgpu_command_buffer_service.dylib:arm64+0x2600c)
    #18 0x00013e9506a4 in gpu::Scheduler::RunNextTask()+0x27c (/Users/user/chromium/src/out/asan-release/libgpu_command_buffer_service.dylib:arm64+0x246a4)
    #19 0x00013e95484c (/Users/user/chromium/src/out/asan-release/libgpu_command_buffer_service.dylib:arm64+0x2884c)
    #20 0x00010670d804 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&)+0x348 (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x1fd804)
    #21 0x00010678ae84 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::LazyNow*)+0x88c (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x27ae84)
    #22 0x00010678a23c in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork()+0x138 (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x27a23c)
    #23 0x0001069163cc in base::MessagePumpCFRunLoopBase::RunWork()+0x1c8 (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x4063cc)
    #24 0x000106900df8 in base::apple::CallWithEHFrame(void () block_pointer)+0xc (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x3f0df8)
    #25 0x00010691475c in base::MessagePumpCFRunLoopBase::RunWorkSource(void*)+0xec (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x40475c)
    #26 0x00019c086b10 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__+0x18 (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation:arm64e+0x7cb10)
    #27 0x00019c086aa4 in __CFRunLoopDoSource0+0xa8 (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation:arm64e+0x7caa4)
    #28 0x00019c086810 in __CFRunLoopDoSources0+0xe4 (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation:arm64e+0x7c810)
    #29 0x00019c085464 in __CFRunLoopRun+0x344 (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation:arm64e+0x7b464)
    #30 0x00019c084a94 in CFRunLoopRunSpecific+0x238 (/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation:arm64e+0x7aa94)
    #31 0x00019d654c74 in -[NSRunLoop(NSRunLoop) runMode:beforeDate:]+0xd0 (/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation:arm64e+0x59c74)
    #32 0x000106917db8 in base::MessagePumpNSRunLoop::DoRun(base::MessagePump::Delegate*)+0xc8 (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x407db8)
    #33 0x000106913334 in base::MessagePumpCFRunLoopBase::Run(base::MessagePump::Delegate*)+0x290 (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x403334)
    #34 0x00010678c240 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta)+0x32c (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x27c240)
    #35 0x000106678b08 in base::RunLoop::Run(base::Location const&)+0x430 (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x168b08)
    #36 0x000134c6ca04 in content::GpuMain(content::MainFunctionParams)+0x8b4 (/Users/user/chromium/src/out/asan-release/libcontent.dylib:arm64+0x10a04)
    #37 0x0001389e4ac8 in content::RunOtherNamedProcessTypeMain(...)+0x420 (/Users/user/chromium/src/out/asan-release/libcontent.dylib:arm64+0x3d88ac8)
    #38 0x0001389e6c48 in content::ContentMainRunnerImpl::Run()+0x53c (/Users/user/chromium/src/out/asan-release/libcontent.dylib:arm64+0x3d8ac48)
    #39 0x0001389e2558 in content::RunContentProcess(content::ContentMainParams, content::ContentMainRunner*)+0x858 (/Users/user/chromium/src/out/asan-release/libcontent.dylib:arm64+0x3d86558)
    #40 0x0001389e2a48 in content::ContentMain(content::ContentMainParams)+0x190 (/Users/user/chromium/src/out/asan-release/libcontent.dylib:arm64+0x3d86a48)
    #41 0x00011c79b724 in ChromeMain+0x490 (/Users/user/chromium/src/out/asan-release/libchrome_dll.dylib:arm64+0xb724)
    #42 0x000104130b94 in main+0x254 (/Users/user/chromium/src/out/asan-release/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7702.0/Helpers/Chromium Helper.app/Contents/MacOS/Chromium Helper:arm64+0x100000b94)
    #43 0x00019bbfab94 in start+0x17b8 (/usr/lib/dyld:arm64e+0x6b94)

0x602000010015 is located 0 bytes after 5-byte region [0x602000010010,0x602000010015)
allocated by thread T0 here:
    #0 0x000104a3cdb8 in __asan_memmove+0x2fd8 (/Users/user/chromium/src/out/asan-release/libclang_rt.asan_osx_dynamic.dylib:arm64+0x54db8)
    #1 0x000307a05a60 in angle::MemoryBuffer::resize(unsigned long)+0x50 (/Users/user/chromium/src/out/asan-release/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7702.0/Libraries/libGLESv2.dylib:arm64+0xa05a60)
    #2 0x0003078e04b4 in rx::BufferMtl::setDataImpl(gl::Context const*, gl::BufferBinding, void const*, unsigned long, gl::BufferUsage, rx::BufferFeedback*)+0x29c (/Users/user/chromium/src/out/asan-release/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7702.0/Libraries/libGLESv2.dylib:arm64+0x8e04b4)
    #3 0x0003073eab88 in gl::Buffer::setDataWithUsageFlags(...)+0x130 (/Users/user/chromium/src/out/asan-release/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7702.0/Libraries/libGLESv2.dylib:arm64+0x3eab88)
    #4 0x0003073ea688 in gl::Buffer::bufferDataImpl(...)+0x1d0 (/Users/user/chromium/src/out/asan-release/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7702.0/Libraries/libGLESv2.dylib:arm64+0x3ea688)
    #5 0x000147778850 in gpu::gles2::GLES2DecoderPassthroughImpl::DoBufferData(unsigned int, long, void const*, unsigned int)+0xb0 (/Users/user/chromium/src/out/asan-release/libgpu_gles2.dylib:arm64+0xcc850)
    #6 0x0001477496cc in gpu::error::Error gpu::gles2::GLES2DecoderPassthroughImpl::DoCommandsImpl<false>(unsigned int, void const volatile*, int, int*)+0x1a4 (/Users/user/chromium/src/out/asan-release/libgpu_gles2.dylib:arm64+0x9d6cc)
    #7 0x00013e936b44 in gpu::CommandBufferService::Flush(int, gpu::AsyncAPIInterface*)+0x4bc (/Users/user/chromium/src/out/asan-release/libgpu_command_buffer_service.dylib:arm64+0xab44)
    #8 0x000142ee616c in gpu::CommandBufferStub::OnAsyncFlush(...)+0x450 (/Users/user/chromium/src/out/asan-release/libgpu_ipc_service.dylib:arm64+0x616c)
    #9 0x000142ee52ec in gpu::CommandBufferStub::ExecuteDeferredRequest(...)+0x468 (/Users/user/chromium/src/out/asan-release/libgpu_ipc_service.dylib:arm64+0x52ec)
    #10 0x000142f099fc in gpu::GpuChannel::ExecuteDeferredRequest(...)+0x290 (/Users/user/chromium/src/out/asan-release/libgpu_ipc_service.dylib:arm64+0x299fc)
    #11 0x000142f15aa8 (/Users/user/chromium/src/out/asan-release/libgpu_ipc_service.dylib:arm64+0x35aa8)
    #12 0x000142f158c0 (/Users/user/chromium/src/out/asan-release/libgpu_ipc_service.dylib:arm64+0x358c0)
    #13 0x00013e97dafc (/Users/user/chromium/src/out/asan-release/libgpu_command_buffer_service.dylib:arm64+0x51afc)
    #14 0x00013e95200c in gpu::Scheduler::ExecuteSequence(...)+0x634 (/Users/user/chromium/src/out/asan-release/libgpu_command_buffer_service.dylib:arm64+0x2600c)
    #15 0x00013e9506a4 in gpu::Scheduler::RunNextTask()+0x27c (/Users/user/chromium/src/out/asan-release/libgpu_command_buffer_service.dylib:arm64+0x246a4)
    #16 0x00013e95484c (/Users/user/chromium/src/out/asan-release/libgpu_command_buffer_service.dylib:arm64+0x2884c)
    #17 0x00010670d804 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&)+0x348 (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x1fd804)
    #18 0x00010678ae84 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::LazyNow*)+0x88c (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x27ae84)
    #19 0x00010678a23c in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork()+0x138 (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x27a23c)
    #20 0x0001069163cc in base::MessagePumpCFRunLoopBase::RunWork()+0x1c8 (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x4063cc)
    #21 0x000106900df8 in base::apple::CallWithEHFrame(void () block_pointer)+0xc (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x3f0df8)
    #22 0x00010691475c in base::MessagePumpCFRunLoopBase::RunWorkSource(void*)+0xec (/Users/user/chromium/src/out/asan-release/libbase.dylib:arm64+0x40475c)
    #23 0x00019c086b10 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__+0x18
    #24 0x00019c086aa4 in __CFRunLoopDoSource0+0xa8
    #25 0x00019c086810 in __CFRunLoopDoSources0+0xe4
    #26 0x00019c085464 in __CFRunLoopRun+0x344
    #27 0x00019c084a94 in CFRunLoopRunSpecific+0x238
    #28 0x00019d654c74 in -[NSRunLoop(NSRunLoop) runMode:beforeDate:]+0xd0
    #29 0x000106917db8 in base::MessagePumpNSRunLoop::DoRun(base::MessagePump::Delegate*)+0xc8
    #30 0x000106913334 in base::MessagePumpCFRunLoopBase::Run(base::MessagePump::Delegate*)+0x290
    #31 0x00010678c240 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta)+0x32c
    #32 0x000106678b08 in base::RunLoop::Run(base::Location const&)+0x430
    #33 0x000134c6ca04 in content::GpuMain(content::MainFunctionParams)+0x8b4
    #34 0x0001389e4ac8 in content::RunOtherNamedProcessTypeMain(...)+0x420
    #35 0x0001389e6c48 in content::ContentMainRunnerImpl::Run()+0x53c
    #36 0x0001389e2558 in content::RunContentProcess(...)+0x858
    #37 0x0001389e2a48 in content::ContentMain(content::ContentMainParams)+0x190
    #38 0x00011c79b724 in ChromeMain+0x490
    #39 0x000104130b94 in main+0x254
    #40 0x00019bbfab94 in start+0x17b8

0x602000010015 is located 0 bytes after 5-byte region [0x602000010010,0x602000010015)
allocated by thread T0 here:
    #0 0x000104a3cdb8 in __asan_memmove+0x2fd8
    #1 0x000307a05a60 in angle::MemoryBuffer::resize(unsigned long)+0x50
    #2 0x0003078e04b4 in rx::BufferMtl::setDataImpl(...)+0x29c
    #3 0x0003073eab88 in gl::Buffer::setDataWithUsageFlags(...)+0x130
    #4 0x0003073ea688 in gl::Buffer::bufferDataImpl(...)+0x1d0
    #5 0x000147778850 in gpu::gles2::GLES2DecoderPassthroughImpl::DoBufferData(...)+0xb0
    #6 0x0001477496cc in gpu::gles2::GLES2DecoderPassthroughImpl::DoCommandsImpl<false>(...)+0x1a4
    #7 0x00013e936b44 in gpu::CommandBufferService::Flush(...)+0x4bc
    #8 0x000142ee616c in gpu::CommandBufferStub::OnAsyncFlush(...)+0x450
    #9 0x000142ee52ec in gpu::CommandBufferStub::ExecuteDeferredRequest(...)+0x468
    #10 0x000142f099fc in gpu::GpuChannel::ExecuteDeferredRequest(...)+0x290

SUMMARY: AddressSanitizer: heap-buffer-overflow (/Users/user/chromium/src/out/asan-release/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/147.0.7702.0/Libraries/libGLESv2.dylib:arm64+0x933090) in rx::ProgramExecutableMtl::legalizeUniformBufferOffsets(rx::ContextMtl*)+0x1580
Shadow bytes around the buggy address:
  0x60200000fd80: f7 fa fd fa f7 fa fd fa f7 fa fd fa f7 fa fd fa
  0x60200000fe00: f7 fa fd fa f7 fa fd fa f7 fa fd fa f7 fa 00 00
  0x60200000fe80: f7 fa fd fa f7 fa 00 00 f7 fa 00 00 f7 fa 00 00
  0x60200000ff00: f7 fa fd fa f7 fa fd fd f7 fa fd fa f7 fa fd fa
  0x60200000ff80: f7 fa fd fd f7 fa fd fa f7 fa fd fd f7 fa fd fd
=>0x602000010000: f7 fa[05]fa f7 fa fd fa f7 fa fd fd f7 fa fd fa
  0x602000010080: f7 fa fd fd f7 fa fd fa f7 fa fd fa f7 fa fd fa
  0x602000010100: f7 fa fd fd f7 fa fd fa f7 fa fd fa f7 fa fd fd
  0x602000010180: f7 fa fd fd f7 fa fd fd f7 fa fd fd f7 fa fd fd
  0x602000010200: f7 fa fd fd f7 fa 00 00 f7 fa fd fa f7 fa fd fa
  0x602000010280: f7 fa fd fa f7 fa fd fa f7 fa fd fd f7 fa 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb

==11248==ABORTING

Credit

Please use c6eed09fc8b174b0f3eebedcceb1e792 as the credit for this vulnerability. Thank you.

The original report as published on the Chromium issue tracker, by c6eed09fc8b174b0f3eebedcceb1e792. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

Context

This is an out-of-bounds read in the GPU process of Google Chrome, reachable from any WebGL2 page on macOS when the Metal backend is in use. The affected component is ANGLE, the translation layer that maps OpenGL ES and WebGL calls onto the platform's native graphics API. On macOS that native API is Metal, and the relevant code lives in the Metal backend of ANGLE, in ProgramExecutableMtl.mm.

The feature involved is uniform buffer object (UBO) conversion. In WebGL2, a shader can declare a uniform block whose members are laid out according to the std140 rules. Under std140 a bool occupies 4 bytes. Metal's native layout stores a bool in 1 byte. When a shader uses a uniform block containing a bool, ANGLE's Metal backend therefore has to rewrite the buffer contents at draw time, expanding or contracting each bool between the two representations. That rewrite is done by ConvertUniformBufferData, which is called from legalizeUniformBufferOffsets when a draw is set up.

The bug affects both Intel and Apple Silicon Macs. The report describes it as a 1 to 3 byte heap out-of-bounds read in the GPU process.

Setup

The testing was done on Chromium commit d0f83d769eeed, on macOS with the Metal backend. To make the out-of-bounds read visible to AddressSanitizer, the ANGLE feature useShadowBuffersWhenAppropriate has to be enabled at runtime, so that UBO shadow copies are allocated through malloc and are therefore tracked by ASAN. Without that feature, the read targets a Metal buffer mapping with driver-level alignment padding: the out-of-bounds read still happens, but ASAN may not catch it. On Intel Macs the feature is enabled by default, so the environment override is not needed there; elsewhere it can be force-enabled.

The build is a Chromium ASAN build. A minimal args.gn for out/asan-release:

Text
is_asan = true
is_debug = false
is_component_build = false
symbol_level = 1

Finding it

The starting point is the bounds check that guards the bool conversion. A prior commit, [redacted] ("Metal: upstream 'UBO convert only whole block'"), added a check of the form srcBool < maxSrcPtr to this code path. That check looks reasonable at a glance, but it only establishes that the start of the value lies inside the buffer. The very next operation dereferences a 4-byte unsigned int starting at that pointer. If the pointer sits in the last one to three bytes of the allocation, the check passes and the read runs past the end.

The introducing commit for the affected code is [redacted], dated Wed Jan 25 18:50:40 2023 -0800, authored by Kyle Piddington, reviewed at https://chromium-review.googlesource.com/c/angle/angle/+/4209867.

Exploitation

Step 1: understand how many blocks get processed

legalizeUniformBufferOffsets computes the number of bytes to convert as the full buffer size minus the initial source offset:

C++
// ProgramExecutableMtl.mm — legalizeUniformBufferOffsets
size_t sizeToCopy = bufferMtl->size() - conversion->initialSrcOffset();

// ProgramExecutableMtl.mm — ConvertUniformBufferData
const uint8_t *maxSrcPtr = sourceData + sizeToCopy;
size_t numBlocksToCopy =
    (sizeToCopy + blockConversionInfo.stdSize() - 1) / blockConversionInfo.stdSize();

The ceiling division means that when the buffer size is not an exact multiple of the block's std140 size, a partial final block is still processed. That partial block is the entry point for the bug.

Step 2: look at the bool branch

Inside the per-block loop, the bool conversion computes the source pointer and then guards the dereference:

C++
// ProgramExecutableMtl.mm — ConvertUniformBufferData, bool branch
const uint8_t *srcBool =
    (sourceData + stdIterator->offset + stdArrayOffset +
     blockConversionInfo.stdSize() * i +
     gl::VariableComponentSize(GL_BOOL) * boolCol);
unsigned int srcValue =
    srcBool < maxSrcPtr ? *((unsigned int *)(srcBool)) : 0;

The guard compares the pointer against maxSrcPtr, but the dereference reads 4 bytes from srcBool. When srcBool points at, for example, the last byte of the buffer, the comparison succeeds and the read extends 3 bytes beyond the allocation.

Step 3: get a buffer whose size is not a multiple of the block size

ANGLE's Metal backend rounds buffer sizes up to 16 bytes when a buffer is first created as UNIFORM_BUFFER. That round-up does not happen when the buffer is first created as ARRAY_BUFFER and only later bound to a uniform buffer binding point. The report notes this is a known gap, acknowledged in a TODO in BufferMtl::setDataImpl:

C++
// BufferMtl.mm — setDataImpl
if (target == gl::BufferBinding::Uniform)
{
    // This doesn't work! A buffer can be allocated on ARRAY_BUFFER and used in UNIFORM_BUFFER
    // TODO(anglebug.com/42266052)
    adjustedSize = roundUpPow2(adjustedSize, (size_t)16);
}

So the trigger is a buffer created as ARRAY_BUFFER with a size that is not a multiple of the block's std140 size, then bound to a uniform buffer binding point with bindBufferRange.

Step 4: work through the concrete numbers

A uniform block declared as layout(std140) uniform U { bool b; } has stdSize = 4. Create a buffer as ARRAY_BUFFER with 5 bytes and bind it to a uniform buffer binding. Then sizeToCopy = 5 and numBlocksToCopy = ceil(5/4) = 2. On the second block iteration srcBool = sourceData + 4. Since 4 < 5, the check passes, but the 4-byte read at offset 4 touches bytes [4..7], three bytes past the end of the 5-byte allocation.

Step 5: build and run with ASAN

Build the ASAN configuration:

autoninja -C ~/chromium/src/out/asan-release chrome

Launch Chrome with the PoC, forcing the Metal backend and the shadow buffer feature:

ANGLE_FEATURE_OVERRIDES_ENABLED=useShadowBuffersWhenAppropriate \
ASAN_OPTIONS=detect_odr_violation=0 \
~/chromium/src/out/asan-release/Chromium.app/Contents/MacOS/Chromium \
  --no-sandbox --use-angle=metal \
  --user-data-dir=/tmp/poc-$(date +%s) \
  poc.html

ANGLE_FEATURE_OVERRIDES_ENABLED turns on the shadow buffer path so the UBO copy is a malloc allocation ASAN can track, --use-angle=metal selects the Metal backend, and the throwaway --user-data-dir keeps the run isolated.

Step 6: read the ASAN report

The GPU process reports a heap-buffer-overflow in rx::ProgramExecutableMtl::legalizeUniformBufferOffsets with a READ of size 4. The shadow byte pattern [05] confirms a 5-byte allocation where a 4-byte read starting at offset 4 overflows by 3 bytes. The key lines of the output:

Text
==11248==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000010014 at pc 0x000307933094 bp 0x00016bccbcb0 sp 0x00016bccbca8
READ of size 4 at 0x602000010014 thread T0
    #0 0x000307933090 in rx::ProgramExecutableMtl::legalizeUniformBufferOffsets(rx::ContextMtl*)+0x1580
    #1 0x0003079308a4 in rx::ProgramExecutableMtl::updateUniformBuffers(rx::ContextMtl*, rx::mtl::RenderCommandEncoder*, rx::mtl::RenderPipelineDesc const&)+0x1a4
    #2 0x00030792ea94 in rx::ProgramExecutableMtl::setupDraw(gl::Context const*, rx::mtl::RenderCommandEncoder*, rx::mtl::RenderPipelineDesc const&, bool, bool, bool)+0x340
    #3 0x0003078fd4b0 in rx::ContextMtl::setupDrawImpl(gl::Context const*, gl::PrimitiveMode, int, int, int, gl::DrawElementsType, void const*, bool, bool*)+0xb28
    #4 0x0003078efbc0 in rx::ContextMtl::drawArraysImpl(gl::Context const*, gl::PrimitiveMode, int, int, int, unsigned int)+0x2cc
    #5 0x0003078f1ad4 in rx::ContextMtl::drawArrays(gl::Context const*, gl::PrimitiveMode, int, int)+0x158
    #6 0x000307033f3c in GL_DrawArrays+0x4f0
    #7 0x00010b06457c in gl::RealGLApi::glDrawArraysFn(unsigned int, int, int)+0x19c
    #8 0x00014777ec50 in gpu::gles2::GLES2DecoderPassthroughImpl::DoDrawArrays(unsigned int, int, int)+0x94

0x602000010015 is located 0 bytes after 5-byte region [0x602000010010,0x602000010015)
allocated by thread T0 here:
    #0 0x000104a3cdb8 in __asan_memmove+0x2fd8
    #1 0x000307a05a60 in angle::MemoryBuffer::resize(unsigned long)+0x50
    #2 0x0003078e04b4 in rx::BufferMtl::setDataImpl(gl::Context const*, gl::BufferBinding, void const*, unsigned long, gl::BufferUsage, rx::BufferFeedback*)+0x29c
    #3 0x0003073eab88 in gl::Buffer::setDataWithUsageFlags(...)+0x130
    #4 0x0003073ea688 in gl::Buffer::bufferDataImpl(...)+0x1d0
    #5 0x000147778850 in gpu::gles2::GLES2DecoderPassthroughImpl::DoBufferData(unsigned int, long, void const*, unsigned int)+0xb0

SUMMARY: AddressSanitizer: heap-buffer-overflow in rx::ProgramExecutableMtl::legalizeUniformBufferOffsets(rx::ContextMtl*)+0x1580
=>0x602000010000: f7 fa[05]fa f7 fa fd fa f7 fa fd fd f7 fa fd fa

The stack shows the path from the WebGL draw call (glDrawArrays through the passthrough decoder) into setupDraw, updateUniformBuffers and finally legalizeUniformBufferOffsets. The allocation stack shows the 5-byte region coming from BufferMtl::setDataImpl via angle::MemoryBuffer::resize, matching the ARRAY_BUFFER creation described above.

Root cause

The bounds check srcBool < maxSrcPtr validates only the first byte of a 4-byte access. The dereference *((unsigned int *)(srcBool)) reads four bytes, so a pointer in the last one to three bytes of the allocation passes the check and the read runs past the end. The ceiling division in numBlocksToCopy is what allows a partial final block to be processed at all, and the missing 16-byte round-up for buffers created as ARRAY_BUFFER and later bound as uniform buffers is what allows a buffer size that is not a multiple of stdSize to reach this code. The existing defence, the srcBool < maxSrcPtr check added by [redacted], was insufficient because it did not account for the width of the read.

Impact

The result is a 1 to 3 byte heap out-of-bounds read in the GPU process, reachable from any WebGL2 page on macOS using the Metal backend, on both Intel and Apple Silicon Macs. The report does not describe what an attacker could do with the leaked bytes beyond the read itself. Detection by ASAN depends on the shadow buffer path being active; without it the read still occurs but lands in driver-aligned padding and may go unnoticed.

Fix

The report does not describe a fix. The check would need to account for the full 4-byte dereference, for example by requiring that the whole read fits within maxSrcPtr, rather than only that the starting pointer is below it.

Variants to test

  1. Other partial-block conversions in the same loop: any member type whose std140 size differs from its native size, combined with a buffer size that is not a multiple of stdSize. A positive result is an ASAN report in legalizeUniformBufferOffsets with a read width matching the member type.
  2. Buffers created as ARRAY_BUFFER and rebound to other binding points that skip the 16-byte round-up. A positive result is a heap allocation whose size is not a multiple of 16 reaching the conversion code.
  3. The same pattern on other ANGLE backends that perform layout conversion at draw time. A positive result is an out-of-bounds read reported at the corresponding conversion function.
  4. Other pointer-plus-width checks of the form ptr < end followed by a wider dereference. A positive result is a read that crosses the end of the allocation while the pointer comparison still succeeds.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 16 min read.

What happened, in plain words

A web page can ask your graphics card to draw things. Chrome does this through a piece of software called ANGLE, which translates the drawing instructions a web page writes into the language your operating system's graphics system understands. On a Mac, that native language is called Metal.

When a web page sends a small block of settings to the graphics card (for example, a true/false switch that changes how something is drawn), ANGLE has to reformat that block, because the web standard and Metal store true/false values in different sizes. The reformatting code had a check that was meant to stop it reading past the end of the block. The check was not strict enough: it confirmed that the start of a value was inside the block, but then read four bytes from there, which could run one to three bytes past the end.

Reading past the end of a reserved area of memory is called an out-of-bounds read. In this case it happened inside Chrome's GPU process, the separate program that talks to the graphics card. The bug could be triggered by any WebGL2 page on macOS using the Metal backend, on both Intel and Apple Silicon Macs. The researcher asked to be credited under the identifier [redacted].

This article walks through the report step by step, explaining each idea from scratch.

Background concepts

Before the details, a few terms that come up constantly.

  • WebGL2: a browser feature that lets a web page draw 3D and 2D graphics using the graphics card. A page written with WebGL2 can run on any browser that supports it.
  • GPU: the graphics processing unit, the chip that draws images. Chrome runs GPU work in a separate process (the GPU process) so that a crash or bug there does not take down the whole browser.
  • ANGLE: a translation layer inside Chrome. Web pages speak one graphics language (OpenGL ES / WebGL); each operating system speaks its own (Metal on macOS, Direct3D on Windows, and so on). ANGLE converts between them.
  • Metal: Apple's own graphics API, the set of instructions macOS provides for talking to the GPU.
  • Shader: a small program that runs on the GPU to decide the colour of each pixel or the position of each shape.
  • Uniform: a value a web page passes into a shader, such as a colour or a true/false flag. It stays the same for every pixel in a single draw.
  • Uniform buffer object (UBO): a chunk of memory that holds several uniforms together, so they can be sent to the GPU in one go.
  • std140: a set of rules from the graphics standard that says exactly how the fields inside a uniform buffer are laid out in memory, including how many bytes each type takes. Under std140, a bool takes 4 bytes.
  • Heap: the general-purpose pool of memory a program uses for data it creates while running. Reading past the end of a heap allocation is a classic memory-safety bug.
  • Out-of-bounds read: reading memory outside the area a program reserved. It does not corrupt anything, but it can leak data or crash the program.
  • AddressSanitizer (ASAN): a debugging tool built into the compiler that watches memory accesses and reports when a program reads or writes outside an allocation. It is how the researcher made the bug visible.
  • Commit: a saved change in a source-code repository, identified by a long hexadecimal string.

Context

The bug is an out-of-bounds read in Chrome's GPU process. It can be reached from any WebGL2 page on macOS when the Metal backend is in use. The affected component is ANGLE, and the relevant code lives in ANGLE's Metal backend, in a file called ProgramExecutableMtl.mm.

The feature involved is uniform buffer object conversion. In WebGL2, a shader can declare a uniform block whose members follow the std140 layout rules. Under std140 a bool occupies 4 bytes. Metal's native layout stores a bool in 1 byte. So when a shader uses a uniform block containing a bool, ANGLE's Metal backend has to rewrite the buffer contents at draw time, expanding or contracting each bool between the two representations. That rewrite is done by a function called ConvertUniformBufferData, which is called from legalizeUniformBufferOffsets when a draw is set up.

The bug affects both Intel and Apple Silicon Macs. The report describes it as a 1 to 3 byte heap out-of-bounds read in the GPU process.

Setup

The testing was done on Chromium commit d0f83d769eeed, on macOS with the Metal backend. To make the out-of-bounds read visible to AddressSanitizer, the ANGLE feature useShadowBuffersWhenAppropriate has to be enabled at runtime, so that UBO shadow copies are allocated through malloc and are therefore tracked by ASAN. Without that feature, the read targets a Metal buffer mapping with driver-level alignment padding: the out-of-bounds read still happens, but ASAN may not catch it. On Intel Macs the feature is enabled by default, so the environment override is not needed there; elsewhere it can be force-enabled.

The build is a Chromium ASAN build. A minimal args.gn for out/asan-release:

Text
is_asan = true
is_debug = false
is_component_build = false
symbol_level = 1

Line by line:

  1. is_asan = true turns on AddressSanitizer, the memory-checking tool used to detect the read.
  2. is_debug = false builds a non-debug configuration with ASAN enabled.
  3. is_component_build = false links the browser into fewer, larger libraries instead of many separate shared libraries.
  4. symbol_level = 1 keeps a reduced amount of debugging information in the binary.

Finding it

The starting point is the bounds check that guards the bool conversion. A prior commit, [redacted] ("Metal: upstream 'UBO convert only whole block'"), added a check of the form srcBool < maxSrcPtr to this code path. That check looks reasonable at a glance, but it only establishes that the start of the value lies inside the buffer. The very next operation reads a 4-byte unsigned int starting at that pointer. If the pointer sits in the last one to three bytes of the allocation, the check passes and the read runs past the end.

The introducing commit for the affected code is [redacted], dated Wed Jan 25 18:50:40 2023 -0800, authored by Kyle Piddington, reviewed at https://chromium-review.googlesource.com/c/angle/angle/+/4209867.

Exploitation

Step 1: understand how many blocks get processed

legalizeUniformBufferOffsets computes the number of bytes to convert as the full buffer size minus the initial source offset:

C++
// ProgramExecutableMtl.mm — legalizeUniformBufferOffsets
size_t sizeToCopy = bufferMtl->size() - conversion->initialSrcOffset();

// ProgramExecutableMtl.mm — ConvertUniformBufferData
const uint8_t *maxSrcPtr = sourceData + sizeToCopy;
size_t numBlocksToCopy =
    (sizeToCopy + blockConversionInfo.stdSize() - 1) / blockConversionInfo.stdSize();

What each line does:

  1. size_t sizeToCopy = bufferMtl->size() - conversion->initialSrcOffset(); works out how many bytes still need converting: the total buffer size minus however far into the buffer the conversion starts.
  2. const uint8_t *maxSrcPtr = sourceData + sizeToCopy; sets a marker pointer at the end of the region to be converted. Adding sizeToCopy to the start pointer puts maxSrcPtr one byte past the end of the region to be converted.
  3. size_t numBlocksToCopy = (sizeToCopy + blockConversionInfo.stdSize() - 1) / blockConversionInfo.stdSize(); calculates how many blocks fit in that region. Adding stdSize - 1 before dividing is a standard trick called ceiling division: it rounds up instead of down. So if the region is not an exact multiple of the block size, the last, partial block is still counted and processed.

That ceiling division is the entry point for the bug: it allows a partial final block to be handled, and a partial block is where the read can run past the end.

Step 2: look at the bool branch

Inside the per-block loop, the bool conversion computes the source pointer and then guards the read:

C++
// ProgramExecutableMtl.mm — ConvertUniformBufferData, bool branch
const uint8_t *srcBool =
    (sourceData + stdIterator->offset + stdArrayOffset +
     blockConversionInfo.stdSize() * i +
     gl::VariableComponentSize(GL_BOOL) * boolCol);
unsigned int srcValue =
    srcBool < maxSrcPtr ? *((unsigned int *)(srcBool)) : 0;

What each line does:

  1. const uint8_t *srcBool = ... declares a pointer to the byte where the current bool value starts.
  2. sourceData + stdIterator->offset + stdArrayOffset + blockConversionInfo.stdSize() * i + gl::VariableComponentSize(GL_BOOL) * boolCol adds up several offsets: the start of the buffer, the position of this field within the block, any array offset, the size of each block times the block index i, and the size of a bool times the column index boolCol. The result is the exact address of the bool being converted.
  3. srcBool < maxSrcPtr ? *((unsigned int *)(srcBool)) : 0; is a conditional expression. If the pointer is below the end marker, it reads 4 bytes (unsigned int) from that address; otherwise it uses 0. The (unsigned int *)(srcBool) part is a cast: it tells the compiler to treat the byte pointer as a pointer to a 4-byte integer.

The guard compares the pointer against maxSrcPtr, but the read takes 4 bytes from srcBool. When srcBool points at, for example, the last byte of the buffer, the comparison succeeds and the read extends 3 bytes beyond the allocation.

Step 3: get a buffer whose size is not a multiple of the block size

ANGLE's Metal backend rounds buffer sizes up to 16 bytes when a buffer is first created as UNIFORM_BUFFER. That round-up does not happen when the buffer is first created as ARRAY_BUFFER and only later bound to a uniform buffer binding point. The report notes this is a known gap, acknowledged in a TODO in BufferMtl::setDataImpl:

C++
// BufferMtl.mm — setDataImpl
if (target == gl::BufferBinding::Uniform)
{
    // This doesn't work! A buffer can be allocated on ARRAY_BUFFER and used in UNIFORM_BUFFER
    // TODO(anglebug.com/42266052)
    adjustedSize = roundUpPow2(adjustedSize, (size_t)16);
}

What each line does:

  1. if (target == gl::BufferBinding::Uniform) checks whether the buffer is being created for use as a uniform buffer.
  2. The comment records the known problem: a buffer can be allocated as an ARRAY_BUFFER (a general-purpose buffer used for vertex data) and later used as a uniform buffer, and the code below does not cover that case.
  3. adjustedSize = roundUpPow2(adjustedSize, (size_t)16); rounds the buffer size up to a multiple of 16 bytes. This is the protection that is skipped for buffers created as ARRAY_BUFFER.

So the trigger is a buffer created as ARRAY_BUFFER with a size that is not a multiple of the block's std140 size, then bound to a uniform buffer binding point with bindBufferRange.

Step 4: work through the concrete numbers

A uniform block declared as layout(std140) uniform U { bool b; } has stdSize = 4. Create a buffer as ARRAY_BUFFER with 5 bytes and bind it to a uniform buffer binding. Then sizeToCopy = 5 and numBlocksToCopy = ceil(5/4) = 2. On the second block iteration srcBool = sourceData + 4. Since 4 < 5, the check passes, but the 4-byte read at offset 4 touches bytes [4..7], three bytes past the end of the 5-byte allocation.

In everyday terms: imagine a shelf with room for exactly five books. The check asks "is the book I want to pick up somewhere on the shelf?" and the answer is yes for the fifth slot. But the action is "pick up four books starting here", and there are only one book's worth of space left, so three books are grabbed from beyond the shelf.

Step 5: build and run with ASAN

Build the ASAN configuration:

autoninja -C ~/chromium/src/out/asan-release chrome

This runs the build tool autoninja in the output directory ~/chromium/src/out/asan-release and builds the target called chrome. The -C flag tells the tool which directory to work in.

Launch Chrome with the PoC, forcing the Metal backend and the shadow buffer feature:

ANGLE_FEATURE_OVERRIDES_ENABLED=useShadowBuffersWhenAppropriate \
ASAN_OPTIONS=detect_odr_violation=0 \
~/chromium/src/out/asan-release/Chromium.app/Contents/MacOS/Chromium \
  --no-sandbox --use-angle=metal \
  --user-data-dir=/tmp/poc-$(date +%s) \
  poc.html

What each part does:

  1. ANGLE_FEATURE_OVERRIDES_ENABLED=useShadowBuffersWhenAppropriate turns on the shadow buffer path, so the UBO copy is a malloc allocation that ASAN can track. Without it, the copy may live in driver-managed memory that ASAN cannot see.
  2. ASAN_OPTIONS=detect_odr_violation=0 turns off ASAN's one-definition-rule violation check for this run.
  3. ~/chromium/src/out/asan-release/Chromium.app/Contents/MacOS/Chromium is the path to the browser binary that was just built.
  4. --no-sandbox runs the browser without Chrome's process sandbox.
  5. --use-angle=metal selects the Metal backend.
  6. --user-data-dir=/tmp/poc-$(date +%s) sets the profile directory, named with the current timestamp.
  7. poc.html is the proof-of-concept page passed to Chrome.

Step 6: read the ASAN report

The GPU process reports a heap-buffer-overflow in rx::ProgramExecutableMtl::legalizeUniformBufferOffsets with a READ of size 4. The shadow byte pattern [05] confirms a 5-byte allocation where a 4-byte read starting at offset 4 overflows by 3 bytes. The key lines of the output:

Text
==11248==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000010014 at pc 0x000307933094 bp 0x00016bccbcb0 sp 0x00016bccbca8
READ of size 4 at 0x602000010014 thread T0
    #0 0x000307933090 in rx::ProgramExecutableMtl::legalizeUniformBufferOffsets(rx::ContextMtl*)+0x1580
    #1 0x0003079308a4 in rx::ProgramExecutableMtl::updateUniformBuffers(rx::ContextMtl*, rx::mtl::RenderCommandEncoder*, rx::mtl::RenderPipelineDesc const&)+0x1a4
    #2 0x00030792ea94 in rx::ProgramExecutableMtl::setupDraw(gl::Context const*, rx::mtl::RenderCommandEncoder*, rx::mtl::RenderPipelineDesc const&, bool, bool, bool)+0x340
    #3 0x0003078fd4b0 in rx::ContextMtl::setupDrawImpl(gl::Context const*, gl::PrimitiveMode, int, int, int, gl::DrawElementsType, void const*, bool, bool*)+0xb28
    #4 0x0003078efbc0 in rx::ContextMtl::drawArraysImpl(gl::Context const*, gl::PrimitiveMode, int, int, int, unsigned int)+0x2cc
    #5 0x0003078f1ad4 in rx::ContextMtl::drawArrays(gl::Context const*, gl::PrimitiveMode, int, int)+0x158
    #6 0x000307033f3c in GL_DrawArrays+0x4f0
    #7 0x00010b06457c in gl::RealGLApi::glDrawArraysFn(unsigned int, int, int)+0x19c
    #8 0x00014777ec50 in gpu::gles2::GLES2DecoderPassthroughImpl::DoDrawArrays(unsigned int, int, int)+0x94

0x602000010015 is located 0 bytes after 5-byte region [0x602000010010,0x602000010015)
allocated by thread T0 here:
    #0 0x000104a3cdb8 in __asan_memmove+0x2fd8
    #1 0x000307a05a60 in angle::MemoryBuffer::resize(unsigned long)+0x50
    #2 0x0003078e04b4 in rx::BufferMtl::setDataImpl(gl::Context const*, gl::BufferBinding, void const*, unsigned long, gl::BufferUsage, rx::BufferFeedback*)+0x29c
    #3 0x0003073eab88 in gl::Buffer::setDataWithUsageFlags(...)+0x130
    #4 0x0003073ea688 in gl::Buffer::bufferDataImpl(...)+0x1d0
    #5 0x000147778850 in gpu::gles2::GLES2DecoderPassthroughImpl::DoBufferData(unsigned int, long, void const*, unsigned int)+0xb0

SUMMARY: AddressSanitizer: heap-buffer-overflow in rx::ProgramExecutableMtl::legalizeUniformBufferOffsets(rx::ContextMtl*)+0x1580
=>0x602000010000: f7 fa[05]fa f7 fa fd fa f7 fa fd fd f7 fa fd fa

How to read it:

  1. The first line says ASAN found a heap-buffer-overflow at a particular memory address. "Heap-buffer-overflow" is ASAN's name for an access outside a heap allocation.
  2. READ of size 4 says the program tried to read 4 bytes, and the address is the one that was out of bounds.
  3. The numbered #0, #1, #2 lines are the call stack: the chain of function calls that led to the bad read. #0 is where it happened (legalizeUniformBufferOffsets), and the lines below show how the program got there: updateUniformBuffers, then setupDraw, then drawArraysImpl, then drawArrays, then GL_DrawArrays, then glDrawArraysFn, then DoDrawArrays. In other words, a WebGL draw call from the page travelled through the passthrough decoder into the Metal backend and ended in the buggy conversion.
  4. 0x602000010015 is located 0 bytes after 5-byte region [0x602000010010,0x602000010015) says the allocation was exactly 5 bytes, and the bad address is right after it.
  5. The second stack, under allocated by thread T0 here, shows where that 5-byte region came from: BufferMtl::setDataImpl via angle::MemoryBuffer::resize, which matches the ARRAY_BUFFER creation described above.
  6. SUMMARY repeats the finding in one line.
  7. The =>0x602000010000: f7 fa[05]fa ... line is the shadow memory view. ASAN keeps a parallel map where each byte records how many bytes of the corresponding 8-byte region are valid. 05 means five of the eight bytes in that region are valid, and the brackets mark the shadow byte covering the bad access. fa marks a heap redzone (a guard area around an allocation) and fd marks freed heap memory.

Root cause

The bounds check srcBool < maxSrcPtr validates only the first byte of a 4-byte access. The read *((unsigned int *)(srcBool)) takes four bytes, so a pointer in the last one to three bytes of the allocation passes the check and the read runs past the end. The ceiling division in numBlocksToCopy is what allows a partial final block to be processed at all, and the missing 16-byte round-up for buffers created as ARRAY_BUFFER and later bound as uniform buffers is what allows a buffer size that is not a multiple of stdSize to reach this code. The existing defence, the srcBool < maxSrcPtr check added by [redacted], was insufficient because it did not account for the width of the read.

Impact

The result is a 1 to 3 byte heap out-of-bounds read in the GPU process, reachable from any WebGL2 page on macOS using the Metal backend, on both Intel and Apple Silicon Macs. The report does not describe what an attacker could do with the leaked bytes beyond the read itself. Detection by ASAN depends on the shadow buffer path being active; without it the read still occurs but lands in driver-aligned padding and may go unnoticed.

Fix

The report does not describe a fix. The check would need to account for the full 4-byte read, for example by requiring that the whole read fits within maxSrcPtr, rather than only that the starting pointer is below it.

Variants to test

  1. Other partial-block conversions in the same loop: any member type whose std140 size differs from its native size, combined with a buffer size that is not a multiple of stdSize. A positive result is an ASAN report in legalizeUniformBufferOffsets with a read width matching the member type.
  2. Buffers created as ARRAY_BUFFER and rebound to other binding points that skip the 16-byte round-up. A positive result is a heap allocation whose size is not a multiple of 16 reaching the conversion code.
  3. The same pattern on other ANGLE backends that perform layout conversion at draw time. A positive result is an out-of-bounds read reported at the corresponding conversion function.
  4. Other pointer-plus-width checks of the form ptr < end followed by a wider read. A positive result is a read that crosses the end of the allocation while the pointer comparison still succeeds.

Glossary

  • AddressSanitizer (ASAN): a tool built into the compiler that detects out-of-bounds and use-after-free memory accesses at runtime.
  • ANGLE: the translation layer in Chrome that converts WebGL and OpenGL ES calls into the platform's native graphics API.
  • API: an application programming interface, the set of functions one piece of software offers to another.
  • ARRAY_BUFFER: a general-purpose buffer in WebGL, normally used for vertex data.
  • bindBufferRange: the WebGL call that attaches a buffer to a binding point, optionally for only part of the buffer.
  • bool: a true/false value.
  • Bounds check: code that verifies an access stays within an allowed region before performing it.
  • Call stack: the list of function calls currently in progress, from the innermost outwards.
  • Ceiling division: division rounded up to the next whole number, here done by adding size - 1 before dividing.
  • Dereference: reading the value stored at a memory address pointed to by a pointer.
  • GPU: graphics processing unit, the chip that draws images.
  • GPU process: the separate Chrome process that performs graphics work.
  • Heap: the pool of memory a program uses for data created while running.
  • malloc: the standard C function for allocating memory on the heap.
  • Metal: Apple's native graphics API.
  • Partial block: a final block of data that is smaller than the full block size.
  • Pointer: a value that holds a memory address.
  • PoC: proof of concept, a small test that demonstrates a bug.
  • Redzone: a guard area ASAN places around allocations to detect accesses that stray outside them.
  • Shader: a small program that runs on the GPU.
  • Shadow buffer: a CPU-side copy of a GPU buffer, used here so ASAN can track the memory.
  • Shadow memory: ASAN's parallel map recording which bytes of program memory are valid.
  • std140: the graphics standard's rules for laying out uniform block members in memory.
  • stdSize: the size of one block under the std140 layout.
  • UBO (uniform buffer object): a block of memory holding several uniform values sent to the GPU together.
  • Uniform: a value passed from the page into a shader that stays constant for a draw.
  • WebGL2: the browser feature that lets web pages draw using the GPU.

More by c6eed09fc8b174b0f3eebedcceb1e792

View all

52 more disclosed reports, best first.

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.