Integer overflow in Skia (CVE-2025-0436)
A crafted Skia path can make the quad count in AAHairlineOp::onPrepareDraws grow large enough that an integer addition overflows, so a vertex buffer is allocated too small. The code then writes quad vertices past the end of that buffer, causing an out-of-bounds write on the GPU path.
- Fix shipped in 38 days
Steps to reproduce the problem
- [optional] apply skia patch (only accelerate the computation to enhance bug reproduce)
- build skpbench with ubsan
- run script to generate path.skp and run ./skpbench --src poc/path.skp --config gles
Problem Description
In function AAHairlineOp::onPrepareDraws, the quadCount iterate every path and add gather_lines_and_quads, which can be controlled by fPath. by creating crafted skia path, we're able to increase the gather_lines_and_quads results to 0xf0f4 in the poc. and there are no additional verification for the quadCount to prevent overflow.
int instanceCount = fPaths.size();
bool convertConicsToQuads = !target->caps().shaderCaps()->fFloatIs32Bits;
for (int i = 0; i < instanceCount; i++) {
const PathData& args = fPaths[i];
int quadCount += gather_lines_and_quads(args.fPath, args.fViewMatrix, args.fDevClipBounds,
args.fCapLength, convertConicsToQuads, &lines, &quads,
&conics, &qSubdivs, &cWeights);
// [1] gather_lines_and_quads can be super large (e.g. 0xf0f4)
// therefore the quadCount may overflow
}
Subsequently, the quadCount is used for allocation at [2-3], endup being used to allocate
buffer at [4]. Therefore, the OOB will happen at [5]
int quadAndConicCount = conicCount + quadCount; //[2]
static constexpr int kMaxLines = SK_MaxS32 / kLineSegNumVertices;
static constexpr int kMaxQuadsAndConics = SK_MaxS32 / kQuadNumVertices;
if (lineCount > kMaxLines || quadAndConicCount > kMaxQuadsAndConics) {
return;
}
int vertexCount = kQuadNumVertices * quadAndConicCount; // [3]
void* vertices = target->makeVertexSpace(sizeof(BezierVertex), vertexCount, &vertexBuffer,
&firstVertex); // [4]
if (!vertices || !quadsIndexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
}
BezierVertex* bezVerts = reinterpret_cast<BezierVertex*>(vertices);
int unsubdivQuadCnt = quads.size() / 3;
for (int i = 0; i < unsubdivQuadCnt; ++i) {
SkASSERT(qSubdivs[i] >= 0);
if (!quads[3*i].isFinite() || !quads[3*i+1].isFinite() || !quads[3*i+2].isFinite()) {
return;
}
add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &bezVerts); //[5]
}
Summary
Security: Skia integer overflow (results in OOB) at AAHairlineOp::onPrepareDraws
Custom Questions
Type of crash:
gpu
Reporter credit:
Han Zheng (HexHive)
Additional Data
Category: Security
Chrome Channel: Not sure
Regression: N/A
Context
Skia is the 2D graphics library used by Chrome for rendering. One of its GPU drawing paths is the hairline path renderer, implemented in AAHairlineOp. When Skia draws anti-aliased hairlines on the GPU, AAHairlineOp::onPrepareDraws walks every path in the draw batch, converts each path into line segments, quads and conics, and then allocates a vertex buffer large enough to hold the resulting geometry before filling it.
The report describes an integer overflow in that preparation step. The number of quads produced from a path is attacker-influenced, and the code that turns that count into a buffer size does not guard against the count wrapping around. The result is an out-of-bounds access on the GPU path.
The issue was tracked as CVE-2025-0436, rated high severity, in the Google Chrome program through the Chrome VRP. The reporter credit is Han Zheng (HexHive), and the bounty was 3000.00 USD. It was disclosed on 2025-01-14.
Setup
The reproduction does not need a full browser. It uses skpbench, a Skia benchmarking tool that replays a recorded .skp picture, built with UndefinedBehaviorSanitizer so that the overflow is reported. The GPU configuration used is gles.
Preconditions:
- A Skia build that includes
skpbench, compiled with ubsan. - A crafted
.skpfile containing the malicious path. - Optionally, a Skia patch that accelerates the computation, purely to make the bug easier to reproduce.
Finding it
The researcher looked at AAHairlineOp::onPrepareDraws, where the per-path quad count is accumulated:
int instanceCount = fPaths.size();
bool convertConicsToQuads = !target->caps().shaderCaps()->fFloatIs32Bits;
for (int i = 0; i < instanceCount; i++) {
const PathData& args = fPaths[i];
int quadCount += gather_lines_and_quads(args.fPath, args.fViewMatrix, args.fDevClipBounds,
args.fCapLength, convertConicsToQuads, &lines, &quads,
&conics, &qSubdivs, &cWeights);
// [1] gather_lines_and_quads can be super large (e.g. 0xf0f4)
// therefore the quadCount may overflow
}
The value returned by gather_lines_and_quads depends on args.fPath, which comes from the picture being drawn. By crafting the path, the researcher could make that function return 0xf0f4 quads for a single path. The running quadCount is a plain int, and nothing checks it before it is used, so a large enough contribution wraps the counter.
Exploitation
Step 1: build the harness
Build skpbench with ubsan, optionally after applying a Skia patch that only accelerates the computation to make the bug easier to reproduce.
Step 2: generate the malicious picture
Run the script that generates path.skp, the picture containing the crafted path.
Step 3: replay it on the GPU
./skpbench --src poc/path.skp --config gles
This replays the picture through the GLES backend, which reaches AAHairlineOp::onPrepareDraws with the crafted path.
Step 4: the overflow reaches the allocation
After the loop, the accumulated quadCount is combined with the conic count and used to size the vertex allocation:
int quadAndConicCount = conicCount + quadCount; //[2]
static constexpr int kMaxLines = SK_MaxS32 / kLineSegNumVertices;
static constexpr int kMaxQuadsAndConics = SK_MaxS32 / kQuadNumVertices;
if (lineCount > kMaxLines || quadAndConicCount > kMaxQuadsAndConics) {
return;
}
int vertexCount = kQuadNumVertices * quadAndConicCount; // [3]
void* vertices = target->makeVertexSpace(sizeof(BezierVertex), vertexCount, &vertexBuffer,
&firstVertex); // [4]
if (!vertices || !quadsIndexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
}
BezierVertex* bezVerts = reinterpret_cast<BezierVertex*>(vertices);
int unsubdivQuadCnt = quads.size() / 3;
for (int i = 0; i < unsubdivQuadCnt; ++i) {
SkASSERT(qSubdivs[i] >= 0);
if (!quads[3*i].isFinite() || !quads[3*i+1].isFinite() || !quads[3*i+2].isFinite()) {
return;
}
add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &bezVerts); //[5]
}
At [2] the wrapped quadCount is added to conicCount. The sanity check that follows compares quadAndConicCount against kMaxQuadsAndConics, but because the value has already overflowed it passes the check. At [3] the vertex count is computed from the wrapped value, and at [4] that count is used to allocate GPU vertex space. The loop at [5] then writes every quad from the quads array through add_quads into bezVerts, which points into the undersized allocation. The number of quads actually written is derived from quads.size(), not from the wrapped count, so the writes run past the end of the buffer: an out-of-bounds write.
Root cause
The bug is an integer overflow in the accumulation of quadCount in AAHairlineOp::onPrepareDraws. The per-path result of gather_lines_and_quads is attacker-controlled through the path geometry, and the sum is stored in a signed int with no check on each addition. The later guard (quadAndConicCount > kMaxQuadsAndConics) is intended to bound the allocation, but it operates on the already-wrapped value, so it cannot catch the case. The multiplication at [3] and the allocation at [4] therefore use a small, incorrect size while the write loop at [5] iterates over the real, much larger quad array.
Impact
A crafted Skia path, delivered through a picture that reaches the hairline GPU renderer, causes an out-of-bounds write in the vertex buffer on the GPU path. The report classifies the crash type as gpu and the weakness as an integer overflow resulting in OOB. The report does not describe a full exploit chain, so the practical impact beyond memory corruption in the renderer is not established here.
Fix
The report does not state which change was made. The natural fix, following from the analysis, is to validate the per-path return value of gather_lines_and_quads and the running quadCount before they can wrap, so that the existing kMaxQuadsAndConics guard sees the true count rather than an overflowed one.
Variants to test
- Other path renderers that accumulate counts across paths in a loop and then size a GPU buffer from the total. A positive result is a wrapped count that passes the size guard and produces an allocation smaller than the number of elements written.
- Other callers of
gather_lines_and_quadsor similar geometry-gathering helpers where the return value feeds an allocation. A positive result is a ubsan signed-integer-overflow report on the accumulation. - Paths that produce large conic counts, since
conicCountis added toquadCountat [2]. A positive result is an overflow reached through the conic contribution rather than the quad contribution. - Different GPU backends and configurations. The report uses
gles; a positive result elsewhere is the same OOB write under ubsan or a sanitizer build.
Hunting notes
This kind of bug hides in geometry preparation code that sums per-primitive counts into a fixed-width integer and then multiplies that sum to size a buffer. During recon, look for loops over paths or primitives where the count comes from parsed or attacker-supplied geometry, and for guards that compare the total against a maximum only after the sum has been computed. Building the target with ubsan and replaying crafted inputs through the GPU path is a direct way to surface the overflow. The report gives a reproducible harness command, a crafted picture and the line where the out-of-bounds access occurs.
What happened, in plain words
Chrome draws everything you see on a web page, text, shapes, images, using a graphics library called Skia. Skia is the part of Chrome that turns instructions like "draw a thin line here" into pixels on your screen. When your computer has a graphics card (GPU), Skia can hand some of that drawing work to the GPU, which is much faster than doing it all on the main processor.
One of the drawing jobs Skia does on the GPU is drawing very thin lines, called hairlines. The code for that job lives in a class named AAHairlineOp. Before it can draw, it has to work out how much memory it needs: it counts up all the little pieces of geometry it is about to draw, asks the GPU for a chunk of memory big enough to hold them, and then fills that memory with the pieces.
The problem is in the counting. The number of pieces produced from a shape is influenced by the shape itself, and a shape can be crafted by an attacker. If the count gets large enough, it wraps around, the way an old car odometer rolls from 999999 back to 000000. Skia then asks the GPU for a smaller piece of memory than the real pieces need, and the write loop runs past its end. Writing past the end of a piece of memory is called an out-of-bounds write, and it is a serious class of bug because it can corrupt other data or crash the program.
This was tracked as CVE-2025-0436, rated high severity, in the Google Chrome program through the Chrome VRP. The reporter credit is Han Zheng (HexHive), the bounty was 3000.00 USD, and it was disclosed on 2025-01-14.
Some background before we start
A few ideas come up again and again below, so here they are from zero.
What Skia is. Skia is a library, meaning a collection of ready-made code that other programs can use. Chrome uses it to draw. A library is like a toolbox: Chrome does not build its own hammer every time it needs to draw a rectangle, it reaches into the Skia toolbox.
What a GPU is. The graphics processing unit is the chip in your computer that specialises in drawing. It is very good at doing the same small operation on many things at once, which is exactly what drawing thousands of tiny shapes requires. Code that runs on the GPU is often called the GPU path, as opposed to the CPU path, which runs on the main processor.
What a path is. In graphics, a path is a shape described as a sequence of points and curves. A circle, a squiggle, the outline of a letter: all of these can be expressed as paths. Skia reads paths and turns them into the pieces it actually draws.
What a quad and a conic are. When Skia prepares a path for drawing, it breaks curves into simpler pieces. A quad is a small four-sided shape, and a conic is a curve piece. A hairline, which is a line too thin to have a real width, gets chopped into many of these pieces so the GPU can draw them efficiently.
What a vertex is. A vertex is a corner point. Graphics code describes shapes by listing their corner points, and a buffer full of vertices is just a list of points in memory that the GPU will read.
What a buffer is. A buffer is a reserved block of memory, like a row of numbered lockers. You ask for a row of a certain length, and then you are only allowed to put things in those lockers. Writing into a locker past the end of your row is the out-of-bounds write mentioned above.
What an integer overflow is. Computers store whole numbers in fixed-size boxes. A common box is the 32-bit signed integer, usually called int, which can hold values from about minus two billion to about plus two billion. If you keep adding to a number and it goes past the top of the range, it does not stop; it wraps around to the bottom, just like a car odometer rolling over. The result is a small or negative number where you expected a huge one. That is an integer overflow, and it is dangerous whenever the number is later used to decide how much memory to reserve.
What a sanitizer is. A sanitizer is a debugging tool built into a program that watches for mistakes while the program runs. UndefinedBehaviorSanitizer, or ubsan, is one of them: it specifically shouts when the program does something the programming language says is undefined, such as overflowing a signed integer. Building a program "with ubsan" means compiling it with this watchdog switched on.
What a .skp file is. Skia can record a drawing session into a file with the .skp extension, and replay it later. Think of it as a video recording of drawing commands rather than of pixels. Replaying a crafted recording is a convenient way to feed hostile shapes into Skia without needing a whole browser.
What skpbench is. skpbench is a small benchmarking tool that ships with Skia. Its job is to replay .skp files and measure how fast they draw. For our purposes it is simply a way to run Skia's drawing code on a chosen file.
What GLES is. GLES stands for OpenGL ES, a standard way for programs to talk to a GPU. When skpbench is told to use the gles configuration, it draws through that standard, which is the route that reaches the hairline code described here.
What CVE and the Chrome VRP are. CVE stands for Common Vulnerabilities and Exposures: a public catalogue where each security bug gets a permanent identifier, here CVE-2025-0436. The Chrome VRP is Google's Vulnerability Reward Program, which pays people who report security bugs in Chrome. A bounty is the payment made for a valid report.
Context
Skia is the 2D graphics library used by Chrome for rendering. One of its GPU drawing paths is the hairline path renderer, implemented in AAHairlineOp. When Skia draws anti-aliased hairlines on the GPU, AAHairlineOp::onPrepareDraws walks every path in the draw batch, converts each path into line segments, quads and conics, and then allocates a vertex buffer large enough to hold the resulting geometry before filling it.
Anti-aliasing is the smoothing trick that stops diagonal lines looking jagged. It works by drawing lots of small pieces along the edge, which is why the hairline renderer ends up with so many quads to count.
The report describes an integer overflow in that preparation step. The number of quads produced from a path is attacker-influenced, and the code that turns that count into a buffer size does not guard against the count wrapping around. The result is an out-of-bounds write on the GPU side.
The issue was tracked as CVE-2025-0436, rated high severity, in the Google Chrome program through the Chrome VRP. The reporter credit is Han Zheng (HexHive), and the bounty was 3000.00 USD. It was disclosed on 2025-01-14.
Setup
The reproduction does not need a full browser. It uses skpbench, a Skia benchmarking tool that replays a recorded .skp picture, built with UndefinedBehaviorSanitizer so that the overflow is reported. The GPU configuration used is gles.
Why this setup? A full browser is a huge program with many moving parts, and it is hard to tell which part misbehaved. skpbench is small and does one thing: replay a drawing recording. Building it with ubsan means that the moment the integer wraps, the tool prints a warning instead of silently carrying on. And using the gles configuration makes sure the drawing goes down the GPU route where the hairline code lives.
Preconditions:
- A Skia build that includes
skpbench, compiled with ubsan. - A crafted
.skpfile containing the malicious path. - Optionally, a Skia patch that accelerates the computation, purely to make the bug easier to reproduce.
A patch here means a small modification to the source code before building. The one mentioned only speeds up the calculation; it does not change the bug itself. It is there only to speed up the calculation.
Finding it
The researcher looked at AAHairlineOp::onPrepareDraws, where the per-path quad count is accumulated:
int instanceCount = fPaths.size();
bool convertConicsToQuads = !target->caps().shaderCaps()->fFloatIs32Bits;
for (int i = 0; i < instanceCount; i++) {
const PathData& args = fPaths[i];
int quadCount += gather_lines_and_quads(args.fPath, args.fViewMatrix, args.fDevClipBounds,
args.fCapLength, convertConicsToQuads, &lines, &quads,
&conics, &qSubdivs, &cWeights);
// [1] gather_lines_and_quads can be super large (e.g. 0xf0f4)
// therefore the quadCount may overflow
}
Line by line:
int instanceCount = fPaths.size();asks how many paths are waiting to be drawn and stores that number ininstanceCount.fPathsis the list of paths in this batch.bool convertConicsToQuads = ...decides whether curve pieces (conics) should be turned into quads. It depends on whether the GPU works with 32-bit floating point numbers. This is a capability check: Skia asks the GPU what it can do and adapts.for (int i = 0; i < instanceCount; i++) {starts a loop that visits each path in turn, one per iteration.const PathData& args = fPaths[i];picks out the current path and its associated settings, such as the view matrix (how the shape is positioned on screen) and the clip bounds (the region it is allowed to draw into).int quadCount += gather_lines_and_quads(...)is the heart of it.gather_lines_and_quadsexamines the path and works out how many lines, quads and conics it needs, writing those pieces into thelines,quads,conics,qSubdivsandcWeightscollections. It returns the number of quads, and that number is added to a running total calledquadCount. The+=means "add to what is already there".- The two comment lines, marked
[1], are the researcher's note: the returned value can be very large, for example 0xf0f4, and therefore the running total can overflow.
The value returned by gather_lines_and_quads depends on args.fPath, which comes from the picture being drawn. By crafting the path, the researcher could make that function return 0xf0f4 quads for a single path. The running quadCount is a plain int, and nothing checks it before it is used, so a large enough contribution wraps the counter.
0xf0f4 is a number written in hexadecimal, a base-16 way of writing numbers that programmers use a lot. It equals 61,684 in ordinary decimal. That is not enormous by itself, but the number is chosen by the shape, and a large enough contribution can push the total past the top of the int range.
Exploitation
Step 1: build the harness
Build skpbench with ubsan, optionally after applying a Skia patch that only accelerates the computation to make the bug easier to reproduce.
This step produces the tool that will run the hostile drawing. The ubsan build is what turns a silent wrap-around into a visible report. The optional patch is a convenience, not a requirement.
Step 2: generate the malicious picture
Run the script that generates path.skp, the picture containing the crafted path.
A script is a small program that automates a task. Here it writes out the .skp recording containing the specially shaped path. The shape is the input that controls how many quads gather_lines_and_quads will report.
Step 3: replay it on the GPU
./skpbench --src poc/path.skp --config gles
Line by line:
./skpbenchruns the benchmarking tool that was just built. The./simply means "the program in the current folder".--src poc/path.skptells it which recording to replay: the crafted picture sitting in thepocfolder.pocis short for proof of concept, the file that demonstrates the bug.--config glestells it to draw through the GLES backend, the GPU route.
This replays the picture through the GLES backend, which reaches AAHairlineOp::onPrepareDraws with the crafted path.
Step 4: the overflow reaches the allocation
After the loop, the accumulated quadCount is combined with the conic count and used to size the vertex allocation:
int quadAndConicCount = conicCount + quadCount; //[2]
static constexpr int kMaxLines = SK_MaxS32 / kLineSegNumVertices;
static constexpr int kMaxQuadsAndConics = SK_MaxS32 / kQuadNumVertices;
if (lineCount > kMaxLines || quadAndConicCount > kMaxQuadsAndConics) {
return;
}
int vertexCount = kQuadNumVertices * quadAndConicCount; // [3]
void* vertices = target->makeVertexSpace(sizeof(BezierVertex), vertexCount, &vertexBuffer,
&firstVertex); // [4]
if (!vertices || !quadsIndexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
}
BezierVertex* bezVerts = reinterpret_cast<BezierVertex*>(vertices);
int unsubdivQuadCnt = quads.size() / 3;
for (int i = 0; i < unsubdivQuadCnt; ++i) {
SkASSERT(qSubdivs[i] >= 0);
if (!quads[3*i].isFinite() || !quads[3*i+1].isFinite() || !quads[3*i+2].isFinite()) {
return;
}
add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &bezVerts); //[5]
}
Line by line:
int quadAndConicCount = conicCount + quadCount;at[2]adds the conic count to the quad count. This is the total number of curved pieces Skia believes it has.static constexpr int kMaxLines = SK_MaxS32 / kLineSegNumVertices;computes a ceiling for the number of lines.SK_MaxS32is the largest value a 32-bit signed integer can hold, and dividing it by the number of vertices each line needs gives the most lines that can be handled without the vertex count overflowing.static constexpr int kMaxQuadsAndConics = SK_MaxS32 / kQuadNumVertices;does the same for quads and conics: the largest number of pieces whose vertex count still fits.if (lineCount > kMaxLines || quadAndConicCount > kMaxQuadsAndConics) { return; }is the safety check. If either total is too big, stop and draw nothing. This is the guard that is supposed to prevent the problem.int vertexCount = kQuadNumVertices * quadAndConicCount;at[3]multiplies the number of pieces by the number of vertices each piece needs, giving the total number of vertices to reserve room for.void* vertices = target->makeVertexSpace(sizeof(BezierVertex), vertexCount, ...)at[4]asks the GPU for that much space.sizeof(BezierVertex)is the size in bytes of one vertex record, andvertexCountis how many records are wanted. The result,vertices, is a pointer to the start of the reserved memory.if (!vertices || !quadsIndexBuffer) { SkDebugf("Could not allocate vertices\n"); return; }handles the case where the reservation failed.SkDebugfprints a message, andreturngives up.BezierVertex* bezVerts = reinterpret_cast<BezierVertex*>(vertices);reinterprets the raw memory pointer as a pointer to vertex records, so the code can write vertices into it one after another.reinterpret_castis a way of telling the compiler "treat this block of bytes as this kind of thing".int unsubdivQuadCnt = quads.size() / 3;works out how many quads are actually in thequadscollection. Each quad is stored as three points, hence the division by three.for (int i = 0; i < unsubdivQuadCnt; ++i) {loops over every one of those real quads.SkASSERT(qSubdivs[i] >= 0);is a debug-only assertion that a subdivision count is not negative.if (!quads[3*i].isFinite() || ...) { return; }checks that the three points of the current quad are finite numbers, not infinities or not-a-number values, and bails out if not.add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &bezVerts);at[5]writes the quad into the vertex memory and advancesbezVertspast what it wrote.
At [2] the wrapped quadCount is added to conicCount. The sanity check that follows compares quadAndConicCount against kMaxQuadsAndConics, but because the value has already overflowed it passes the check. At [3] the vertex count is computed from the wrapped value, and at [4] that count is used to allocate GPU vertex space. The loop at [5] then writes every quad from the quads array through add_quads into bezVerts, which points into the undersized allocation. The number of quads actually written is derived from quads.size(), not from the wrapped count, so the writes run past the end of the buffer: an out-of-bounds write.
A comparison helps. Imagine a form that asks how many boxes you need, and a clerk who adds up your requests. If the total rolls over to a small number, the clerk reserves a small shelf. But the warehouse still sends all the real boxes, and the person stacking them keeps going past the end of the shelf, knocking into whatever is stored next to it.
Root cause
The bug is an integer overflow in the accumulation of quadCount in AAHairlineOp::onPrepareDraws. The per-path result of gather_lines_and_quads is attacker-controlled through the path geometry, and the sum is stored in a signed int with no check on each addition. The later guard (quadAndConicCount > kMaxQuadsAndConics) is intended to bound the allocation, but it operates on the already-wrapped value, so it cannot catch the case. The multiplication at [3] and the allocation at [4] therefore use a small, incorrect size while the write loop at [5] iterates over the real, much larger quad array.
In other words, the check is in the wrong place in the sequence. It inspects the total after the damage has been done, rather than checking each addition as it happens.
Impact
A crafted Skia path, delivered through a picture that reaches the hairline GPU renderer, causes an out-of-bounds write in the vertex buffer on the GPU path. The report classifies the crash type as gpu and the weakness as an integer overflow resulting in OOB. The report does not describe a full exploit chain, so the practical impact beyond memory corruption in the renderer is not established here.
Memory corruption means memory has been written where it should not have been, which can lead to a crash or, in the worst case, to an attacker influencing behaviour they should not control. How far that could be taken is not shown in this report.
Fix
The report does not state which change was made. The natural fix, following from the analysis, is to validate the per-path return value of gather_lines_and_quads and the running quadCount before they can wrap, so that the existing kMaxQuadsAndConics guard sees the true count rather than an overflowed one.
Put simply: check the total as it grows, not only at the end, so the safety check is never fooled by a number that has already rolled over.
Variants to test
- Other path renderers that accumulate counts across paths in a loop and then size a GPU buffer from the total. A positive result is a wrapped count that passes the size guard and produces an allocation smaller than the number of elements written.
- Other callers of
gather_lines_and_quadsor similar geometry-gathering helpers where the return value feeds an allocation. A positive result is a ubsan signed-integer-overflow report on the accumulation. - Paths that produce large conic counts, since
conicCountis added toquadCountat[2]. A positive result is an overflow reached through the conic contribution rather than the quad contribution. - Different GPU backends and configurations. The report uses
gles; a positive result elsewhere is the same OOB write under ubsan or a sanitizer build.
A variant, in security work, is a nearby piece of code that might have the same mistake. If one counting loop forgot to check for overflow, other counting loops written by the same people in the same style may have forgotten too.
Hunting notes
This kind of bug hides in geometry preparation code that sums per-primitive counts into a fixed-width integer and then multiplies that sum to size a buffer. During recon, look for loops over paths or primitives where the count comes from parsed or attacker-supplied geometry, and for guards that compare the total against a maximum only after the sum has been computed. Building the target with ubsan and replaying crafted inputs through the GPU path is a direct way to surface the overflow. The report gives a reproducible harness command, a crafted picture and the line where the out-of-bounds access occurs.
Recon, short for reconnaissance, means the exploratory reading of code before attacking it: finding the interesting places, understanding how data flows through them, and noting where input from outside the program ends up being trusted.
Glossary
- AAHairlineOp: the Skia class that prepares and draws very thin (hairline) lines on the GPU.
- Anti-aliasing: a smoothing technique that draws extra small pieces along edges so they do not look jagged.
- API: an agreed way for one piece of software to ask another to do something, like a menu of available requests.
- Backend: the underlying system a program uses to do a job, here the GLES route for talking to the GPU.
- Bounty: a payment made by a company for a valid security report.
- Buffer: a reserved block of memory used to hold data, such as a list of vertices.
- Chrome VRP: Google's Vulnerability Reward Program for Chrome, which receives and pays for security reports.
- Conic: a curve piece produced when Skia breaks a path into simpler geometry.
- CVE: Common Vulnerabilities and Exposures, a public catalogue giving each security bug a permanent identifier.
- GLES: OpenGL ES, a standard way for software to talk to a GPU.
- GPU: graphics processing unit, the chip that specialises in drawing.
- Hairline: a line too thin to have a real width, drawn as a special case.
- Hexadecimal: a base-16 way of writing numbers, common in programming; 0xf0f4 equals 61,684.
- Integer overflow: when a number grows past the largest value its fixed-size storage can hold and wraps around to a small or negative value.
int: a common fixed-size whole-number type, typically 32-bit signed, holding roughly minus two billion to plus two billion.- Out-of-bounds write (OOB): writing data past the end of the memory that was reserved, into memory that belongs to something else.
- Patch: a small modification to source code, applied before building.
- Path: a shape described as a sequence of points and curves.
- Pointer: a value that records where in memory something is stored.
- Proof of concept (poc): a concrete input or program that demonstrates a bug.
- Quad: a small four-sided shape produced when Skia breaks a path into simpler geometry.
- Recon: exploratory reading of code to find interesting places before attempting an attack.
- Sanitizer: a debugging tool built into a program that reports certain kinds of mistakes while it runs.
- Script: a small program that automates a task.
- Skia: the 2D graphics library Chrome uses to draw.
.skp: a Skia recording of drawing commands that can be replayed later.skpbench: a Skia benchmarking tool that replays.skpfiles.- UBSan (UndefinedBehaviorSanitizer): a sanitizer that reports undefined behaviour such as signed integer overflow.
- Variant: a nearby piece of code that may contain the same kind of mistake.
- Vertex: a corner point of a shape; a vertex buffer is a list of such points.