Use after free in GPU (CVE-2026-9894)
- Fix shipped in 29 days
Report description
GPU passthrough decoder UAF: DoBufferData GL error path skips mapped_buffer_map.erase()
Bug location
Where do you want to report your vulnerability?
Chrome VRP – Report security issues affecting the Chrome browser. See program rules
Which URL (or repository) have you found the vulnerability in?
The problem
Please describe the technical details of the vulnerability
Vulnerability Description
GLES2DecoderPassthroughImpl::DoBufferData in the GPU passthrough decoder does not clean up the mapped_buffer_map entry when glBufferData returns a GL error. The result is that DoUnmapBuffer later finds a stale entry with map_ptr pointing to freed driver memory and writes renderer-controlled data into it.
The relevant code in gles2_cmd_decoder_passthrough_doers.cc (current HEAD, ~line 618):
CheckErrorCallbackState();
api()->glBufferDataFn(target, size, data, usage);
if (CheckErrorCallbackState()) {
return error::kNoError; // early return, no erase
}
resources_->mapped_buffer_map.erase(bound_buffers_[target]); // not reached on error
CheckErrorCallbackState() works through the KHR_debug callback (PassthroughGLDebugMessageCallback -> OnDebugMessage -> had_error_callback_ = true). Any GL error from glBufferDataFn causes the early return. The most impactful case is GL_OUT_OF_MEMORY, where the driver frees the old backing store and the map_ptr in the remaining mapped_buffer_map entry now points to freed memory.
The same vulnerability was fixed in the validating decoder in commit daeb9ba8d7ce (Bug 498715368) with this comment in buffer_manager.cc:
// SECURITY: ... Clear it here so that UnmapBufferHelper does not memcpy
// renderer-controlled SHM into freed driver memory.
buffer->ClearMapping();
The passthrough decoder was not included in that fix.
Attack Preconditions
Attacker has a compromised renderer process (standard precondition for GPU process bugs). The GPU passthrough decoder must be active, which is the case by default on Windows, macOS, and Linux: ui/gl/features.gni sets enable_validating_command_decoder = is_android, so on desktop builds UsePassthroughCommandDecoder() in gl_utils.cc returns true unconditionally.
Reproduction Steps / POC
I added a regression test to the existing passthrough decoder test suite: gpu/command_buffer/service/gles2_cmd_decoder_passthrough_unittest_buffers.cc
Test name: GLES3DecoderPassthroughTest.BufferDataGLErrorLeavesStaleMapEntry
Steps the test performs:
- Create and bind a buffer, map it with GL_MAP_WRITE_BIT. Confirms the entry is added to mapped_buffer_map.
- Submit a BufferData command with size=-1. This triggers GL_INVALID_VALUE, which fires the KHR_debug callback and causes DoBufferData to take the early-return path. Functionally the same as GL_OUT_OF_MEMORY for this code path.
- Assert that the mapped_buffer_map entry is still present (bug confirmed).
Output from the ASAN build (out/asan/gpu_unittests, macOS arm64, ANGLE null backend):
[ RUN ] GLES3DecoderPassthroughTest.BufferDataGLErrorLeavesStaleMapEntry
[ERROR] GL_INVALID_VALUE: glBufferData: Negative size.
[ OK ] GLES3DecoderPassthroughTest.BufferDataGLErrorLeavesStaleMapEntry (3584 ms)
The EXPECT_NE assertion passes, confirming the stale entry is present after the GL error. On real hardware with GL_OUT_OF_MEMORY the map_ptr would point to freed driver memory, and a subsequent glUnmapBuffer call from the renderer would trigger:
memcpy(map_info.map_ptr, renderer_shm, map_info.size)
That memcpy is a heap-use-after-free write in the GPU process with renderer-controlled content and size.
Fix: add the erase before the early return in DoBufferData:
if (CheckErrorCallbackState()) {
resources_->mapped_buffer_map.erase(bound_buffers_[target]);
return error::kNoError;
}
Impact analysis
A compromised renderer can trigger this by mapping a GPU buffer, then calling glBufferData with a large enough size to cause GL_OUT_OF_MEMORY. The GPU driver frees the old backing store. DoBufferData returns early without erasing the mapped_buffer_map entry. The renderer then calls glUnmapBuffer, which causes the GPU process to write attacker-controlled data into freed driver memory.
This gives an attacker a heap-use-after-free write primitive in the GPU process, with control over the write destination (via timing/heap grooming), the content (shared memory), and the size. The GPU process is a sandboxed process separate from the renderer. Exploiting this primitive to achieve GPU process code execution would constitute a sandbox escape from a compromised renderer.
The bug affects all desktop Chrome users on Windows, macOS, and Linux, since the passthrough decoder is enabled by default on those platforms.
The cause
What version of Chrome have you found the security issue in?
149.0.7815.0 (dev/canary) - confirmed on HEAD commit fc933fae76 (2026-04-28) 147.0.7727.138 (stable) - affected, bug predates current HEAD
Is the security issue related to a crash?
Yes, it is related to a crash.
Choose the type of vulnerability
Memory Corruption (in a sandboxed process)
How would you like to be publicly acknowledged for your report?
tohafrit
Context
This report concerns Google Chrome's GPU process, specifically the GPU passthrough command decoder. Chrome splits its work across processes: the renderer runs web content, and the GPU process handles graphics commands on its behalf. The command decoder is the component inside the GPU process that receives serialised GL commands from the renderer and executes them against the real graphics driver.
Chrome has two decoder implementations. The validating command decoder checks commands against a set of rules before passing them to the driver. The passthrough decoder forwards commands more directly to the driver, relying on the driver and on the command buffer's own bookkeeping for safety. The report states that the passthrough decoder is the default on desktop: ui/gl/features.gni sets enable_validating_command_decoder = is_android, so on Windows, macOS and Linux, UsePassthroughCommandDecoder() in gl_utils.cc returns true unconditionally.
The feature at issue is buffer mapping. A renderer can map a GPU buffer, receive a pointer into driver memory, and later unmap it. The decoder tracks mapped buffers in a map called mapped_buffer_map, keyed by the bound buffer. When the renderer unmaps, the decoder copies data from renderer shared memory into the mapped driver memory. The correctness of that copy depends entirely on the map entry being accurate.
The report is filed under the Chrome Vulnerability Reward Program, was disclosed on 2026-05-27, and carries a bounty of 25,000 USD. The weakness class is use after free, the severity is high, and the researcher is credited as tohafrit.
Setup
The preconditions are architectural:
- A compromised renderer process. The report calls this the standard precondition for GPU process bugs.
- The GPU passthrough decoder active. As noted above, this is the default on Windows, macOS and Linux desktop builds.
The code under review is in the Chromium source tree at:
https://source.chromium.org/chromium/chromium/src/+/main:gpu/command_buffer/service/[redacted].cc
The researcher reports the issue against Chrome 149.0.7815.0 (dev/canary), confirmed on HEAD commit fc933fae76 (2026-04-28), and states that 147.0.7727.138 (stable) is affected and that the bug predates the current HEAD.
For the regression test, the researcher used an ASAN build, out/asan/gpu_unittests, on macOS arm64 with the ANGLE null backend.
Finding it
The researcher focused on GLES2DecoderPassthroughImpl::DoBufferData in [redacted].cc, around line 618 at the time of the report. The relevant code is:
CheckErrorCallbackState();
api()->glBufferDataFn(target, size, data, usage);
if (CheckErrorCallbackState()) {
return error::kNoError; // early return, no erase
}
resources_->mapped_buffer_map.erase(bound_buffers_[target]); // not reached on error
The logic is that a successful glBufferData call invalidates any existing mapping, so the decoder erases the buffer's entry from mapped_buffer_map. But if the driver call produces a GL error, the function returns early and the erase never happens. The stale entry remains, and it still holds a map_ptr that the driver may have invalidated.
The error detection runs through the KHR_debug callback: CheckErrorCallbackState() observes state set by PassthroughGLDebugMessageCallback -> OnDebugMessage -> had_error_callback_ = true. Any GL error from glBufferDataFn therefore triggers the early return.
The researcher singles out GL_OUT_OF_MEMORY as the most impactful case. In that situation the driver frees the old backing store, so the map_ptr in the surviving mapped_buffer_map entry now points to freed memory.
The researcher also notes that the same class of bug had already been fixed in the validating decoder in commit daeb9ba8d7ce (Bug 498715368), with this comment in buffer_manager.cc:
// SECURITY: ... Clear it here so that UnmapBufferHelper does not memcpy
// renderer-controlled SHM into freed driver memory.
buffer->ClearMapping();
The passthrough decoder was not included in that fix.
Exploitation
Step 1: Map a buffer
The renderer creates and binds a buffer, then maps it with GL_MAP_WRITE_BIT. This adds an entry to mapped_buffer_map containing the mapping pointer and size. The regression test confirms this state before proceeding.
Step 2: Trigger a GL error from BufferData
The renderer submits a BufferData command with size=-1. This produces GL_INVALID_VALUE, which fires the KHR_debug callback and sends DoBufferData down the early-return path. The researcher notes that this is functionally the same as GL_OUT_OF_MEMORY for this code path: both leave the map entry in place. The difference is that with GL_OUT_OF_MEMORY on real hardware, the driver has also freed the old backing store, so the stale pointer is dangling.
Step 3: Confirm the stale entry
The test asserts that the mapped_buffer_map entry is still present after the error. The ASAN run output is:
[ RUN ] GLES3DecoderPassthroughTest.BufferDataGLErrorLeavesStaleMapEntry
[ERROR] GL_INVALID_VALUE: glBufferData: Negative size.
[ OK ] GLES3DecoderPassthroughTest.BufferDataGLErrorLeavesStaleMapEntry (3584 ms)
The EXPECT_NE assertion passes, which the researcher reads as confirmation that the stale entry survives the GL error. On real hardware with GL_OUT_OF_MEMORY, the map_ptr would point to freed driver memory.
Step 4: Unmap and write into freed memory
The renderer then calls glUnmapBuffer. The decoder looks up the stale entry and performs the copy:
memcpy(map_info.map_ptr, renderer_shm, map_info.size)
Because map_ptr refers to freed driver memory, this is a heap-use-after-free write in the GPU process. The content and size come from renderer-controlled shared memory.
Root cause
The mistake is an error path that skips cleanup. DoBufferData erases the mapped_buffer_map entry only on the success path. When CheckErrorCallbackState() reports a GL error, the function returns error::kNoError before reaching the erase. The map entry therefore outlives the driver allocation it describes.
The existing defence did not cover this path. The validating decoder had already been hardened with buffer->ClearMapping() in buffer_manager.cc, with a comment explicitly describing the risk of copying renderer-controlled shared memory into freed driver memory. The passthrough decoder, which is the default on desktop, was not part of that fix. The KHR_debug callback correctly detects the error, but the detection only causes an early return; it does not trigger the cleanup that the success path performs.
Impact
A compromised renderer can obtain a heap-use-after-free write primitive in the GPU process. According to the report, the attacker controls:
- The write destination, via timing and heap grooming.
- The content, which comes from renderer shared memory.
- The size, also from the mapping metadata.
The GPU process is sandboxed and separate from the renderer. The researcher states that exploiting this primitive to achieve GPU process code execution would constitute a sandbox escape from a compromised renderer. The report states that exploiting this primitive to achieve GPU process code execution would constitute a sandbox escape from a compromised renderer.
The affected population is all desktop Chrome users on Windows, macOS and Linux, because the passthrough decoder is enabled by default there. The report marks the issue as related to a crash and classifies it as memory corruption in a sandboxed process.
Fix
The researcher proposes adding the erase before the early return in DoBufferData:
if (CheckErrorCallbackState()) {
resources_->mapped_buffer_map.erase(bound_buffers_[target]);
return error::kNoError;
}
This makes the error path perform the same cleanup as the success path, so a later glUnmapBuffer cannot find a stale entry pointing at freed driver memory. The report proposes this change as the fix.
Variants to test
- Audit other
Do*functions in the passthrough decoder that erase frommapped_buffer_mapor similar resource maps after a driver call. A positive result is an early return onCheckErrorCallbackState()that precedes the erase, leaving a stale entry. - Look for other resource maps keyed by bound objects where a driver error skips cleanup, such as texture or renderbuffer bookkeeping. A positive result is a map entry that survives a GL error and is later dereferenced.
- Compare the validating and passthrough decoders for fixes that landed in only one of them, as happened with commit daeb9ba8d7ce. A positive result is a security comment in
buffer_manager.ccor similar with no equivalent in the passthrough path. - Exercise
GL_OUT_OF_MEMORYrather thanGL_INVALID_VALUEin a test harness, since the former is the case where the driver actually frees the backing store. A positive result under ASAN is a use-after-free report on the unmap copy. - Check whether other error-producing commands that invalidate mappings, beyond
BufferData, take the same early-return shape. A positive result is any command that leavesmapped_buffer_mappopulated after a driver error.
What happened, in plain words
This is a bug report about Google Chrome, the web browser. It describes a memory safety mistake inside one of Chrome's internal helper programs, called the GPU process. The mistake is a specific kind of bug called a use after free. In everyday terms: a program throws away a piece of memory (like deleting a file), keeps a note saying where that memory used to be, and later writes new data to that old address as if the memory were still there. If something else has since taken over that space, the write lands in the wrong place and can corrupt the program.
The report was filed through the Chrome Vulnerability Reward Program, a scheme where Google pays people who find and report security bugs in Chrome. The report was disclosed on 2026-05-27, the researcher is credited as tohafrit, the severity is high, and the bounty was 25,000 USD. The weakness class is use after free, and the affected component is the GPU.
This beginner version walks through the same material as the technical write-up, in the same order, and explains every term from scratch.
Context
What Chrome's processes are
A modern browser does not run everything in one program. It splits work into separate programs, called processes, so that a problem in one does not automatically bring down or compromise the others. Chrome has, among others:
- A renderer process, which runs the actual web page content: HTML, JavaScript, images and so on. Each tab typically gets its own renderer.
- A GPU process, which talks to the graphics hardware (the graphics card) on behalf of the renderer. Web pages that draw things (canvas, WebGL, video) need graphics commands executed, and the GPU process does that.
A process here means an independent running program with its own private memory. One process cannot normally read or write another process's memory; the operating system enforces that separation. This separation is a security boundary: if an attacker takes over the renderer, they still have to break out of it to reach the GPU process or the rest of the machine.
What the command decoder is
The renderer does not talk to the graphics driver directly. Instead it sends a stream of graphics commands to the GPU process, and a component inside the GPU process called the command decoder receives those commands and executes them against the real graphics driver.
An API (application programming interface) is a defined set of functions one piece of software offers to another. Here the relevant API is OpenGL ES, usually shortened to GL, a standard set of graphics functions. The renderer's commands are serialised GL commands: the renderer says "call this GL function with these arguments", and the decoder makes that call happen in the GPU process.
A driver is the software that lets the operating system talk to a piece of hardware. The graphics driver translates GL calls into instructions the graphics card understands.
The two decoders
Chrome has two implementations of this decoder:
- The validating command decoder. Before passing a command to the driver, it checks the command against a set of rules. Think of a careful clerk who reads every form and rejects anything that looks wrong before it reaches the manager.
- The passthrough command decoder. It forwards commands more directly to the driver, relying on the driver and on the command buffer's own bookkeeping for safety. Think of a clerk who passes forms straight through, trusting that the manager will catch problems.
The report states that the passthrough decoder is the default on desktop. Specifically, ui/gl/features.gni sets enable_validating_command_decoder = is_android, so on Windows, macOS and Linux, UsePassthroughCommandDecoder() in gl_utils.cc returns true unconditionally.
In plain words: a build setting file (features.gni) says "use the validating decoder only when building for Android". So on desktop operating systems the check function UsePassthroughCommandDecoder() always answers "yes, use passthrough". That matters because the bug lives in the passthrough decoder, so it affects desktop users by default.
The feature at issue: buffer mapping
A buffer in graphics is a block of memory the graphics system uses to hold data such as vertex positions or pixel values. Mapping a buffer means asking the graphics system: "give me a pointer to this buffer's memory so I can read or write it directly". A pointer is simply a memory address, a number that says where in memory something lives.
When a renderer maps a GPU buffer, it receives a pointer into driver memory. Later it unmaps the buffer, meaning it says "I am done with this memory". The decoder keeps a record of which buffers are currently mapped in a data structure called mapped_buffer_map. A map (in programming) is a lookup table: you give it a key (here, the bound buffer) and it gives you back a value (here, the mapping details, including the pointer and size).
When the renderer unmaps, the decoder copies data from the renderer's shared memory into the mapped driver memory. Shared memory (often abbreviated SHM) is a region of memory that two processes can both access, used here to pass data from the renderer to the GPU process. The correctness of that copy depends entirely on the map entry being accurate: if the entry says "the buffer is at address X", the copy goes to address X.
Report metadata
The report is filed under the Chrome Vulnerability Reward Program, was disclosed on 2026-05-27, and carries a bounty of 25,000 USD. The weakness class is use after free, the severity is high, and the researcher is credited as tohafrit.
Setup
What the researcher needed
The preconditions are architectural, meaning they come from how Chrome is built rather than from any configuration the researcher chose:
- A compromised renderer process. This means the attacker has already found and exploited some other bug that lets them run their own code inside the renderer. The report calls this the standard precondition for GPU process bugs: you start from a renderer you control and try to climb out.
- The GPU passthrough decoder active. As noted above, this is the default on Windows, macOS and Linux desktop builds, so no extra setup is needed there.
The code under review
The code is in the Chromium source tree. Chromium is the open-source project that Chrome is built from; its source code is publicly browsable. The location given is:
https://source.chromium.org/chromium/chromium/src/+/main:gpu/command_buffer/service/[redacted].cc
Line by line, in plain words:
https://source.chromium.orgis the website that hosts the Chromium source code browser./chromium/chromium/src/+/mainmeans: the Chromium project, thesrc(source) repository, on themainbranch (the main line of development).:gpu/command_buffer/service/[redacted].ccis the path to one specific file inside that repository. Thegpu/command_buffer/service/folders hold the GPU process's command handling code. The file name says it contains the "doers" for the passthrough GLES2 command decoder: the functions that actually carry out each GL command..ccis the file extension for C++ source files.
Versions
The researcher reports the issue against Chrome 149.0.7815.0 (dev/canary), confirmed on HEAD commit fc933fae76 (2026-04-28), and states that 147.0.7727.138 (stable) is affected and that the bug predates the current HEAD.
Some terms here:
- dev/canary is an early, experimental build channel of Chrome, updated very frequently, used for testing new code before it reaches ordinary users.
- stable is the normal release channel that most people run.
- HEAD means the most recent commit on a branch, that is, the latest state of the code.
- A commit is a saved snapshot of changes to a code repository, identified by a hash such as
fc933fae76. - Predates means the bug existed before that snapshot, so it is not something newly introduced by the latest changes.
The test environment
For the regression test, the researcher used an ASAN build, out/asan/gpu_unittests, on macOS arm64 with the ANGLE null backend.
- ASAN stands for AddressSanitizer, a tool built into the compiler that watches memory accesses at runtime and loudly reports out-of-bounds or use-after-free accesses. It is like a smoke detector for memory bugs.
out/asan/gpu_unittestsis the build output directory and the name of the test program: the GPU unit tests, compiled with ASAN enabled.- macOS arm64 means an Apple computer with an ARM-based processor (Apple Silicon).
- ANGLE is a translation layer Chrome uses so that GL calls work across different graphics backends. The null backend is a fake graphics backend that does nothing real; it is useful for tests because it runs anywhere without needing a real graphics card.
- A regression test is a test written to reproduce a specific bug so that, if the bug ever comes back, the test fails and alerts developers.
Finding it
The function in question
The researcher focused on GLES2DecoderPassthroughImpl::DoBufferData in [redacted].cc, around line 618 at the time of the report. The name breaks down as: GLES2DecoderPassthroughImpl is the class (the code object) implementing the passthrough decoder; DoBufferData is the function that carries out the BufferData command, which tells the graphics system to allocate or resize a buffer and fill it with data.
The relevant code is:
CheckErrorCallbackState();
api()->glBufferDataFn(target, size, data, usage);
if (CheckErrorCallbackState()) {
return error::kNoError; // early return, no erase
}
resources_->mapped_buffer_map.erase(bound_buffers_[target]); // not reached on error
Line by line, in plain words:
CheckErrorCallbackState();is a call before the driver call; the report does not describe its effect here.api()->glBufferDataFn(target, size, data, usage);actually calls the graphics driver's buffer data function.targetsays which kind of buffer,sizeis how big it should be,datais the initial contents, andusageis a hint about how the buffer will be used. This is the call that can fail.if (CheckErrorCallbackState()) {asks: did the driver report an error during that call?return error::kNoError; // early return, no eraseleaves the function immediately. The comment in the original code says it plainly: this is an early return and no erase happens.error::kNoErrormeans "as far as the command buffer's own error reporting is concerned, nothing went wrong here".resources_->mapped_buffer_map.erase(bound_buffers_[target]); // not reached on erroris the cleanup: remove the buffer's entry from the map of mapped buffers. The comment notes it is not reached when there was an error.
The intended logic is that a successful glBufferData call invalidates any existing mapping, so the decoder erases the buffer's entry from mapped_buffer_map. But if the driver call produces a GL error, the function returns early and the erase never happens. The stale entry remains, and it still holds a map_ptr (the mapping pointer) that the driver may have invalidated.
A useful comparison: imagine a cloakroom. You hand in your coat and get a ticket (the map entry). When you take the coat back, the attendant should tear up the ticket. Here, if something goes wrong at the counter, the attendant walks away without tearing up the ticket, so the ticket still exists even though the coat is gone. Anyone holding that ticket later will be sent to an empty hook.
How the error is detected
The error detection runs through the KHR_debug callback: CheckErrorCallbackState() observes state set by PassthroughGLDebugMessageCallback -> OnDebugMessage -> had_error_callback_ = true. Any GL error from glBufferDataFn therefore triggers the early return.
Unpacking that:
- KHR_debug is an extension to OpenGL that lets an application register a callback, that is, a function the driver will call when it wants to report a message such as an error.
PassthroughGLDebugMessageCallbackis Chrome's callback function. When the driver reports something, it callsOnDebugMessage, which sets a flaghad_error_callback_ = true, meaning "an error was reported".CheckErrorCallbackState()reads that flag.
So the mechanism works: the error is noticed. The problem is what happens next. The detection only causes an early return; it does not trigger the cleanup that the success path performs.
The most impactful error
The researcher singles out GL_OUT_OF_MEMORY as the most impactful case. GL_OUT_OF_MEMORY is the error a graphics driver reports when it cannot allocate the memory requested. In that situation the driver frees the old backing store, so the map_ptr in the surviving mapped_buffer_map entry now points to freed memory. Backing store means the actual memory the driver had set aside for that buffer. Once it is freed, the address is no longer valid, and anything written there is a use after free.
The earlier fix in the other decoder
The researcher also notes that the same class of bug had already been fixed in the validating decoder in commit daeb9ba8d7ce (Bug 498715368), with this comment in buffer_manager.cc:
// SECURITY: ... Clear it here so that UnmapBufferHelper does not memcpy
// renderer-controlled SHM into freed driver memory.
buffer->ClearMapping();
Line by line:
// SECURITY: ... Clear it here so that UnmapBufferHelper does not memcpyis a comment (text ignored by the computer, written for humans). It says this line exists for security reasons: clear the mapping here so that the unmap helper does not perform amemcpy.// renderer-controlled SHM into freed driver memory.continues the comment: the danger is copying renderer-controlled shared memory into driver memory that has been freed.memcpyis a standard C function that copies a block of bytes from one memory address to another.buffer->ClearMapping();is the actual fix: it clears the stored mapping on the buffer object, so no stale pointer remains to be used later.
The passthrough decoder was not included in that fix. A duplicate is a report of a bug that has already been reported or fixed; reward programs usually do not pay twice for the same thing.
Exploitation
Step 1: Map a buffer
The renderer creates and binds a buffer, then maps it with GL_MAP_WRITE_BIT. This adds an entry to mapped_buffer_map containing the mapping pointer and size. The regression test confirms this state before proceeding.
Why this step: the whole bug depends on there being a map entry to leave behind. GL_MAP_WRITE_BIT is a flag meaning "I intend to write to this mapped memory". Binding a buffer means making it the current one for subsequent commands, so the decoder knows which buffer the commands refer to.
Step 2: Trigger a GL error from BufferData
The renderer submits a BufferData command with size=-1. This produces GL_INVALID_VALUE, which fires the KHR_debug callback and sends DoBufferData down the early-return path. The researcher notes that this is functionally the same as GL_OUT_OF_MEMORY for this code path: both leave the map entry in place. The difference is that with GL_OUT_OF_MEMORY on real hardware, the driver has also freed the old backing store, so the stale pointer is dangling.
Why this step: the researcher needs a reliable way to make the driver report an error. A negative size is invalid by definition, so the driver rejects it every time with GL_INVALID_VALUE ("the value you passed is not acceptable"). That makes the test deterministic. On real hardware, the attacker would instead provoke GL_OUT_OF_MEMORY, which is harder to arrange but also frees the memory, turning the stale pointer into a genuine dangling pointer. A dangling pointer is a pointer to memory that has been freed.
Step 3: Confirm the stale entry
The test asserts that the mapped_buffer_map entry is still present after the error. To assert in testing means to state a condition that must be true, and have the test fail if it is not. The ASAN run output is:
[ RUN ] GLES3DecoderPassthroughTest.BufferDataGLErrorLeavesStaleMapEntry
[ERROR] GL_INVALID_VALUE: glBufferData: Negative size.
[ OK ] GLES3DecoderPassthroughTest.BufferDataGLErrorLeavesStaleMapEntry (3584 ms)
Line by line:
[ RUN ] GLES3DecoderPassthroughTest.BufferDataGLErrorLeavesStaleMapEntrysays the test framework has started running a test. The test belongs to theGLES3DecoderPassthroughTestgroup and is namedBufferDataGLErrorLeavesStaleMapEntry, which describes exactly what it checks: a GL error in BufferData leaves a stale map entry.[ERROR] GL_INVALID_VALUE: glBufferData: Negative size.is the driver's complaint, passed through the debug callback: the buffer data call was given a negative size, which is invalid.[ OK ] GLES3DecoderPassthroughTest.BufferDataGLErrorLeavesStaleMapEntry (3584 ms)says the test passed, and it took 3584 milliseconds.
The EXPECT_NE assertion passes, which the researcher reads as confirmation that the stale entry survives the GL error. EXPECT_NE is a test macro meaning "expect not equal": the test checks that the map entry is not equal to "absent", that is, that it is still there. On real hardware with GL_OUT_OF_MEMORY, the map_ptr would point to freed driver memory.
Step 4: Unmap and write into freed memory
The renderer then calls glUnmapBuffer. The decoder looks up the stale entry and performs the copy:
memcpy(map_info.map_ptr, renderer_shm, map_info.size)
Line by line:
memcpy(is the standard memory copy function: copy a number of bytes from a source address to a destination address.map_info.map_ptris the destination: the pointer stored in the mapping information, which is the stale pointer into driver memory.renderer_shmis the source: the shared memory region the renderer controls.map_info.sizeis how many bytes to copy, also taken from the mapping information.
Because map_ptr refers to freed driver memory, this is a heap-use-after-free write in the GPU process. The heap is the general-purpose pool of memory a program uses for dynamically allocated data; a heap-use-after-free is a use after free involving that pool. The content and size come from renderer-controlled shared memory, so the attacker chooses what is written and how much.
Root cause
The mistake is an error path that skips cleanup. DoBufferData erases the mapped_buffer_map entry only on the success path. When CheckErrorCallbackState() reports a GL error, the function returns error::kNoError before reaching the erase. The map entry therefore outlives the driver allocation it describes.
An error path is the route a function takes when something goes wrong, as opposed to the normal success path. Bugs often hide on error paths because they are tested less and because developers focus on the happy case.
The existing defence did not cover this path. The validating decoder had already been hardened with buffer->ClearMapping() in buffer_manager.cc, with a comment explicitly describing the risk of copying renderer-controlled shared memory into freed driver memory. The passthrough decoder, which is the default on desktop, was not part of that fix. The KHR_debug callback correctly detects the error, but the detection only causes an early return; it does not trigger the cleanup that the success path performs.
Impact
A compromised renderer can obtain a heap-use-after-free write primitive in the GPU process. A primitive in security means a basic capability an attacker has gained, which they can then build on. Here the primitive is "write controlled bytes to a controlled address that has been freed".
According to the report, the attacker controls:
- The write destination, via timing and heap grooming. Heap grooming means arranging memory allocations so that a chosen object lands at a chosen address, making the freed slot predictable.
- The content, which comes from renderer shared memory.
- The size, also from the mapping metadata.
The GPU process is sandboxed and separate from the renderer. A sandbox is a set of restrictions that limits what a process can do, so that even if it is compromised, the damage is contained. The researcher states that exploiting this primitive to achieve GPU process code execution would constitute a sandbox escape from a compromised renderer. Code execution means getting the processor to run the attacker's own instructions. A sandbox escape means getting out of the restricted environment into a more privileged one.
The report states that exploiting this primitive to achieve GPU process code execution would constitute a sandbox escape from a compromised renderer.
The affected population is all desktop Chrome users on Windows, macOS and Linux, because the passthrough decoder is enabled by default there. The report marks the issue as related to a crash and classifies it as memory corruption in a sandboxed process. Memory corruption means memory contents are changed in ways the program did not intend, which can lead to crashes or, worse, to exploitable behaviour.
Fix
The researcher proposes adding the erase before the early return in DoBufferData:
if (CheckErrorCallbackState()) {
resources_->mapped_buffer_map.erase(bound_buffers_[target]);
return error::kNoError;
}
Line by line:
if (CheckErrorCallbackState()) {is the same check as before: did the driver report an error?resources_->mapped_buffer_map.erase(bound_buffers_[target]);is the new line: before leaving, remove the buffer's entry from the map of mapped buffers. This is the cleanup that was previously skipped.return error::kNoError;then leaves the function as before.
This makes the error path perform the same cleanup as the success path, so a later glUnmapBuffer cannot find a stale entry pointing at freed driver memory. The report proposes this change as the fix.
Variants to test
The following are suggestions for follow-up work, not findings from the report.
- Audit other
Do*functions in the passthrough decoder that erase frommapped_buffer_mapor similar resource maps after a driver call. To audit means to review code systematically looking for a class of mistake. A positive result is an early return onCheckErrorCallbackState()that precedes the erase, leaving a stale entry. - Look for other resource maps keyed by bound objects where a driver error skips cleanup, such as texture or renderbuffer bookkeeping. A texture is image data used in graphics; a renderbuffer is a buffer used as a rendering target. A positive result is a map entry that survives a GL error and is later dereferenced. To dereference a pointer means to use the memory it points at.
- Compare the validating and passthrough decoders for fixes that landed in only one of them, as happened with commit daeb9ba8d7ce. A positive result is a security comment in
buffer_manager.ccor similar with no equivalent in the passthrough path. - Exercise
GL_OUT_OF_MEMORYrather thanGL_INVALID_VALUEin a test harness, since the former is the case where the driver actually frees the backing store. A test harness is the surrounding code that sets up and runs a test. A positive result under ASAN is a use-after-free report on the unmap copy. - Check whether other error-producing commands that invalidate mappings, beyond
BufferData, take the same early-return shape. A positive result is any command that leavesmapped_buffer_mappopulated after a driver error.
Glossary
- API: a defined set of functions one piece of software offers to another so they can work together.
- ASAN (AddressSanitizer): a compiler tool that watches memory accesses at runtime and reports out-of-bounds or use-after-free accesses.
- Assert: in testing, to state a condition that must be true, with the test failing if it is not.
- Audit: to review code systematically looking for a class of mistake.
- Backing store: the actual memory a driver has set aside to hold a buffer's data.
- Buffer: a block of memory used by the graphics system to hold data such as vertices or pixels.
- Callback: a function you hand to another piece of software, which it calls when something happens.
- Chromium: the open-source project whose source code Chrome is built from.
- Code execution: getting the processor to run the attacker's own instructions.
- Commit: a saved snapshot of changes in a code repository, identified by a hash.
- Command decoder: the component in the GPU process that receives graphics commands from the renderer and executes them against the driver.
- Dangling pointer: a pointer to memory that has already been freed.
- Dereference: to use the memory a pointer points at.
- Driver: software that lets the operating system talk to a piece of hardware.
- Duplicate: a report of a bug that has already been reported or fixed.
- Error path: the route a function takes when something goes wrong, as opposed to the normal success path.
- GL / OpenGL ES: a standard set of graphics functions used to draw and manage graphics data.
- GL_INVALID_VALUE: a GL error meaning a function was given an argument value that is not acceptable.
- GL_MAP_WRITE_BIT: a flag meaning the caller intends to write to mapped buffer memory.
- GL_OUT_OF_MEMORY: a GL error meaning the driver could not allocate the requested memory.
- GPU process: the Chrome process that talks to the graphics hardware on behalf of the renderer.
- HEAD: the most recent commit on a branch, that is, the latest state of the code.
- Heap: the general-purpose pool of memory a program uses for dynamically allocated data.
- Heap grooming: arranging memory allocations so a chosen object lands at a chosen address.
- Heap-use-after-free: a use after free involving memory from the heap.
- KHR_debug: an OpenGL extension that lets an application register a callback to receive driver messages such as errors.
- Map (data structure): a lookup table that returns a value for a given key.
- Mapping (a buffer): asking the graphics system for a pointer to a buffer's memory so it can be read or written directly.
- memcpy: a standard C function that copies a block of bytes from one memory address to another.
- Memory corruption: memory contents changed in ways the program did not intend, which can cause crashes or exploitable behaviour.
- Passthrough command decoder: the decoder that forwards commands more directly to the driver, relying on the driver and the command buffer's bookkeeping for safety.
- Pointer: a memory address, a number saying where in memory something lives.
- Primitive: in security, a basic capability an attacker has gained and can build on.
- Process: an independent running program with its own private memory.
- Regression test: a test written to reproduce a specific bug so it fails if the bug returns.
- Renderer process: the Chrome process that runs web page content such as HTML, JavaScript and images.
- Sandbox: a set of restrictions limiting what a process can do, so damage is contained if it is compromised.
- Sandbox escape: getting out of a restricted environment into a more privileged one.
- Shared memory (SHM): a region of memory two processes can both access, used here to pass data from renderer to GPU process.
- Stable: the normal Chrome release channel most people run.
- Test harness: the surrounding code that sets up and runs a test.
- Texture: image data used in graphics.
- Unmap: telling the graphics system you are done with a mapped buffer's memory.
- Use after free: using memory after it has been freed, which can corrupt data or crash the program.
- Validating command decoder: the decoder that checks commands against a set of rules before passing them to the driver.
- Vulnerability Reward Program (VRP): a scheme where a vendor pays people who find and report security bugs in its software.