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

Heap buffer overflow in ANGLE (CVE-2026-6296)

ANGLE's texture-image state sync omits the pack-state dirty bits, so a stale GL_PACK_ROW_LENGTH from an earlier readPixels survives into the CPU readback path used by copySubTextureCPUReadback. An attacker can then make native GL write past a scratch heap buffer with attacker-controlled bytes at an attacker-chosen offset, causing a heap overflow in the GPU process from WebGL2 JavaScript.

cinzinga Follow

Originally disclosed on Chrome VRP

Bounty$90,000 Critical View original
  • Fix shipped in 42 days

Report description

ANGLE BlitGL copySubTextureCPUReadback Controlled Heap Overflow via Unsynchronized PACK_ROW_LENGTH


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?

https://source.chromium.org/chromium/chromium/src/+/main:third_party/angle/src/libANGLE/renderer/gl/BlitGL.cpp


The problem

Please describe the technical details of the vulnerability

kTexImageDirtyBits in ANGLE's Context.cpp omits DIRTY_BIT_PACK_STATE and DIRTY_BIT_PACK_BUFFER_BINDING. When copySubTextureCPUReadback (BlitGL.cpp) calls glReadPixels on a scratch heap buffer, it inherits stale GL_PACK_ROW_LENGTH from native GL, causing a controlled heap overflow. Triggered from JavaScript via WebGL2, no compromised renderer required.

Data written is attacker-controlled via source WebGL canvas pixel data (RGBA bytes rendered by attacker). Write offset is attacker-controlled via PACK_ROW_LENGTH which sets row stride. Write size is width * 4 bytes per row, tunable via source canvas dimensions.

Tight primitive: width=2, height=2, PACK_ROW_LENGTH=N gives exactly 8 controlled bytes at offset N*4 past the scratch buffer.

Attack Chain:

  1. Set PACK_ROW_LENGTH=N. Forwarded to ANGLE via command buffer (gles2_implementation.cc uses break, not return, for this param).
  2. Bind PBO, then readPixels. This bypasses ScopedPackStateRowLengthReset (disabled when PBO bound, passthrough_doers.cc:2661). ANGLE syncs PACK_ROW_LENGTH=N to native GL.
  3. Unbind and delete PBO. StateManagerGL::deleteBuffer unbinds PBO in native GL. PACK_ROW_LENGTH persists.
  4. Call texImage2D(SRGB8_ALPHA8, webglCanvas). SRGB dest forces CPU readback path (TextureGL.cpp:1113,1133 skip fast paths when destSRGB=true). WebGL canvas source is texture-backed, routes through CopySubTextureCHROMIUM to copySubTextureCPUReadback.
  5. Overflow. BlitGL.cpp:859 calls native glReadPixels with stale PACK_ROW_LENGTH=N, stride N*4 bytes per row into a width*height*4*2 byte scratch buffer.

Affected Code

C++
// third_party/angle/src/libANGLE/Context.cpp:86-89
constexpr state::DirtyBits kTexImageDirtyBits{
    state::DIRTY_BIT_UNPACK_STATE,
    state::DIRTY_BIT_UNPACK_BUFFER_BINDING,
    // Missing: DIRTY_BIT_PACK_STATE, DIRTY_BIT_PACK_BUFFER_BINDING
};

syncStateForTexImage() uses kTexImageDirtyBits. It syncs unpack state but never pack state. Compare with kReadPixelsDirtyBits (line 94) which correctly includes DIRTY_BIT_PACK_STATE.

When copySubTextureCPUReadback (BlitGL.cpp:859) calls mFunctions->readPixels() into a scratch buffer, it reads with whatever PACK_ROW_LENGTH was last synced to native GL by a prior readPixels call. The scratch buffer is sized for width * height * 4 * 2 (32KB for 64x64), but native GL writes with stride PACK_ROW_LENGTH * 4, overflowing the buffer.

Steps to Reproduce

  1. Build Chromium with ASan (is_asan = true) or use an ASan-instrumented build.
  2. Save the attached poc.html.
  3. Run:
./chrome --no-sandbox --ignore-gpu-blocklist --single-process poc.html
  1. ASan reports heap-buffer-overflow (or heap-use-after-free) on the Chrome_InProcGp thread at BlitGL::copySubTextureCPUReadback.

No GPU hardware required. Reproduces on stock Linux VMs with Mesa llvmpipe.

ASan Output

PACK_ROW_LENGTH=4096. Full trace in asan_out.txt:

==175475==ERROR: AddressSanitizer: heap-use-after-free on address 0x75876315dab0
WRITE of size 8 at 0x75876315dab0 thread T17 (Chrome_InProcGp)
    #0 memcpy
    #1-#4 libgallium (Mesa readpixels)
    #5 rx::BlitGL::copySubTextureCPUReadback BlitGL.cpp:859
    #6 rx::TextureGL::copySubTextureHelper TextureGL.cpp:1150
    ...
    #12 GLES2DecoderPassthroughImpl::DoCopySubTextureCHROMIUM passthrough_doers.cc:4501

0x75876315dab0 is located 16 bytes inside of 29-byte region [0x75876315daa0,0x75876315dabd)
freed by thread T17 (Chrome_InProcGp) here:
    #0 operator delete
    #1 llvm::MCContext::reset()

MiraclePtr Status: NOT PROTECTED

Controlled bytes written at controlled offset past the scratch buffer. Landed in a freed LLVM MCContext region, likely reclaimable via heap spray.

Fix

Add pack state dirty bits to kTexImageDirtyBits:

C++
constexpr state::DirtyBits kTexImageDirtyBits{
    state::DIRTY_BIT_UNPACK_STATE,
    state::DIRTY_BIT_UNPACK_BUFFER_BINDING,
    state::DIRTY_BIT_PACK_STATE,            // ADD
    state::DIRTY_BIT_PACK_BUFFER_BINDING,   // ADD
};

Or reset pack state in copySubTextureCPUReadback before readPixels (BlitGL.cpp:859), similar to how it already resets pack state after (line 873-876).

Bisect

Introduced in ANGLE commit https://chromium.googlesource.com/angle/angle/+/aadc8f376a ("Implement the CPU fallback for CopyTextureCHROMIUM on OpenGL", 2017-08-11). This commit added copySubTextureCPUReadback with readPixels before setPixelPackState. Pack state was never reset before the read, from day one. Rolled into Chromium via https://chromium.googlesource.com/chromium/src/+/ed7971c95c05a (2017-08-30), shipping in Chrome 63 (December 2017).

The PBO bypass path that disables ScopedPackStateRowLengthReset when a PBO is bound was added in https://chromium.googlesource.com/chromium/src/+/5899dbdc3d96d ("Implement async ReadPixels for the passthrough command decoder", 2017-10-05), making the stale state reachable.

Impact analysis

Heap overflow in the GPU process from unprivileged WebGL2 JavaScript, no compromised renderer required. The attacker controls the write data (source canvas pixels), write offset (PACK_ROW_LENGTH), and write size (source canvas width). The overflow target is a malloc'd scratch buffer with no MiraclePtr protection. On Linux, the GPU process is sandboxed but not as tightly as the renderer.


The cause

What version of Chrome have you found the security issue in?

147.0.7703.0 (Developer Build) (64-bit)

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?

cinzinga

The original report as published on the Chromium issue tracker, by cinzinga. 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. 7 min read.

Context

This report describes a heap buffer overflow in ANGLE, the graphics translation layer that Chrome uses to map WebGL and OpenGL ES calls onto the platform's native graphics API. The affected function is copySubTextureCPUReadback in third_party/angle/src/libANGLE/renderer/gl/BlitGL.cpp, which is used when a texture copy cannot take a fast GPU path and has to be performed by reading pixels back into a CPU scratch buffer.

The bug was reported through the Chrome Vulnerability Reward Program (Chrome VRP), the programme that covers security issues affecting the Chrome browser. The researcher is credited as cinzinga. The platform records the severity as critical, the weakness as a heap buffer overflow, the affected asset as ANGLE, and the bounty as 90,000 USD. The report itself is an advisory-style write-up rather than a request/response walkthrough: it contains code excerpts, a reproduction command, an ASan trace and commit references, but no HTTP traffic.

The vulnerability is reachable from unprivileged WebGL2 JavaScript. In the researcher's words, no compromised renderer is required. The overflow occurs in the GPU process.

Setup

The report lists the following preconditions and tools:

  1. A Chromium build with AddressSanitizer enabled (is_asan = true), or any ASan-instrumented build.
  2. The proof-of-concept file poc.html that accompanies the report. The report refers to it as "the attached poc.html" but does not reproduce its contents.
  3. A Linux environment. The researcher states that no GPU hardware is required and that the issue reproduces on stock Linux VMs with Mesa llvmpipe.
  4. The Chrome version tested: 147.0.7703.0 (Developer Build) (64-bit).

The researcher classifies the issue as Memory Corruption in a sandboxed process and confirms it is related to a crash.

Finding it

The starting point is the dirty-bit set that ANGLE uses when synchronising state before a texture image operation. In third_party/angle/src/libANGLE/Context.cpp the constant kTexImageDirtyBits is defined as follows:

C++
// third_party/angle/src/libANGLE/Context.cpp:86-89
constexpr state::DirtyBits kTexImageDirtyBits{
    state::DIRTY_BIT_UNPACK_STATE,
    state::DIRTY_BIT_UNPACK_BUFFER_BINDING,
    // Missing: DIRTY_BIT_PACK_STATE, DIRTY_BIT_PACK_BUFFER_BINDING
};

syncStateForTexImage() uses this set. It therefore synchronises unpack state but never pack state. The researcher contrasts this with kReadPixelsDirtyBits (line 94), which correctly includes DIRTY_BIT_PACK_STATE.

The consequence is that when copySubTextureCPUReadback (BlitGL.cpp:859) calls mFunctions->readPixels() into a scratch buffer, it reads with whatever PACK_ROW_LENGTH was last synced to native GL by a prior readPixels call. The scratch buffer is sized for width * height * 4 * 2 (32KB for a 64x64 texture), but native GL writes with a stride of PACK_ROW_LENGTH * 4, which overflows the buffer.

The researcher describes the primitive as tight and fully controlled:

  • The data written is attacker-controlled through the source WebGL canvas pixel data (RGBA bytes rendered by the attacker).
  • The write offset is attacker-controlled through PACK_ROW_LENGTH, which sets the row stride.
  • The write size is width * 4 bytes per row, tunable through the source canvas dimensions.

With width=2, height=2 and PACK_ROW_LENGTH=N, the result is exactly 8 controlled bytes at offset N*4 past the scratch buffer.

Exploitation

The report lays out the attack as a five-step chain.

Step 1: set PACK_ROW_LENGTH

JavaScript sets PACK_ROW_LENGTH=N. The value is forwarded to ANGLE through the command buffer. The researcher notes that gles2_implementation.cc uses break, not return, for this parameter, so the value is passed on rather than short-circuited.

Step 2: bind a PBO and call readPixels

Binding a pixel buffer object and then calling readPixels bypasses ScopedPackStateRowLengthReset, which is disabled when a PBO is bound (passthrough_doers.cc:2661). During this call ANGLE syncs PACK_ROW_LENGTH=N to native GL.

Step 3: unbind and delete the PBO

StateManagerGL::deleteBuffer unbinds the PBO in native GL, but PACK_ROW_LENGTH persists in the native GL state.

Step 4: trigger the CPU readback path

The attacker calls texImage2D(SRGB8_ALPHA8, webglCanvas). The SRGB destination forces the CPU readback path: TextureGL.cpp:1113,1133 skip the fast paths when destSRGB=true. Because the WebGL canvas source is texture-backed, the call routes through CopySubTextureCHROMIUM to copySubTextureCPUReadback.

Step 5: overflow

BlitGL.cpp:859 calls native glReadPixels with the stale PACK_ROW_LENGTH=N. Native GL writes with a stride of N*4 bytes per row into a width*height*4*2 byte scratch buffer, overflowing it.

Reproduction

The report gives the following steps.

  1. Build Chromium with ASan (is_asan = true) or use an ASan-instrumented build.
  2. Save the attached poc.html.
  3. Run:
Bash
./chrome --no-sandbox --ignore-gpu-blocklist --single-process poc.html
  1. ASan reports heap-buffer-overflow (or heap-use-after-free) on the Chrome_InProcGp thread at BlitGL::copySubTextureCPUReadback.

The report states that no GPU hardware is required and that the issue reproduces on stock Linux VMs with Mesa llvmpipe.

ASan output

The trace was produced with PACK_ROW_LENGTH=4096. The full trace is in asan_out.txt; the report quotes the following excerpt:

Text
==175475==ERROR: AddressSanitizer: heap-use-after-free on address 0x75876315dab0
WRITE of size 8 at 0x75876315dab0 thread T17 (Chrome_InProcGp)
    #0 memcpy
    #1-#4 libgallium (Mesa readpixels)
    #5 rx::BlitGL::copySubTextureCPUReadback BlitGL.cpp:859
    #6 rx::TextureGL::copySubTextureHelper TextureGL.cpp:1150
    ...
    #12 GLES2DecoderPassthroughImpl::DoCopySubTextureCHROMIUM passthrough_doers.cc:4501

0x75876315dab0 is located 16 bytes inside of 29-byte region [0x75876315daa0,0x75876315dabd)
freed by thread T17 (Chrome_InProcGp) here:
    #0 operator delete
    #1 llvm::MCContext::reset()

MiraclePtr Status: NOT PROTECTED

The trace shows an 8-byte write landing inside a 29-byte region that had already been freed by llvm::MCContext::reset(). The researcher notes that the controlled bytes were written at a controlled offset past the scratch buffer and landed in a freed LLVM MCContext region, which is likely reclaimable via heap spray. The trace also records MiraclePtr Status: NOT PROTECTED for the target allocation.

Root cause

The defect is an omission in the dirty-bit set used for texture image synchronisation. kTexImageDirtyBits includes DIRTY_BIT_UNPACK_STATE and DIRTY_BIT_UNPACK_BUFFER_BINDING but not DIRTY_BIT_PACK_STATE or DIRTY_BIT_PACK_BUFFER_BINDING. As a result, syncStateForTexImage() never brings pack state into a known condition before copySubTextureCPUReadback performs its readPixels.

The stale value is introduced by an earlier readPixels call that legitimately syncs PACK_ROW_LENGTH to native GL. The usual reset, ScopedPackStateRowLengthReset, does not apply while a PBO is bound (passthrough_doers.cc:2661), so the value survives the PBO being unbound and deleted. When the SRGB destination forces the CPU readback path, the scratch buffer is allocated for width * height * 4 * 2 bytes but native GL writes with the stale stride.

The researcher's bisect places the origin of the flaw in ANGLE commit aadc8f376a ("Implement the CPU fallback for CopyTextureCHROMIUM on OpenGL", 2017-08-11), which added copySubTextureCPUReadback with readPixels before setPixelPackState. Pack state was never reset before the read, from day one. The change rolled into Chromium via ed7971c95c05a (2017-08-30) and shipped in Chrome 63 in December 2017. The PBO bypass path that disables ScopedPackStateRowLengthReset when a PBO is bound was added in 5899dbdc3d96d ("Implement async ReadPixels for the passthrough command decoder", 2017-10-05), which made the stale state reachable.

On defences: the report notes that the overflow target is a malloc'd scratch buffer with no MiraclePtr protection, which the ASan trace confirms. The report does not describe any other mitigation that was evaluated.

Impact

The impact is a heap overflow in the GPU process reachable from unprivileged WebGL2 JavaScript, with no compromised renderer required. The attacker controls the write data (source canvas pixels), the write offset (PACK_ROW_LENGTH) and the write size (source canvas width). The overflow target is a malloc'd scratch buffer without MiraclePtr protection. On Linux, the researcher notes, the GPU process is sandboxed but not as tightly as the renderer.

The report does not discuss escaping the GPU process sandbox. It describes the primitive and the observation that the write landed in a freed LLVM MCContext region that is likely reclaimable via heap spray.

Fix

The report proposes two options.

  1. Add the pack state dirty bits to kTexImageDirtyBits:
C++
constexpr state::DirtyBits kTexImageDirtyBits{
    state::DIRTY_BIT_UNPACK_STATE,
    state::DIRTY_BIT_UNPACK_BUFFER_BINDING,
    state::DIRTY_BIT_PACK_STATE,            // ADD
    state::DIRTY_BIT_PACK_BUFFER_BINDING,   // ADD
};
  1. Alternatively, reset pack state in copySubTextureCPUReadback before readPixels (BlitGL.cpp:859), similar to how it already resets pack state afterwards (lines 873-876).

The report does not state which fix was adopted, and the supplied material does not include a patch or a confirmation from the vendor.

Variants to test

These are extrapolations from the report's mechanism, not claims made in it.

  1. Other dirty-bit sets that omit pack state. Audit constants such as kTexImageDirtyBits against the operations that consume them. A positive result is a code path where a pack parameter is read from native GL without being synchronised first.
  2. Other callers of readPixels into fixed-size scratch buffers. Look for allocations sized from one set of dimensions while the native read uses a stride from another. A positive result is an ASan report showing a write past the allocation with a stride-derived offset.
  3. Other state-reset scopes that are disabled when a buffer object is bound, in the style of ScopedPackStateRowLengthReset. A positive result is a parameter that survives unbinding and deletion of the buffer and is later consumed by an unrelated operation.
  4. Other format conversions that force a CPU fallback, in the style of the SRGB destination in TextureGL.cpp:1113,1133. A positive result is a copy path that reaches a CPU readback with state inherited from an earlier, unrelated call.
  5. Other GPU-process allocations without MiraclePtr protection that are adjacent to attacker-influenced writes. A positive result is a controllable write landing in a freed or reclaimable region, as in the LLVM MCContext case here.

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. 22 min read.

What happened, in plain words

This report describes a memory safety bug in Chrome, found by a security researcher credited as cinzinga and reported through the Chrome Vulnerability Reward Program (Chrome VRP). The platform records the severity as critical, the weakness as a heap buffer overflow, the affected asset as ANGLE, and the bounty as 90,000 USD.

To understand the bug you need three ideas, explained from zero.

  1. A browser is made of several programs running side by side. One part draws the page (the renderer), another part talks to the graphics hardware (the GPU process). They are kept apart on purpose, so that a bug in one does not automatically give an attacker control of the whole browser. This separation is called a sandbox.
  2. Web pages can ask the browser to draw 3D graphics. The web standard for this is called WebGL, and its newer version is WebGL2. A web page uses WebGL by calling a set of functions the browser exposes to it. A set of functions exposed like this is called an API (application programming interface). Think of an API as a restaurant menu: the page can only order dishes that are on the menu, and the kitchen decides how each dish is actually cooked.
  3. ANGLE is the kitchen in this comparison. ANGLE is a piece of software inside Chrome that translates the WebGL orders into instructions the computer's actual graphics system understands. Different operating systems and graphics cards speak slightly different graphics languages, and ANGLE is the translator that lets one web page work everywhere.

The bug is a heap buffer overflow. To unpack that: a program stores its working data in a region of memory called the heap, and it reserves small blocks of it, called buffers, when it needs space. A buffer has a fixed size. If a program writes more bytes than the buffer can hold, the extra bytes spill into whatever sits next to it in memory. That spill is the overflow. It is dangerous because the spilled bytes can overwrite data that belongs to something else, and an attacker who controls both what is written and where it lands can sometimes turn that into running their own code.

The specific flaw: when ANGLE copies an image using a slow fallback path that goes through the computer's main processor (the CPU) instead of the graphics card (the GPU), it asks the graphics system to read pixels into a small temporary buffer. That temporary buffer is called a scratch buffer. The graphics system is told how far apart to place each row of pixels by a setting called PACK_ROW_LENGTH. If that setting is left over from an earlier operation, the rows are spaced further apart than the scratch buffer expects, and the writes run past the end of the buffer.

The researcher's key point is that this is reachable from ordinary web page JavaScript running WebGL2, with no need to first break into the renderer. In the researcher's words, no compromised renderer is required. The overflow happens in the GPU process.

The report as submitted

Report description

The report's own title is:

Text
ANGLE BlitGL copySubTextureCPUReadback Controlled Heap Overflow via Unsynchronized PACK_ROW_LENGTH

Read it in pieces. BlitGL is the name of a source file in ANGLE. copySubTextureCPUReadback is the name of the function inside it that does the copying on the CPU. Controlled means the attacker decides the details of the overflow rather than it being random. Heap Overflow is the memory corruption described above. Unsynchronized PACK_ROW_LENGTH means the row-spacing setting was not brought into a known, consistent state before it was used. "Unsynchronized" here is the heart of the bug: two parts of the program disagreed about what the setting was.

Bug location

Where do you want to report your vulnerability?

The report was filed under:

Text
Chrome VRP – Report security issues affecting the Chrome browser. [See program rules](https://bughunters.google.com/about/rules/5745167867576320/chrome-vulnerability-reward-program-rules)

A bug bounty programme is a scheme where a company pays researchers for reporting security flaws responsibly instead of exploiting them. The Chrome VRP is Google's programme for Chrome. The link points to the programme's published rules, which define what is in scope and how rewards are decided.

Which URL (or repository) have you found the vulnerability in?

The report points at this source file:

Text
https://source.chromium.org/chromium/chromium/src/+/main:third_party/angle/src/libANGLE/renderer/gl/BlitGL.cpp

This is a link into Chromium's public source code browser. third_party/angle is the folder where ANGLE lives inside the Chromium source tree, because ANGLE is a separate project that Chromium pulls in. src/libANGLE/renderer/gl/BlitGL.cpp is the file that implements the OpenGL renderer backend, and BlitGL.cpp specifically handles copying (blitting) images. Naming the exact file lets the vendor go straight to the code.

The problem

Please describe the technical details of the vulnerability

The researcher's summary is:

Text
`kTexImageDirtyBits` in ANGLE's `Context.cpp` omits `DIRTY_BIT_PACK_STATE` and `DIRTY_BIT_PACK_BUFFER_BINDING`. When `copySubTextureCPUReadback` (BlitGL.cpp) calls `glReadPixels` on a scratch heap buffer, it inherits stale `GL_PACK_ROW_LENGTH` from native GL, causing a controlled heap overflow. Triggered from JavaScript via WebGL2, no compromised renderer required.

Line by line, in plain words:

  • kTexImageDirtyBits is a named list, kept in a file called Context.cpp, of settings that ANGLE should refresh before it performs a texture image operation. The word "dirty" here is a programming term meaning "has been changed and may not match what the graphics system currently has". A dirty bit is a marker that says "this setting needs updating".
  • The list omits two entries: DIRTY_BIT_PACK_STATE and DIRTY_BIT_PACK_BUFFER_BINDING. Those two entries are exactly the ones that would refresh the pack settings, which are the settings that control how pixels are read out of the graphics system.
  • copySubTextureCPUReadback is the function that copies an image on the CPU. It calls glReadPixels, a standard graphics function that reads pixels from the graphics system into a memory buffer.
  • Because the pack settings were never refreshed, the read inherits a stale (left over, out of date) value of GL_PACK_ROW_LENGTH from the underlying native graphics system. native GL means the real graphics library on the machine, as opposed to ANGLE's own bookkeeping.
  • The result is a controlled heap overflow: the attacker controls the details.
  • It is triggered from JavaScript through WebGL2, and no compromised renderer is required.

Then the report explains exactly what the attacker controls:

Text
Data written is attacker-controlled via source WebGL canvas pixel data (RGBA bytes rendered by attacker). Write offset is attacker-controlled via `PACK_ROW_LENGTH` which sets row stride. Write size is `width * 4` bytes per row, tunable via source canvas dimensions.

A canvas is the drawing surface a web page uses to render graphics. RGBA means each pixel is described by four numbers: red, green, blue and alpha (transparency). Because the attacker's own JavaScript draws the canvas, the attacker decides the exact byte values that get written. PACK_ROW_LENGTH sets the row stride, which is the distance in pixels between the start of one row and the start of the next. By choosing it, the attacker chooses how far past the buffer the writes land. The amount written per row is width * 4 bytes, because each pixel is four bytes, so the attacker tunes the size by choosing the canvas width.

The report then gives the tightest version of the primitive:

Text
Tight primitive: width=2, height=2, `PACK_ROW_LENGTH=N` gives exactly 8 controlled bytes at offset `N*4` past the scratch buffer.

A primitive in security means a small, reliable building block of an attack. Here the block is: write exactly 8 bytes (2 pixels wide times 4 bytes per pixel, for one row of a 2 by 2 image) at a position the attacker picks by choosing N. Small and precise is better than large and messy, because it is easier to aim at a specific target.

Attack Chain

The report lays out five steps.

  1. Set PACK_ROW_LENGTH=N. Forwarded to ANGLE via command buffer (gles2_implementation.cc uses break, not return, for this param).
  2. Bind PBO, then readPixels. This bypasses ScopedPackStateRowLengthReset (disabled when PBO bound, passthrough_doers.cc:2661). ANGLE syncs PACK_ROW_LENGTH=N to native GL.
  3. Unbind and delete PBO. StateManagerGL::deleteBuffer unbinds PBO in native GL. PACK_ROW_LENGTH persists.
  4. Call texImage2D(SRGB8_ALPHA8, webglCanvas). SRGB dest forces CPU readback path (TextureGL.cpp:1113,1133 skip fast paths when destSRGB=true). WebGL canvas source is texture-backed, routes through CopySubTextureCHROMIUM to copySubTextureCPUReadback.
  5. Overflow. BlitGL.cpp:859 calls native glReadPixels with stale PACK_ROW_LENGTH=N, stride N*4 bytes per row into a width*height*4*2 byte scratch buffer.

Now each step explained from zero.

Step 1: set the row length. The web page calls a WebGL function to set PACK_ROW_LENGTH to a value N of the attacker's choosing. In Chrome, WebGL calls from a web page do not go straight to the graphics system. They are packaged up and sent across a boundary to the GPU process. That packaging is the command buffer, a queue of instructions passed from one process to another. The file gles2_implementation.cc is where Chrome's WebGL implementation handles these calls. The researcher notes it uses break, not return, for this parameter. In programming, break exits a loop or switch statement and carries on with the rest of the function, while return would exit the whole function immediately. Using break means the value is passed onward rather than being dropped early. That matters because it is how the value reaches ANGLE at all.

Step 2: bind a PBO and read pixels. A PBO (pixel buffer object) is a chunk of graphics memory used as a temporary destination for pixel data. "Binding" means making it the current target, like putting a sheet of paper on a clipboard so the next stamp lands on it. The report says binding a PBO and then calling readPixels bypasses ScopedPackStateRowLengthReset. That name describes a guard whose job is to reset the row length setting back to its default when a block of code finishes. A scope in programming is a region of code with a defined beginning and end, and a guard tied to a scope runs its cleanup automatically at the end. The guard is disabled when a PBO is bound, at passthrough_doers.cc:2661. So the reset that would normally tidy up does not happen. During this call, ANGLE copies PACK_ROW_LENGTH=N down to the native graphics system, which now remembers it.

Step 3: unbind and delete the PBO. The page releases the PBO and deletes it. StateManagerGL::deleteBuffer is the function that unbinds the PBO in the native graphics system. But the report says PACK_ROW_LENGTH persists: the row length setting is not part of the buffer, so deleting the buffer does not clear it. It stays behind like a sticky note left on a desk after the person who wrote it has gone.

Step 4: trigger the CPU readback path. The page calls texImage2D(SRGB8_ALPHA8, webglCanvas). texImage2D is the WebGL function that uploads an image into a texture, which is an image the graphics system can use. SRGB8_ALPHA8 is a colour format that describes colours in a particular way (sRGB is a standard colour space, and the alpha channel carries transparency). The report says an SRGB destination forces the CPU readback path, because TextureGL.cpp:1113,1133 skip the fast paths when destSRGB=true. In other words, when the destination format is sRGB, ANGLE cannot use the quick graphics-card route and must fall back to doing the copy on the CPU. Because the source is a WebGL canvas that is itself stored as a texture, the call is routed through CopySubTextureCHROMIUM and ends up in copySubTextureCPUReadback.

Step 5: overflow. At BlitGL.cpp:859, the code calls the native glReadPixels with the stale PACK_ROW_LENGTH=N. The native graphics system writes each row N*4 bytes apart, into a scratch buffer that was only allocated as width*height*4*2 bytes. The writes run past the end of the buffer. That is the overflow.

Affected Code

The report shows the faulty definition:

C++
// third_party/angle/src/libANGLE/Context.cpp:86-89
constexpr state::DirtyBits kTexImageDirtyBits{
    state::DIRTY_BIT_UNPACK_STATE,
    state::DIRTY_BIT_UNPACK_BUFFER_BINDING,
    // Missing: DIRTY_BIT_PACK_STATE, DIRTY_BIT_PACK_BUFFER_BINDING
};

Line by line:

  • The first line is a comment giving the file and line numbers, so a reader can find it in the source.
  • constexpr means the value is fixed at compile time and cannot change while the program runs. state::DirtyBits is the type, a set of markers. kTexImageDirtyBits is the name of this particular set. The k prefix is a naming convention for constants.
  • Inside the braces are the entries that are present: DIRTY_BIT_UNPACK_STATE and DIRTY_BIT_UNPACK_BUFFER_BINDING. "Unpack" settings control how pixel data is read into the graphics system, for example when uploading an image. "Pack" settings control how pixel data is read out of the graphics system, for example when reading pixels back.
  • The comment marks what is missing: DIRTY_BIT_PACK_STATE and DIRTY_BIT_PACK_BUFFER_BINDING. Those are the pack-side equivalents. Because they are absent, pack settings are never refreshed here.

The report then explains the consequence:

Text
`syncStateForTexImage()` uses `kTexImageDirtyBits`. It syncs unpack state but never pack state. Compare with `kReadPixelsDirtyBits` (line 94) which correctly includes `DIRTY_BIT_PACK_STATE`.

When `copySubTextureCPUReadback` (BlitGL.cpp:859) calls `mFunctions->readPixels()` into a scratch buffer, it reads with whatever `PACK_ROW_LENGTH` was last synced to native GL by a prior `readPixels` call. The scratch buffer is sized for `width * height * 4 * 2` (32KB for 64x64), but native GL writes with stride `PACK_ROW_LENGTH * 4`, overflowing the buffer.

syncStateForTexImage() is the function that brings settings up to date before a texture image operation, and it uses the faulty list. So it refreshes unpack settings but never pack settings. The researcher points out that kReadPixelsDirtyBits, the list used for read-pixel operations, does include DIRTY_BIT_PACK_STATE, which shows the correct pattern. When copySubTextureCPUReadback calls mFunctions->readPixels() into a scratch buffer, it uses whatever PACK_ROW_LENGTH was last pushed down to the native graphics system by an earlier read-pixels call. The scratch buffer is sized for width * height * 4 * 2 bytes, which the report says is 32KB for a 64 by 64 image. But the native graphics system writes with a stride of PACK_ROW_LENGTH * 4, so the writes go past the end.

Steps to Reproduce

The report gives these steps:

  1. Build Chromium with ASan (is_asan = true) or use an ASan-instrumented build.
  2. Save the attached poc.html.
  3. Run:
Bash
./chrome --no-sandbox --ignore-gpu-blocklist --single-process poc.html
  1. ASan reports heap-buffer-overflow (or heap-use-after-free) on the Chrome_InProcGp thread at BlitGL::copySubTextureCPUReadback.

What each part means:

  • ASan is AddressSanitizer, a tool built into the compiler that watches memory accesses while a program runs. When a program reads or writes outside a buffer, ASan notices and prints a detailed report. It is like a smoke alarm for memory bugs. is_asan = true is the build setting that turns it on.
  • poc.html is the proof of concept, a small web page that triggers the bug. The report refers to it as "the attached poc.html" but does not reproduce its contents, so this article cannot show it either.
  • The command line runs the built browser. --no-sandbox turns off the browser's process sandbox, which is normal for a test build. --ignore-gpu-blocklist tells Chrome to use the graphics setup even if it is on Chrome's list of configurations that are normally avoided. --single-process runs everything in one process, which makes debugging simpler. The last argument is the page to open.
  • The report says ASan reports heap-buffer-overflow (or heap-use-after-free) on the Chrome_InProcGp thread at BlitGL::copySubTextureCPUReadback. A thread is a stream of execution inside a process. Chrome_InProcGp is the name of the thread that runs the GPU work in this single-process setup. heap-use-after-free is a related memory bug where memory is used after it has been released.

The report adds that no GPU hardware is required and that the issue reproduces on stock Linux VMs with Mesa llvmpipe. A VM is a virtual machine, a computer simulated in software. Mesa is an open-source graphics library, and llvmpipe is Mesa's software renderer, which draws graphics on the CPU instead of a graphics card. That is why no real GPU is needed.

ASan Output

The report says the trace was produced with PACK_ROW_LENGTH=4096, and that the full trace is in asan_out.txt. It quotes this excerpt:

Text
==175475==ERROR: AddressSanitizer: heap-use-after-free on address 0x75876315dab0
WRITE of size 8 at 0x75876315dab0 thread T17 (Chrome_InProcGp)
    #0 memcpy
    #1-#4 libgallium (Mesa readpixels)
    #5 rx::BlitGL::copySubTextureCPUReadback BlitGL.cpp:859
    #6 rx::TextureGL::copySubTextureHelper TextureGL.cpp:1150
    ...
    #12 GLES2DecoderPassthroughImpl::DoCopySubTextureCHROMIUM passthrough_doers.cc:4501

0x75876315dab0 is located 16 bytes inside of 29-byte region [0x75876315daa0,0x75876315dabd)
freed by thread T17 (Chrome_InProcGp) here:
    #0 operator delete
    #1 llvm::MCContext::reset()

MiraclePtr Status: NOT PROTECTED

Line by line:

  • The first line is ASan announcing the problem: a heap-use-after-free at a particular memory address. The address is a location in memory, written in hexadecimal.
  • WRITE of size 8 means the program tried to write 8 bytes. That matches the width=2 primitive: 2 pixels times 4 bytes per pixel is 8 bytes. thread T17 (Chrome_InProcGp) says which thread did it.
  • The numbered lines are the stack trace, the list of function calls that led to the problem, most recent first. #0 memcpy is the low-level memory copy that actually performed the write. #1-#4 libgallium (Mesa readpixels) are frames inside Mesa's software renderer. #5 rx::BlitGL::copySubTextureCPUReadback BlitGL.cpp:859 is the ANGLE function from the report. #6 rx::TextureGL::copySubTextureHelper TextureGL.cpp:1150 is its caller. The ... means frames were omitted. #12 GLES2DecoderPassthroughImpl::DoCopySubTextureCHROMIUM passthrough_doers.cc:4501 is the command-buffer handler that started the chain.
  • The next line says the address is 16 bytes inside a 29-byte region that spans from one address to another. So the write landed inside a small block of memory that belonged to something else.
  • freed by thread T17 (Chrome_InProcGp) here: begins the trace of who released that memory earlier. #0 operator delete is the memory being freed, and #1 llvm::MCContext::reset() is the code that freed it. llvm::MCContext is part of LLVM, the compiler framework. So the overflow landed in memory that had already been released by the compiler's own bookkeeping.
  • MiraclePtr Status: NOT PROTECTED refers to MiraclePtr, a Chrome defence that makes certain kinds of use-after-free bugs much harder to exploit. The trace says this particular allocation was not protected by it.

The researcher's reading of the trace: the controlled bytes were written at a controlled offset past the scratch buffer and landed in a freed LLVM MCContext region, likely reclaimable via heap spray. A heap spray is a technique where an attacker fills the heap with many copies of chosen data, so that a write landing at an unpredictable spot is likely to hit attacker-controlled content.

Impact analysis

The report's impact statement is:

Text
Heap overflow in the GPU process from unprivileged WebGL2 JavaScript, no compromised renderer required. The attacker controls the write data (source canvas pixels), write offset (PACK_ROW_LENGTH), and write size (source canvas width). The overflow target is a malloc'd scratch buffer with no MiraclePtr protection. On Linux, the GPU process is sandboxed but not as tightly as the renderer.

In plain words: an ordinary web page, with no special privileges, can trigger a memory corruption bug inside the GPU process. unprivileged means the page has only the rights any web page has. malloc'd means the buffer was allocated with malloc, the standard C library function for reserving heap memory. The attacker controls three things: what bytes are written (the canvas pixels), where they land (the row length), and how many (the canvas width). The target has no MiraclePtr protection. On Linux the GPU process is sandboxed, but the researcher notes it is not as tightly confined as the renderer.

The report does not discuss escaping the GPU process sandbox. It describes the primitive and the observation that the write landed in a freed LLVM MCContext region that is likely reclaimable via heap spray.

The cause

What version of Chrome have you found the security issue in?

The version tested was:

Text
147.0.7703.0 (Developer Build) (64-bit)

A Developer Build is a build made for testing rather than for ordinary users, and 64-bit describes the processor architecture. Naming the exact version lets the vendor check whether the bug is present in that build and when it was introduced.

Is the security issue related to a crash?

The report answers yes. A crash is a program stopping unexpectedly, and memory corruption bugs often cause one, which is one reason they are treated seriously.

Choose the type of vulnerability

The report selects:

Text
Memory Corruption (in a sandboxed process)

Memory corruption is the general category for bugs where a program writes to memory it should not, damaging data or code. "In a sandboxed process" records that the corruption happens inside one of the browser's isolated processes, which limits what an attacker gains from it directly.

How would you like to be publicly acknowledged for your report?

The researcher chose the name cinzinga. Bug bounty programmes usually let researchers choose how they are credited once a report is disclosed.

Root cause

The defect is an omission in the list of settings refreshed before a texture image operation. kTexImageDirtyBits includes DIRTY_BIT_UNPACK_STATE and DIRTY_BIT_UNPACK_BUFFER_BINDING but not DIRTY_BIT_PACK_STATE or DIRTY_BIT_PACK_BUFFER_BINDING. As a result, syncStateForTexImage() never brings pack state into a known condition before copySubTextureCPUReadback performs its readPixels.

The stale value is introduced by an earlier readPixels call that legitimately syncs PACK_ROW_LENGTH to native GL. The usual reset, ScopedPackStateRowLengthReset, does not apply while a PBO is bound (passthrough_doers.cc:2661), so the value survives the PBO being unbound and deleted. When the SRGB destination forces the CPU readback path, the scratch buffer is allocated for width * height * 4 * 2 bytes but native GL writes with the stale stride.

The researcher's bisect places the origin of the flaw in ANGLE commit aadc8f376a ("Implement the CPU fallback for CopyTextureCHROMIUM on OpenGL", 2017-08-11), which added copySubTextureCPUReadback with readPixels before setPixelPackState. A bisect is a technique for finding which change introduced a bug, by narrowing down between a version that works and one that does not. A commit is a recorded change to a code repository, identified by a short hash such as aadc8f376a. The report says pack state was never reset before the read, from day one. The change rolled into Chromium via ed7971c95c05a (2017-08-30) and shipped in Chrome 63 in December 2017. The PBO bypass path that disables ScopedPackStateRowLengthReset when a PBO is bound was added in 5899dbdc3d96d ("Implement async ReadPixels for the passthrough command decoder", 2017-10-05), which made the stale state reachable.

On defences: the report notes that the overflow target is a malloc'd scratch buffer with no MiraclePtr protection, which the ASan trace confirms. The report does not describe any other mitigation that was evaluated.

Fix

The report proposes two options.

  1. Add the pack state dirty bits to kTexImageDirtyBits:
C++
constexpr state::DirtyBits kTexImageDirtyBits{
    state::DIRTY_BIT_UNPACK_STATE,
    state::DIRTY_BIT_UNPACK_BUFFER_BINDING,
    state::DIRTY_BIT_PACK_STATE,            // ADD
    state::DIRTY_BIT_PACK_BUFFER_BINDING,   // ADD
};

This is the same list as before, with the two missing entries added, each marked with an // ADD comment. With them present, syncStateForTexImage() would refresh pack state before the texture image operation, so the stale row length could not survive into the read.

  1. Alternatively, reset pack state in copySubTextureCPUReadback before readPixels (BlitGL.cpp:859), similar to how it already resets pack state afterwards (lines 873-876).

This second option fixes the problem at the point of use rather than at the point of synchronisation: just before the read, put the pack settings back to a known state, the same way the code already does after the read.

The report does not state which fix was adopted, and the supplied material does not include a patch or a confirmation from the vendor.

Variants to test

These are extrapolations from the report's mechanism, not claims made in it.

  1. Other dirty-bit sets that omit pack state. Audit constants such as kTexImageDirtyBits against the operations that consume them. A positive result is a code path where a pack parameter is read from native GL without being synchronised first.
  2. Other callers of readPixels into fixed-size scratch buffers. Look for allocations sized from one set of dimensions while the native read uses a stride from another. A positive result is an ASan report showing a write past the allocation with a stride-derived offset.
  3. Other state-reset scopes that are disabled when a buffer object is bound, in the style of ScopedPackStateRowLengthReset. A positive result is a parameter that survives unbinding and deletion of the buffer and is later consumed by an unrelated operation.
  4. Other format conversions that force a CPU fallback, in the style of the SRGB destination in TextureGL.cpp:1113,1133. A positive result is a copy path that reaches a CPU readback with state inherited from an earlier, unrelated call.
  5. Other GPU-process allocations without MiraclePtr protection that are adjacent to attacker-influenced writes. A positive result is a controllable write landing in a freed or reclaimable region, as in the LLVM MCContext case here.

Glossary

  • ANGLE: the software inside Chrome that translates WebGL and OpenGL ES calls into the graphics language of the machine it runs on.
  • API: a defined set of functions a program can call, like a menu of allowed requests.
  • ASan (AddressSanitizer): a compiler tool that detects out-of-bounds and use-after-free memory accesses at runtime and prints a report.
  • Bisect: a technique for finding the change that introduced a bug by narrowing between a working and a broken version.
  • Blit: a copy of a block of image data from one place to another.
  • Buffer: a reserved block of memory with a fixed size.
  • Bug bounty programme: a scheme that pays researchers for responsibly reporting security flaws.
  • Canvas: the drawing surface a web page uses to render graphics.
  • Chrome VRP: Chrome Vulnerability Reward Program, Google's bug bounty programme for Chrome.
  • Command buffer: a queue of instructions passed from one process to another, used here to send WebGL calls to the GPU process.
  • Commit: a recorded change to a code repository, identified by a hash.
  • CPU: the general-purpose processor that runs most program code.
  • Dirty bit: a marker saying a setting has changed and needs to be refreshed before use.
  • GPU: the graphics processor, specialised for drawing and image work.
  • GPU process: the separate Chrome process that handles graphics work.
  • Heap: the region of memory a program uses for data it allocates while running.
  • Heap buffer overflow: writing past the end of a heap allocation into neighbouring memory.
  • Heap spray: filling the heap with many copies of chosen data so an unpredictable write is likely to hit attacker-controlled content.
  • Heap-use-after-free: using memory after it has been released.
  • JavaScript: the programming language web pages run in the browser.
  • LLVM: a compiler framework; its MCContext bookkeeping appeared in the ASan trace.
  • malloc: the standard C library function for reserving heap memory.
  • Mesa: an open-source graphics library used on Linux.
  • llvmpipe: Mesa's software renderer, which draws graphics on the CPU instead of a GPU.
  • MiraclePtr: a Chrome defence that makes certain use-after-free bugs harder to exploit.
  • Native GL: the real graphics library on the machine, as opposed to ANGLE's own bookkeeping.
  • PBO (pixel buffer object): a chunk of graphics memory used as a temporary destination for pixel data.
  • PACK_ROW_LENGTH: a graphics setting that defines the distance in pixels between the start of one row of pixels and the next when reading pixels out.
  • Primitive: a small, reliable building block of an attack.
  • Proof of concept (PoC): a small file or program that demonstrates a bug.
  • RGBA: a pixel format with red, green, blue and alpha (transparency) values.
  • Row stride: the distance in bytes or pixels between the start of one row and the start of the next.
  • Sandbox: an isolation mechanism that limits what a process can do if it is compromised.
  • Scope: a region of code with a defined beginning and end, whose cleanup can run automatically.
  • Scratch buffer: a temporary buffer used for intermediate work.
  • sRGB / SRGB8_ALPHA8: a standard colour space, and a texture format using it with an alpha channel.
  • Stack trace: the list of function calls that led to a point in a program.
  • Stale: left over and out of date.
  • Texture: an image the graphics system can use when drawing.
  • Thread: a stream of execution inside a process.
  • Unpack / pack state: graphics settings controlling how pixel data is read in (unpack) and read out (pack).
  • VM (virtual machine): a computer simulated in software.
  • WebGL / WebGL2: the web standards that let pages draw 3D graphics through an API.

More by cinzinga

View all

8 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.