Skip to content
Info disclosure Disclosed report Advanced CVE-2026-16386

WebGPU stencil-only writes mark depth initialized and leak stale depth data

The WebGPU texture initialisation tracker records only mip and layer ranges, not depth and stencil aspects, so a stencil-only write marks the whole mip/layer as initialised. A later depth-only read then skips the lazy clear and returns stale depth data from a previously destroyed texture to JavaScript.

hajim Follow

Originally disclosed on Mozilla

  • Fixed in 19 days
  • Paid in 53 days
  • Disclosed after 19 days

Created attachment 9589157 webgpu-depth-stencil-aspect-init-bypass-poc.html

WebGPU stencil-only writes mark depth initialized and leak stale depth data

Summary

For depth32float-stencil8 textures, the WebGPU texture initialization tracker tracks only mip/layer state and does not distinguish the depth and stencil aspects. A full-layer stencil-only write can mark the corresponding mip/layer as initialized, which also makes the depth aspect appear initialized. A later depth-only read then skips lazy clearing and returns stale depth allocation data.

PoC: webgpu-depth-stencil-aspect-init-bypass-poc.html

Affected Code

Text
third_party/rust/wgpu-core/src/init_tracker/texture.rs
  TextureInitRange

third_party/rust/wgpu-core/src/device/queue.rs
  queue_write_texture()

third_party/rust/wgpu-core/src/command/transfer.rs
  handle_texture_init()
  copyBufferToTexture
  copyTextureToBuffer

Root Cause

TextureInitRange records only mip and array-layer ranges:

Text
pub(crate) struct TextureInitRange {
    pub(crate) mip_range: Range<u32>,
    pub(crate) layer_range: Range<u32>,
}

It does not record texture aspects. For depth/stencil formats, a full-layer stencil-only write drains the initialization range for the mip/layer and therefore also makes the depth aspect look initialized.

Later, copyTextureToBuffer({ aspect: "depth-only" }) asks whether the mip/layer is initialized. The tracker answers yes, so no lazy clear is emitted and Vulkan copies stale depth bytes into a mappable buffer.

Reachable Path

Text
JS creates an old depth32float-stencil8 texture
  -> render pass clears depth to a recognizable float value
  -> destroys the old texture

JS creates a new depth32float-stencil8 texture
  -> queue.writeTexture(... aspect="stencil-only", full layer)
  -> init tracker marks the mip/layer initialized

JS reads the depth-only aspect
  -> copyTextureToBuffer(... aspect="depth-only")
  -> init tracker skips clear
  -> stale depth bytes enter a MAP_READ buffer

Trigger Conditions

Text
1. The adapter supports depth32float-stencil8.
2. The texture format is depth32float-stencil8.
3. A full mip/layer stencil-only write is performed.
4. The depth aspect has not been initialized.
5. The allocation reuses old depth texture contents.
6. A later depth-only copy or shader read observes the depth aspect.

Dynamic Validation / Log Summary

Environment:

Text
Firefox ASAN no-UBSan
Backend: Vulkan
OS: Linux

Key result:

Text
control, no stencil-only write:
  depth copy is lazily cleared
  staleDepthHits=0
  readback depth values are zero

stencil-only full-layer write:
  validation=ok
  internal=ok
  map=resolved
  depth-only readback contains the stale depth clear value from the old texture

copyBufferToTexture stencil-only variant:
  same result as queue.writeTexture stencil-only

shader read variant:
  texture_depth_2d binding reads the stale depth value
  and writes it into a readable output buffer

device.lost=[]
uncaptured=[]

Cross-device boundary check:

Text
device A seeds and destroys a depth/stencil texture
device B creates a new texture and attempts the depth leak
result: stale sentinel not observed

Exploitability

Text
bug:
  yes. Texture init state is tracked at mip/layer granularity, but the real resource has aspect granularity.

crash:
  no.

exploit primitive:
  yes. Stale depth texture data can be returned to JavaScript.

real exploitable vulnerability:
  yes, a same-GPUDevice information disclosure on Linux/Vulkan.

The current evidence proves same-device stale depth disclosure. Cross-device and cross-origin leakage have not been proven.

Patch Analysis / Fix Guidance

Recommended fixes:

Text
1. Make depth/stencil texture initialization tracking aspect-aware.
2. Or treat single-aspect writes to depth/stencil formats as partial coverage that cannot initialize the other aspect.
3. Keep queue.writeTexture and commandEncoder.copyBufferToTexture behavior consistent.
4. Add a regression test:
   stencil-only full write -> depth-only read must return zero or a validation error.

Fixing only queue.writeTexture is insufficient; copyBufferToTexture reaches the same root cause.

The original report as published on Mozilla's Bugzilla, by hajim. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

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

The initialisation tracker keys state on mip and layer ranges only, ignoring the depth/stencil aspect, so a single-aspect write drains the range for both aspects.

Impact

A same-GPUDevice information disclosure on Linux/Vulkan; cross-device and cross-origin leakage were not proven.

What the attacker needed

Adapter supports depth32float-stencil8; same GPUDevice; Linux/Vulkan backend

The fix

Initialisation tracking should be aspect-aware, or single-aspect writes to depth/stencil formats should be treated as partial coverage that cannot initialise the other aspect, with a regression test added.

How it was found

  1. Create a depth32float-stencil8 texture and clear its depth to a recognisable value in a render pass.
  2. Destroy that texture.
  3. Create a new depth32float-stencil8 texture and write only the stencil aspect for the full layer.
  4. Copy the depth-only aspect into a mappable buffer and read it back.
  5. Observe stale depth values from the destroyed texture instead of zeros.

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.

Graphics textures can hold two separate parts, depth and stencil, in one allocation. The browser tracks whether each part has been written so it can wipe unwritten memory before you read it. Here the tracker treated the two parts as one, so writing only stencil made the depth part look safe to read, and old data from a destroyed texture came back.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by hajim

View all

7 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.