WebGPU dynamic-offset bind group lazy initialization bypass leaks stale GPU buffer data
Firefox's WebGPU implementation failed to apply dynamic offsets when generating lazy buffer initialization actions, so a shader reading through a dynamic offset could see stale GPU buffer contents that were never cleared. An attacker could seed a GPU-only storage buffer, destroy it, allocate a new uninitialized buffer, and read leftover bytes back to JavaScript through a compute shader.
- Fixed in 19 days
- Paid in 46 days
- Disclosed after 19 days
Created attachment 9589153 webgpu-dynamic-offset-bindgroup-lazy-init-poc.html
WebGPU dynamic-offset bind group lazy initialization bypass leaks stale GPU buffer data
Summary
Firefox WebGPU does not apply dynamic offsets when generating lazy buffer initialization actions for hasDynamicOffset=true buffer bindings. The initialization tracker records the base range from createBindGroup(), but the shader-visible range is shifted later by setBindGroup(..., dynamicOffsets).
On Linux/Vulkan, a page can seed a GPU-only STORAGE buffer, destroy it, allocate a new uninitialized storage buffer, and read stale bytes from the dynamic-offset range through a compute shader.
PoC: webgpu-dynamic-offset-bindgroup-lazy-init-poc.html
Affected Code
third_party/rust/wgpu-core/src/device/resource.rs
Device::create_buffer_binding()
third_party/rust/wgpu-core/src/command/pass.rs
set_bind_group()
flush_bindings_helper()
third_party/rust/wgpu-core/src/command/bundle.rs
State::flush_bindings()
Root Cause
Device::create_buffer_binding() records only the base range from the bind group descriptor:
used_buffer_ranges.extend(buffer.initialization_status.read().create_action(
buffer,
bb.offset..bb.offset + visible_size,
MemoryInitKind::NeedsInitializedMemory,
));
For dynamic bindings, this range does not include the dynamic offset later supplied to setBindGroup().
At execution time, pass::set_bind_group() validates dynamic offset count, alignment, and bounds, but does not generate shifted initialization actions. flush_bindings_helper() replays the original base-range action and then passes the dynamic offset to the backend:
check_action(action) // still the base range, e.g. 0..4
raw_encoder.set_bind_group(..., dynamic_offsets) // actual shader range, e.g. 256..260
Therefore WebGPU clears buffer[0..4], while the shader reads buffer[256..260].
Reachable Path
JS createBindGroup(base offset=0, size=4, hasDynamicOffset=true)
-> wgpu-core records used_buffer_ranges = 0..4
JS pass.setBindGroup(0, bindGroup, [256])
-> dynamic offset validation passes
-> binder stores dynamic offset
dispatch
-> flush_bindings_helper() initializes only 0..4
-> backend binds the buffer with dynamic offset 256
-> shader reads stale bytes from 256..260
-> shader writes them into a MAP_READ-visible output buffer
Trigger Conditions
1. A bind group layout buffer entry uses hasDynamicOffset=true.
2. The bind group resource uses a small base range, such as offset=0, size=4.
3. setBindGroup uses a non-zero aligned dynamic offset, such as 256.
4. The dynamic-offset range has not been initialized by JavaScript.
5. The underlying allocation reuses old GPU buffer contents.
6. A shader reads the dynamic-offset range and copies it to a mappable output buffer.
Dynamic Validation / Log Summary
Environment:
Firefox ASAN no-UBSan
Backend: Vulkan
OS: Linux
Key result:
device limits:
minStorageBufferOffsetAlignment=256
minUniformBufferOffsetAlignment=256
static-offset0-control:
bindOffset=0
dynamic=false
seed=0x61
readbackBytes=[0,0,0,0]
static-offset-dynamic-target-control:
bindOffset=256
dynamic=false
seed=0x62
readbackBytes=[0,0,0,0]
dynamic-offset0-control:
bindOffset=0
dynamic=true
dynamicOffset=0
seed=0x63
readbackBytes=[0,0,0,0]
dynamic-offset-target:
bindOffset=0
dynamic=true
dynamicOffset=256
seed=0x64
readbackBytes=[100,100,100,100]
value=0x64646464
validation=ok
internal=ok
device.lost=[]
uncaptured=[]
The static bindOffset=256 control is important: the same target range is cleared correctly when it is expressed as a static binding range. The leak appears only when the range is reached through a dynamic offset.
Additional validation:
uniform dynamic offset:
dynamicOffset=256/512 both read stale sentinels
read-only-storage dynamic offset:
dynamicOffset=256/512 both read stale sentinels
RenderBundle:
dynamic uniform/storage bindings also leak
GPU-only source:
the old allocation can be STORAGE only, written by a compute shader,
without MAP_READ/COPY_SRC/COPY_DST usage.
Exploitability
bug:
yes. The lazy initialization range does not match the actual shader-visible range.
crash:
no.
exploit primitive:
yes. Shader-visible 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
Dynamic offsets are valid WebGPU input, so rejecting them is not the right fix. Lazy initialization must become dynamic-offset aware.
Recommended fixes:
1. When flushing bind groups in pass/bundle code, generate shifted BufferInitTrackerAction ranges:
range.start += dynamic_offset
range.end += dynamic_offset
2. Cover both uniform and storage buffer bindings.
3. Cover direct render/compute passes and RenderBundle replay.
4. Add regression tests:
static offset=256 -> read zero
dynamicOffset=256 -> also read zero
Incomplete fixes to avoid:
fixing uniform but not read-only-storage;
fixing direct passes but not RenderBundle;
expanding the base range at createBindGroup time without knowing future dynamic offsets.
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 buffer initialization tracker records only the base range from the bind group descriptor and never shifts it by the dynamic offset supplied later at setBindGroup time.
Impact
A page could read stale GPU buffer bytes left by earlier work on the same GPUDevice, but cross-origin, cross-navigation and cross-GPUDevice leakage were not proven.
What the attacker needed
Firefox with WebGPU on Linux/Vulkan; Page can run WebGPU compute shaders; Same GPUDevice as the stale data
The fix
Lazy initialization should be made dynamic-offset aware by shifting the recorded buffer initialization ranges by the dynamic offset when bind groups are flushed, covering uniform and storage bindings in both direct passes and RenderBundle replay.
How it was found
- Create a bind group layout entry with hasDynamicOffset=true and a bind group with a small base range such as offset 0, size 4.
- Seed a GPU-only storage buffer, then destroy it and allocate a new uninitialized storage buffer that reuses the old allocation.
- Call setBindGroup with a non-zero aligned dynamic offset such as 256.
- Dispatch a compute shader that reads the dynamic-offset range and writes it to a mappable output buffer.
- Map the output buffer and observe stale bytes from the old allocation.
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.
WebGPU lets web pages run code on the graphics card. Before a page reads a buffer, the browser is supposed to wipe it so no old data from another page or earlier work is visible. Here the browser wiped the wrong part of the buffer when a feature called a dynamic offset shifted where the shader actually looked, so old data could be read back.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.