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

Out of bounds write in Skia (CVE-2026-7923)

A logic flaw in Skia's SkSL Raster Pipeline builder allows a peephole optimisation to incorrectly process multi-slot instructions during a partial stack discard, leading to a negative temporary stack depth. An attacker could then write attacker-controlled uniform data out-of-bounds, potentially achieving RCE in the GPU or Utility process.

Google Chrome

Originally disclosed on Chrome VRP

  • Fix shipped in 30 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 flaw in the SkSL Raster Pipeline builder allows a peephole optimization to incorrectly process multi-slot instructions during a partial stack discard. This results in a negative temporary stack depth, causing the stack pointer to walk backwards out-of-bounds. Subsequent instructions can then write attacker-controlled uniform data into adjacent memory, potentially leading to RCE in the GPU or Utility process.

Affected files:

  • third_party/skia/src/sksl/codegen/SkSLRasterPipelineBuilder.cpp

Estimated timestamp from git blame: 2023-06-28

The Vulnerability

In third_party/skia/src/sksl/codegen/SkSLRasterPipelineBuilder.cpp, the Builder::discard_stack(int32_t count) method attempts to optimize away unnecessary stack operations. When count == 1, it checks for a specific sequence (push, immediate-op, unmasked copy) by calling simplifyImmediateUnmaskedOp().

However, simplifyImmediateUnmaskedOp() contains a logic bug: it fails to verify that the count of slots being discarded matches the size of the multi-slot immediate operation it is optimizing. It only checks if immInstruction->fImmA == popInstruction->fImmA.

The Trigger

This can be triggered by an identity swizzle on a vectorized intrinsic that uses an immediate operation, such as float4 v; (v = abs(v)).xyz;.

  1. v = abs(v) evaluates to a sequence ending with push_slots (4 slots), bitwise_and_imm_int (4 slots), and copy_stack_to_slots_unmasked (4 slots).
  2. The .xyz swizzle requires discarding 1 tail element, calling discard_stack(1).
  3. simplifyImmediateUnmaskedOp() matches the 4-slot sequence. Because it ignores the count == 1 parameter, it erroneously proceeds: it subtracts 4 from the push_slots count (making it 0) and pops the copy_stack_to_slots_unmasked instruction off the list. It returns true, and discard_stack(1) returns early without emitting any instruction.
  4. The CodeGenerator must then discard the remaining 3 slots of the expression statement via discardExpression(3), calling discard_stack(3).
  5. Because the previous instructions were modified, the optimization no longer matches, and a raw discard_stack instruction with fImmA = 3 is appended to the stream.

This results in a net stack usage of -3 slots (0 slots pushed, 3 slots discarded).

Out-of-Bounds Write

By repeating this statement, an attacker can accumulate an arbitrarily large negative stack depth. During pipeline compilation (Program::makeStages):

  1. Assertions protecting stack depth (SkASSERTF(current[stackID] >= 0)) and pointer boundaries (SkASSERT(tempStackPtr >= slots.stack.data())) are compiled out in production Release builds.
  2. stack_usage() returns negative values for the mismatched discard_stack operations, causing tempStackPtr to linearly walk backwards, out of its designated memory slab and into adjacent memory allocated within the same SkArenaAlloc.
  3. The attacker can follow the underflow with an operation that writes to the stack using raw pointers, such as reading an attacker-controlled uniform variable (v = my_uniform;).
  4. The push_uniform instruction initializes a UniformCtx stage. Crucially, it populates ctx->dst by casting the out-of-bounds tempStackPtr directly to a raw float*.
  5. During pipeline execution, copy_uniforms writes the attacker's uniform data to this raw pointer, bypassing the 32-bit SkRPOffset safety mechanism used by other pipeline instructions.

Impact

The SkArenaAlloc slab often houses critical objects prior to the SkSL stack allocation, including MatrixRec data, uniform arrays, and instances of SkRasterPipelineBlitter (which contain vtables). By carefully crafting the stack underflow depth and the uniform payload, an attacker could overwrite these objects, hijack execution flow, and achieve arbitrary Remote Code Execution (RCE) and a Sandbox Escape from a compromised Renderer to the GPU Process or Utility Process.

Proposed Fix

In third_party/skia/src/sksl/codegen/SkSLRasterPipelineBuilder.cpp, simplifyImmediateUnmaskedOp must be updated to verify that the count passed to discard_stack exactly matches the slot count of the immediate operation. Alternatively, discard_stack should simply pass count as an argument to simplifyImmediateUnmaskedOp() to ensure validation.

C++
bool Builder::simplifyImmediateUnmaskedOp(int count) {
    // ...
    if (immInstruction->fImmA == popInstruction->fImmA && immInstruction->fImmA == count) {
        // ...

Evaluated with Chrome root at commit: f200f57a19490707ff8bc7aa5de3cbc443a3afad


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.

The original report as published on the Chromium issue tracker. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

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 peephole optimisation function simplifyImmediateUnmaskedOp does not check that the number of slots being discarded matches the size of the multi-slot immediate operation it is optimising.

Impact

An attacker could overwrite critical objects in the SkArenaAlloc slab, hijack execution flow, and achieve arbitrary Remote Code Execution and a Sandbox Escape from a compromised Renderer to the GPU Process or Utility Process.

What the attacker needed

Ability to supply a crafted shader; Chrome Release build (assertions disabled)

The fix

The simplifyImmediateUnmaskedOp function should be updated to verify that the count passed to discard_stack exactly matches the slot count of the immediate operation, or discard_stack should pass count as an argument to simplifyImmediateUnmaskedOp.

How it was found

  1. Write a shader statement that applies an identity swizzle to a vectorised intrinsic using an immediate operation, such as float4 v; (v = abs(v)).xyz;.
  2. The swizzle triggers discard_stack(1), which incorrectly matches a 4-slot sequence and modifies the instruction stream.
  3. The code generator then discards the remaining 3 slots, appending a raw discard_stack instruction with fImmA = 3.
  4. Repeat the statement to accumulate an arbitrarily large negative stack depth.
  5. Follow the underflow with an operation that writes to the stack using raw pointers, such as reading an attacker-controlled uniform variable.
  6. During pipeline execution, copy_uniforms writes the attacker's uniform data to the out-of-bounds pointer.

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 bug in how it builds shader programs lets a crafted shader make the program's internal stack pointer go below zero. Later instructions then write data outside the intended memory area, which could let an attacker run their own code.

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.

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.