Heap buffer overflow in Skia (CVE-2026-7353)
A logic error in SkRegion::Iterator causes it to yield more rectangles than the region's reported interval count when parsing empty spans. A compromised renderer can send a crafted region to the GPU process, leading to a heap buffer overflow and potential remote code execution.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 28 days
Project Fortify, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports without the security team.
Overview: A logic error in SkRegion::Iterator causes it to desynchronize when parsing a region with empty spans, yielding more rectangles than its reported interval count. When such a crafted region is sent to the GPU process and drawn using RegionOp, these excess rectangles cause an out-of-bounds write in the VertexWriter. This leads to a potential heap-based buffer overflow and RCE in the privileged GPU process.
Affected files:
third_party/skia/src/gpu/ganesh/ops/RegionOp.cppthird_party/skia/src/core/SkRegion.cppthird_party/skia/src/gpu/BufferWriter.h
Estimated timestamp from git blame: 2021-10-26
Summary
A vulnerability in Skia's SkRegion deserialization and iteration logic allows a compromised renderer process to trigger a heap-based out-of-bounds write in the highly privileged GPU process.
By crafting a serialized SkRegion containing empty y-spans, an attacker can cause SkRegion::Iterator to desynchronize during iteration. This desynchronization results in the iterator yielding more rectangles than the region's reported total interval count. The Ganesh RegionOp uses the trusted interval count to allocate its vertex buffer, and the subsequent iteration with the desynchronized iterator overflows this buffer.
Vulnerability Details
1. Incomplete Validation in SkRegion::readFromMemory
The validate_run function in third_party/skia/src/core/SkRegion.cpp, called during readFromMemory, checks that the number of x-intervals in each span is within bounds. However, it does not prevent a region from containing consecutive empty y-spans (where xIntervals == 0). While a single empty span is a valid structural element in Skia to represent vertical gaps, consecutive empty spans or empty spans at the end of a region can trigger parsing bugs downstream.
2. Iterator Desynchronization in SkRegion::Iterator::next()
The SkRegion::Iterator::next() function (third_party/skia/src/core/SkRegion.cpp:1409) has a critical logic flaw when handling empty spans.
if (runs[0] < SkRegion_kRunTypeSentinel) { // valid Y value
int intervals = runs[1];
if (0 == intervals) { // empty line
fRect.fTop = runs[0];
runs += 3; // Advance past the empty span
} else {
fRect.fTop = fRect.fBottom;
}
// BUG: Execution unconditionally falls through to here.
fRect.fBottom = runs[0];
assert_sentinel(runs[2], false);
// ...
When it encounters an empty span (intervals == 0), it sets fRect.fTop and advances the run pointer by 3 (runs += 3) to skip it. However, it fails to return or continue. It unconditionally proceeds to read the "next" span's data within the same next() call. Because runs was already advanced, it misinterprets the subsequent structural metadata (like sentinels or the next span's headers) as rectangle coordinates. The iterator yields a "phantom" rectangle and its internal state becomes completely desynchronized from the true run array structure.
3. OOB Write in Ganesh RegionOp
In third_party/skia/src/gpu/ganesh/ops/RegionOp.cpp, RegionOpImpl::onPrepareDraws calculates the required vertex buffer size using computeRegionComplexity(), which returns the region's fIntervalCount (trusted from the deserialized header). It then allocates a vertex buffer for exactly this number of quads using a QuadHelper.
Subsequently, it iterates through the region using SkRegion::Iterator in a while (!iter.done()) loop, calling vertices.writeQuad() for each rectangle yielded.
Because the iterator desynchronizes on empty spans, it consumes multiple structural elements to produce single phantom rectangles, failing to terminate correctly. Consequently, it yields more rectangles than the originally allocated fIntervalCount.
VertexWriter (third_party/skia/src/gpu/BufferWriter.h) relies entirely on SkASSERT for bounds checking, which compiles to a no-op in Release builds. When writeQuad is called for the excess rectangles, it writes attacker-controlled floating-point data past the end of the allocated vertex buffer on the heap.
Potential Attack Steps
Note: These steps are based on static analysis, as our tooling agent does not currently run exploit code.
- Initial Compromise: An attacker gains arbitrary code execution in the sandboxed Renderer process.
- Crafting the Payload: The attacker crafts a serialized
SkRegionbyte array. The header specifies a smallintervalCount(e.g., 1). The run array is structured with empty spans followed by carefully chosen data designed to be misinterpreted as attacker-controlled rectangle coordinates. - Embedding in IPC: The attacker embeds this
SkRegioninto anAlphaThresholdPaintFilteras part of acc::PaintOpBufferstream. - Triggering the Bug: The compromised Renderer sends this
PaintOpBufferto the GPU process for Out-of-Process Rasterization (OOP-R) via thekRasterCHROMIUMcommand. - Execution: The GPU process deserializes the
PaintOpBuffer, instantiates the filter, and attempts to draw the region using Ganesh. The iterator desynchronizes, yielding excess rectangles, and theVertexWriteroverflows the heap buffer, leading to Remote Code Execution (RCE) in the GPU process.
Suggested Fix
- Fix the Iterator: In
SkRegion::Iterator::next()(third_party/skia/src/core/SkRegion.cpp), modify the empty line handling block to either loop to find the next valid interval or return immediately after advancing the pointer.
if (0 == intervals) { // empty line
fRect.fTop = runs[0];
runs += 3;
fRuns = runs;
// RECURSE OR LOOP HERE to find the next valid rectangle instead of falling through.
this->next();
return;
}
- Harden Validation: Update
validate_runto explicitly reject consecutive empty spans or empty spans at the end of a region if they are considered malformed.
Evaluated with Chrome root at commit: ff3d2b74fa39431785bd60e51463b08fcc71ee33
Results so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, the iterator's handling of empty spans falls through without returning, causing it to misinterpret subsequent data as rectangle coordinates and yield extra rectangles, while the buffer allocation trusts the region's reported interval count.
Impact
A compromised renderer could cause a heap-based buffer overflow in the privileged GPU process, potentially leading to remote code execution.
What the attacker needed
Compromise of the renderer process; ability to send crafted IPC to GPU process
The fix
The iterator should be modified to loop or return after advancing past an empty span, and validation should reject consecutive empty spans or empty spans at the end of a region.
How it was found
- An attacker gains arbitrary code execution in the sandboxed Renderer process.
- The attacker crafts a serialized SkRegion byte array with a small intervalCount and empty spans followed by data that will be misinterpreted as rectangle coordinates.
- The attacker embeds this SkRegion into an AlphaThresholdPaintFilter as part of a cc::PaintOpBuffer stream.
- The compromised Renderer sends this PaintOpBuffer to the GPU process for Out-of-Process Rasterization (OOP-R) via the kRasterCHROMIUM command.
- The GPU process deserializes the PaintOpBuffer, instantiates the filter, and attempts to draw the region using Ganesh, triggering the iterator desynchronization and heap buffer overflow.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Skia is a graphics library used by Chrome. A region is a shape made of rectangles. The code that reads a region from untrusted input can be tricked into producing more rectangles than it says it has, and when those are drawn, they overflow a buffer in the GPU process, which handles graphics and has high privileges. This could let an attacker run code on the victim's machine.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.