Integer overflow in Skia (CVE-2026-13841)
A series of signed 32-bit integer overflows in Skia's Graphite backend let a compromised renderer make the shared gradient buffer's size calculation wrap negative, so the buffer is never enlarged before gradient data is written. This results in a heap out-of-bounds write of attacker-controlled float data in the GPU process, which on Android could potentially lead to a sandbox escape.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 41 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. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: A series of integer overflows in Skia's Graphite backend allow a compromised renderer to trigger a heap out-of-bounds write in the GPU process. This occurs when aggregating large numbers of gradient stops into a shared buffer, leading to container state corruption and undersized allocations. On Android, where the GPU process is unsandboxed, this could potentially lead to a full sandbox escape.
Affected files:
third_party/skia/src/gpu/graphite/PipelineData.hthird_party/skia/src/gpu/graphite/KeyHelpers.cppthird_party/skia/src/base/SkTDArray.cppthird_party/skia/include/private/base/SkTDArray.h
Estimated timestamp from git blame: 2024-06-11
Summary
In Skia's Graphite rendering backend, the FloatStorageManager aggregates gradient color and offset data for all draw calls within a single DrawPass into a shared SkTDArray<float>. By accumulating a large number of gradient stops across multiple drawing commands, a compromised renderer can trigger a 32-bit signed integer overflow in the buffer's size calculation. This leads to a logic error in SkTDArray where the buffer is not correctly resized, resulting in a subsequent out-of-bounds write of attacker-controlled float data.
Technical Details
1. Integer Overflow in Size Calculation
In third_party/skia/src/gpu/graphite/PipelineData.h, the allocateFloatData function calculates the new required size for the shared gradient buffer:
// PipelineData.h:515
void allocateFloatData(int floatCount) {
int currentSize = fGradientStorage.size();
fGradientStorage.resize(currentSize + floatCount);
float* startPtr = fGradientStorage.begin() + currentSize;
return {startPtr, currentSize};
}
currentSize and floatCount are signed 32-bit integers. By sending many draw calls within a single Graphite recorder session, an attacker can cause currentSize to approach INT_MAX. A final draw call with a sufficient floatCount will cause the addition currentSize + floatCount to overflow and wrap to a negative value.
2. Logic Error in SkTDStorage::resize
When fGradientStorage.resize() is called with a negative value, it reaches SkTDStorage::resize in third_party/skia/src/base/SkTDArray.cpp:
void SkTDStorage::resize(int newSize) {
SkASSERT(newSize >= 0); // Compiled out in release builds
if (newSize > fCapacity) {
this->reserve(newSize);
}
fSize = newSize;
}
In release builds, the SkASSERT is removed. Because newSize is negative and fCapacity is a large positive value, the reserve() call is skipped. The buffer is not enlarged, but the logical size fSize is corrupted to the negative value.
3. Out-of-Bounds Write
Back in allocateFloatData, a pointer startPtr is returned pointing into the existing buffer at the old currentSize. The function write_color_and_offset_bufdata in KeyHelpers.cpp then writes the gradient data (RGBA floats and offsets) into this pointer. Since the buffer was never resized to accommodate the new data, this results in a heap out-of-bounds write of attacker-controlled floats.
Potential Exploitation Steps
- Use a compromised renderer process to send a stream of unique gradient draw commands via OOP-Rasterization.
- Accumulate approximately 2GB of gradient data in the GPU process's Graphite recorder to reach the 32-bit signed integer limit.
- Send a final drawing command that triggers the signed integer overflow in
allocateFloatData. - Leverage the resulting heap out-of-bounds write to corrupt adjacent heap objects (e.g., virtual function tables) in the GPU process.
Suggested Fix
- In
PipelineData.h, usebase::CheckedNumericorSkSafeMathto perform the size calculation inallocateFloatDataand handle overflows by failing the draw pass or discarding the data. - Harden
SkTDStorage::resizeto explicitly check and fail ifnewSize < 0in all build types, or transition the container to usesize_tfor its size and capacity members.
Evaluated with Chrome root at commit: 29093e11cf509e3593f6229e4b1b075cca356049
Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:
- If you are familiar with the severity guidelines, you may adjust the severity.
- If this is a false positive, and there's no work to be done, please close as WAI.
- If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.
Data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the size arithmetic in allocateFloatData uses signed 32-bit integers without overflow checks, and SkTDStorage::resize only asserts non-negative sizes, which is compiled out in release builds, so a wrapped negative size skips the reserve and corrupts the logical size.
Impact
A compromised renderer could corrupt GPU process heap memory, and on Android, where the GPU process is unsandboxed, this could potentially lead to a full sandbox escape.
What the attacker needed
Compromised renderer process; roughly 2GB of gradient data accumulated; Android for the sandbox escape claim
The fix
The size calculation should use checked arithmetic such as base::CheckedNumeric or SkSafeMath and fail the draw pass on overflow, and resize should reject negative sizes in all build types or use size_t for size and capacity.
How it was found
- Use a compromised renderer process to send a stream of unique gradient draw commands via OOP-Rasterization.
- Accumulate roughly 2GB of gradient data in the GPU process's Graphite recorder to reach the 32-bit signed integer limit.
- Send a final drawing command that triggers the signed integer overflow in allocateFloatData.
- Use the resulting heap out-of-bounds write to corrupt adjacent heap objects such as virtual function tables in the GPU process.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A renderer is the part of the browser that turns a web page into pixels, and it is kept in a separate, restricted process so a bug there is contained. Here, a bug in the graphics library that collects colour data for gradients miscalculates how much memory is needed when the running total gets very large, so it writes past the end of a buffer. Writing outside a buffer can corrupt other data in the more privileged GPU process, which on Android is not sandboxed.
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.