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

WebGPU resolveQuerySet of unwritten queries leaks stale GPU buffer data

WebGPU's resolveQuerySet marks the destination buffer as initialised even when the query slots being resolved were never written, and on the Vulkan backend those bytes are left untouched. JavaScript can then copy the destination into a readable buffer and map it to read stale GPU memory contents.

hajim Follow

Originally disclosed on Mozilla

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

Created attachment 9589154 webgpu-resolvequeryset-unwritten-query-poc.html

WebGPU resolveQuerySet of unwritten queries leaks stale GPU buffer data

Summary

GPUCommandEncoder.resolveQuerySet() marks the destination buffer range as initialized even when resolving query slots that have never been written. On Linux/Vulkan, the backend does not write bytes for unwritten query slots, so JavaScript can copy the destination into a MAP_READ buffer and read stale allocation contents.

PoC: webgpu-resolvequeryset-unwritten-query-poc.html

Affected Code

Text
third_party/rust/wgpu-core/src/command/query.rs
  resolve_query_set()

Root Cause

resolve_query_set() contains an explicit TODO indicating that query initialization state is not tracked:

Text
TODO: Need to track initialization state.

The code then unconditionally marks the resolve destination range as initialized:

Text
dst_buffer.initialization_status.read().create_action(
    &dst_buffer,
    buffer_start_offset..buffer_end_offset,
    MemoryInitKind::ImplicitlyInitialized,
)

This assumes that copy_query_results() overwrites all destination bytes. Vulkan does not overwrite bytes for query slots that have never been written, so old allocation data is exposed as initialized data.

Reachable Path

Text
JS creates a QuerySet but never writes a query slot
  -> encoder.resolveQuerySet(querySet, 0, count, dst, 0)
  -> wgpu-core marks dst range as ImplicitlyInitialized
  -> Vulkan does not write bytes for unwritten slots
  -> encoder.copyBufferToBuffer(dst, mapReadBuffer)
  -> mapAsync exposes stale bytes

Trigger Conditions

Text
1. The destination buffer allocation reuses old GPU buffer contents.
2. The target QuerySet slots have never been written.
3. resolveQuerySet is called over those unwritten slots.
4. The backend does not write zeroes for unwritten query slots.
5. The destination is copied into a MAP_READ buffer and mapped.

Dynamic Validation / Log Summary

Environment:

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

Minimal stale-allocation result:

Text
unwritten occlusion, prefill 0xa5:
  validation=ok
  internal=ok
  map=resolved
  bytes=[165,165,165,165,165,165,165,165]

unwritten timestamp, prefill 0xa5:
  validation=ok
  internal=ok
  map=resolved
  bytes=[165,165,165,165,165,165,165,165]

used-empty occlusion control, prefill 0xa5:
  validation=ok
  bytes=[0,0,0,0,0,0,0,0]

Large-range result:

Text
occlusion queryCount=1024:
  byteLength=8192
  seed=0xa7
  seedCount=8192/8192
  firstDiff=-1

timestamp queryCount=1024:
  byteLength=8192
  seed=0x4e
  seedCount=8192/8192
  firstDiff=-1

GPU-only source result:

Text
source:
  usage=STORAGE only
  sentinel written by a compute shader
  no MAP_READ/COPY_SRC/COPY_DST usage

timestamp resolve, queryCount=256:
  seed=0x44
  seedCount=2048/2048
  validation=ok
  internal=ok
  map=resolved

Cross-device boundary check:

Text
same GPUDevice baseline:
  8192-byte GPU-only STORAGE seed=0x44
  timestamp query resolve
  seedCount=7936/8192

device A live -> device B:
  seedCount=0/8192
  nonzeroCount=0/8192

device A destroyed -> device B:
  seedCount=0/8192
  nonzeroCount=0/8192

device A destroyed -> device B, 32768-byte pressure:
  seedCount=0/32768
  nonzeroCount=0/32768

Exploitability

Text
bug:
  yes. The init tracker state does not match the backend write behavior for unwritten queries.

crash:
  no.

exploit primitive:
  yes. Stale GPU buffer bytes can be returned to JavaScript.

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

The current evidence proves same-GPUDevice stale GPU memory disclosure. Cross-origin, cross-navigation, and cross-GPUDevice leakage have not been proven.

Patch Analysis / Fix Guidance

This should not be fixed only by JavaScript validation. The current unwritten-query resolve path is validation-clean, and used-empty queries should still resolve and write zeroes.

Recommended fixes:

Text
1. Track query availability / written state.
2. Explicitly zero destination bytes for unwritten/unavailable query slots.
3. Or initialize the destination range with NeedsInitializedMemory before backend query resolve.
4. Cover both occlusion and timestamp queries.
5. Correctly handle mixed written/unwritten ranges slot-by-slot.

Regression tests should prefill or groom the destination allocation with non-zero data, resolve unwritten occlusion/timestamp queries, and require zero output or a validation error rather than stale bytes.

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 resolve path assumes the backend overwrites every destination byte, but it never tracks which query slots were actually written, so unwritten slots leave stale allocation data that is still marked as initialised.

Impact

A page could read stale GPU buffer contents from the same GPUDevice on Linux/Vulkan; cross-origin, cross-navigation and cross-device leakage were not proven.

What the attacker needed

WebGPU available (Firefox, Vulkan, Linux); destination buffer reuses old GPU contents; query slots never written

The fix

The resolve path should track which query slots were written and explicitly zero unwritten slots, or mark the destination as needing initialisation before the backend resolve.

How it was found

  1. Create a QuerySet but never write any query slot.
  2. Call resolveQuerySet over the unwritten slots into a destination buffer.
  3. Copy the destination into a MAP_READ buffer.
  4. Map the buffer and read the returned bytes.

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 GPU buffer is a block of memory the browser hands to web pages for graphics or compute work. When memory is reused, old data can still sit inside it. Here the browser told itself the output was fully written when it was not, so a page could read leftover bytes from earlier GPU work that it should never see.

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.