WebGPU swap-chain textures bypass wgpu-core validation via create_texture_from_hal with content-controlled view_formats, enabling rgba32float views of bgra8unorm shared surfaces and GPU-process OOB read/write
Categories
(Core :: Graphics: WebGPU, defect, P1)
Tracking
()
People
(Reporter: tjr, Assigned: aleiserson)
References
Details
(5 keywords, Whiteboard: [adv-main155+r][adv-esr153.2+r])
Attachments
(9 files, 3 external files)
|
1.42 KB,
text/plain
|
Details | |
|
2.26 KB,
patch
|
Details | Diff | Splinter Review | |
|
2.08 KB,
patch
|
Details | Diff | Splinter Review | |
|
1.26 KB,
application/octet-stream
|
Details | |
|
144 bytes,
application/octet-stream
|
Details | |
|
7.98 KB,
application/octet-stream
|
Details | |
|
6.62 KB,
text/html
|
Details | |
|
2.60 KB,
application/octet-stream
|
Details | |
|
1.00 KB,
text/plain
|
Details |
WebGPU swap-chain shared-texture: content-controlled view_formats / usage bypass wgpu-core validation via create_texture_from_hal → format-reinterpreted GPU texture view → OOB read/write in the GPU process
Classification
- Attacker: compromised (or even unmodified) web content process (
web/webIsolated=<site>). - Victim: GPU process (
WebGPUParent/ wgpu server / driver). On configurations where the
compositor runs in the parent this executes in the parent, but per §4 of the threat-model
reference this is a GPU-class finding (PWebGPUis managed under the compositor bridge;
the server side runs where the compositor lives). - Severity: Content → GPU memory corruption + memory disclosure (moderate per the matrix;
high practical value because it is a controlled GPU-memory OOB write and an OOB read
primitive whose results are returned to attacker JS). - Platform gate: the vulnerable server logic is cross-platform, but the reachable backends
are#ifdef/cfg-gated:- macOS:
SharedTextureMacIOSurface+ Metal (cfg(target_os = "macos"),
create_texture_with_shared_texture_iosurface) — the primary target of this audit item; - Linux:
SharedTextureDMABuf+ Vulkan (cfg(target_os = "linux")) — same flaw; - Windows:
SharedTextureD3D11+ DX12 (cfg(target_os = "windows")) — same flaw.
This analysis host is Linux without any GPU/Vulkan ICD, so no WebGPU adapter exists at all
(requestAdapter()→ null; seeblockers.yaml); empirical in-browser reproduction was
impossible here. The core validation bypass was reproduced empirically against the exact
vendored wgpu-core of this tree (see “Micro-repro” below).
- macOS:
The bug
Where the descriptor comes from (attacker-controlled metadata)
When a WebGPU canvas is configured, the content process sends
Message::CreateSwapChain (gfx/wgpu_bindings/src/lib.rs:301) carrying, among others:
texture_format: wgt::TextureFormatusage: wgt::TextureUsagesview_formats: Vec<wgt::TextureFormat>
These are populated verbatim from the JS GPUCanvasConfiguration:
CanvasContext::Configure(dom/webgpu/CanvasContext.cpp:90) validates onlyformat
(rgba8unorm/bgra8unorm). It performs no validation ofviewFormats(the WebGPU spec
requires each view format to be texture-view-format-compatible withformat, i.e. only the
srgb variant — Firefox never checks this anywhere on this path).Device::SwapChainTextureDescriptor(dom/webgpu/Device.cpp:109) copies
aConfig.mViewFormatsandaConfig.mUsageinto the descriptor.Device::InitSwapChain(dom/webgpu/Device.cpp:1008) forwards them to
wgpu_client_create_swap_chain(gfx/wgpu_bindings/src/client.rs:904), which puts them into
the IPC message unchanged.
In the GPU process, Message::CreateSwapChain handling (server.rs:3111) stores them in the
canonical SwapChainConfig (server.rs:142). SwapChainConfig::to_texture_descriptor()
(server.rs:150) pins size/mip/sample/dimension (this was the bug-2050871 hardening) but
passes through format, usage and view_formats untouched.
Where validation is skipped (the twin-path flaw)
DeviceAction::CreateTexture with a swap_chain_id (server.rs:2080) replaces the client desc
with the canonical one, then — because the swap chain uses shared textures
(default on macOS/Windows/Linux-dmabuf; dom.webgpu.allow-present-without-readback defaults to
true on those platforms) — calls the platform path, e.g. macOS
create_texture_with_shared_texture_iosurface (server.rs:3670):
WebGPUParent::EnsureSharedTextureForSwapChaincreates the IOSurface via
SharedTexture::Create→SharedTextureMacIOSurface::Create
(dom/webgpu/SharedTexture.cpp:39,dom/webgpu/SharedTextureMacIOSurface.cpp:15) —
BGRA,width×height, 4 bytes/texel.- A Metal texture wrapping the IOSurface is created with hardcoded
MTLPixelFormat::BGRA8Unorm,Type2D, usageRenderTarget|ShaderRead|PixelFormatView
(server.rs:3722-3737). - The wgpu-core texture is registered via the unsafe, validation-free
Global::create_texture_from_hal(server.rs:3769,
wgpu-core/src/device/resource.rs:1407) with the attacker'susageandview_formats
in the descriptor.
create_texture_from_hal(_inner) performs none of device_create_texture's checks. In
particular it skips the view-format compatibility check
(wgpu-core/src/device/resource.rs:1852-1861):
if desc.format.remove_srgb_suffix() != format.remove_srgb_suffix() {
return Err(CreateTextureError::InvalidViewFormat(*format, desc.format));
}
Its safety contract — “hal_texture must be created respecting desc” — is violated: the hal
texture is a fixed BGRA8 (4 B/px) 2D surface, while desc.view_formats may say
[Rgba32Float] (16 B/px) and desc.usage may claim capabilities the Metal/Vulkan object was
not created with.
Where the poisoned descriptor is consumed
Global::texture_create_view (wgpu-core/src/device/resource.rs:2124-2139) trusts the
descriptor:
let format_is_good = resolved_format == texture.desc.format
|| texture.desc.view_formats.contains(&resolved_format);
So content sends TextureAction::CreateView(view_id, { format: Some(Rgba32Float) }) (plain JS:
getCurrentTexture().createView({format:'rgba32float'}) — there is no client/DOM-side
validation either, dom/webgpu/Texture.cpp:49, client.rs:1089) and wgpu-core accepts it and
calls wgpu-hal:
- Metal (
wgpu-hal/src/metal/device.rs:616):
newTextureViewWithPixelFormat:RGBA32Float ...on the BGRA8Unorm IOSurface texture. Metal
requires view formats to be per-texel-size compatible; violating this without the (disabled in
release) validation layer is undefined behavior — the returned view addresses
width×height×16bytes over awidth×height×4-byte IOSurface. (If Metal returns nil the
.unwrap()panics = GPU-process abort, still a content-triggered DoS.) - Vulkan (
wgpu-hal/src/vulkan/device.rs:1258):vkCreateImageViewwith
VK_FORMAT_R32G32B32A32_SFLOATon aB8G8R8A8_UNORMimage created without
VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT(dmabuf import atserver.rs:1903uses only
ALIAS) — violates VUID-VkImageViewCreateInfo-image-01019/01762 → UB; drivers create the
view and address per the view format's texel size → OOB. - DX12: SRV/RTV with a format outside the resource's cast family → UB, same shape.
Primitives
With the rgba32float view of the 4-B/px swap-chain surface:
- OOB write: render pass (view as color attachment) or clear — GPU writes
W*H*16bytes into aW*H*4allocation with attacker-chosen 128-bit fill; ~75 % of the
writes land beyond the IOSurface/VkImage allocation, corrupting adjacent GPU-accessible
memory of the GPU process (other surfaces, heaps). - OOB read + exfiltration: bind the view (
sampleType:'unfilterable-float') and
textureLoadevery texel into a storage buffer, copy to aMAP_READbuffer,mapAsync,
read in JS → discloses memory beyond the surface (other tabs' surface contents, GPU heap
data) to web content.
Secondary variant (same root cause): the attacker-controlled usage is also installed without
validation, so wgpu-core lets content use the swap-chain texture in ways the underlying
Metal texture (RenderTarget|ShaderRead|PixelFormatView, no ShaderWrite) / VkImage
(only COLOR_ATTACHMENT) was never created for (e.g. STORAGE_BINDING writes,
COPY_DST blits) — further API-contract UB.
Note this is exactly the “same check present in one path but missing in its twin” +
“descriptor trusted over the mapping” patterns: device_create_texture validates,
create_texture_from_hal (used only for shared swap-chain textures — the very surface of
this audit item) does not.
Reachability
- Requires: WebGPU enabled (
dom.webgpu.enabled; default in release on Windows, Nightly on
macOS/Linux), a hardware adapter, and the shared-texture swap chain
(dom.webgpu.allow-present-without-readback— default true on Win/macOS/Linux;
support_use_shared_texture_in_swap_chain— true on macOS Metal hardware, Windows DX12
hardware, Linux Vulkan with dmabuf extensions). - No compromised renderer is strictly required:
viewFormatsflows from plain JS with no
validation at any layer (checked:CanvasContext::Configure,Device::InitSwapChain,
wgpu_client_create_swap_chain,Message::CreateSwapChainhandler,to_texture_descriptor,
create_texture_from_hal,texture_create_view). The includedexploit.patchadditionally
injects the poisoned view format from a (modeled) compromised content process at the client
FFI boundary,XRE_IsContentProcess()-guarded, to keep the PoC working even if DOM-side
spec validation is added later.
Why not reproduced empirically here
- Primary backend is macOS-only (
#ifdef XP_MACOSX,cfg(target_os="macos"),
dom/webgpu/SharedTextureMacIOSurface.cpp); this host is Linux. - The Linux sibling (
SharedTextureDMABuf+ Vulkan) has the same flaw, but this host has no
GPU, no /dev/dri, no Vulkan ICD (not even lavapipe) and
server.rshardcodesBackends::PRIMARY, sorequestAdapter()returns null and no
WebGPU path can execute (verified again with browser_evaluator in this session:
[PoC] no WebGPU adapter on this machine). Recorded inblockers.yaml.
Micro-repro (executed here, against this tree's vendored wgpu-core)
micro_repro/ builds a small Rust program (cargo build --offline, vendored deps from
/firefox/third_party/rust) that uses wgpu-core's noop hal backend in place of Metal/Vulkan
and performs exactly the calls Firefox's GPU process performs:
[1] device_create_texture (validated path) REJECTS the descriptor:
The view format Rgba32Float is not compatible with texture format Bgra8Unorm, only changing srgb-ness is allowed.
[2] create_texture_from_hal (swap-chain path) ACCEPTS the same descriptor: validation BYPASSED
[3] texture_create_view(format=Rgba32Float) on the Bgra8Unorm swap-chain texture SUCCEEDS.
=> wgpu-hal now holds a 16-byte/texel view of a 4-byte/texel surface.
[4] Control: same view on a texture without poisoned view_formats is rejected as expected:
Trying to create a view of format Rgba32Float of a texture with format Bgra8Unorm, but this view format is not present in the texture's viewFormat array
This proves, on this exact code revision, that the incompatible-format view object is created
and handed to wgpu-hal; on real backends that call is
newTextureViewWithPixelFormat:/vkCreateImageView on the shared swap-chain surface.
Reproduction on the target OS (macOS)
- Nightly/ASAN build of this tree on macOS (Metal hardware; defaults suffice:
dom.webgpu.enabled=trueon Nightly,dom.webgpu.allow-present-without-readback=true). - Optionally
git apply exploit.patch(not required today; see above) and rebuild. - Load
testcase.html. - Expected observations, in order of likelihood:
- GPU-process crash (Metal/driver fault or GPU command-buffer error → device loss) during
the clear/dispatch on the oversized view; under ASAN/GuardMalloc, an OOB write report if
the IOSurface mapping is CPU-shadowed; - or the page logs non-zero “OOB words” — memory disclosed from beyond the 256 KiB
IOSurface into JS (checkfirst OOB wordsline); - if Metal returns nil for the incompatible view: Rust panic
called Option::unwrap() on a None valuein
wgpu-hal/src/metal/device.rs:678(create_texture_view) — GPU-process abort, proving
the incompatible view request reached the driver.
- GPU-process crash (Metal/driver fault or GPU command-buffer error → device loss) during
- Linux variant: any Vulkan-capable machine with dmabuf (
GBM_FORMAT_ARGB8888modifiers);
same testcase; thevkCreateImageViewUB typically yields RADV/ANV OOB addressing.
Suggested fix
- Run full descriptor validation for swap-chain textures: either call the same checks as
device_create_texturebeforecreate_texture_from_hal, or sanitize
SwapChainConfig::view_formats(allow only the srgb variant offormat) andusage
(mask to what the hal texture was actually created with) in the
Message::CreateSwapChainhandler — server-side, since the values are content-controlled. - Additionally validate
GPUCanvasConfiguration.viewFormatsinCanvasContext::Configure
per spec (defense in depth; returns proper TypeError to JS).
Files
testcase.html— plain-JS PoC (configure poisoned viewFormats → rgba32float view →
OOB-write render pass + OOB-read compute/textureLoad exfiltration).exploit.patch— compromised-content-process variant (guarded by
XRE_IsContentProcess()), injects the poisoned view format in
Device::InitSwapChain; verified to compile against this tree (ASAN build).micro_repro/Cargo.toml,micro_repro/src/main.rs,micro_repro/cargo-config.toml—
the executed validation-bypass proof against the vendored wgpu-core.
| Reporter | ||
Comment 1•3 months ago
|
||
| Reporter | ||
Comment 2•3 months ago
|
||
| Reporter | ||
Comment 3•3 months ago
|
||
| Reporter | ||
Comment 4•3 months ago
|
||
| Reporter | ||
Comment 5•3 months ago
|
||
| Reporter | ||
Comment 6•3 months ago
|
||
| Reporter | ||
Comment 7•3 months ago
|
||
| Reporter | ||
Comment 8•3 months ago
|
||
| Reporter | ||
Comment 9•3 months ago
|
||
| Reporter | ||
Comment 10•3 months ago
|
||
This bug was filed automatically by an AI-powered security testing tool. The analysis, testcase, and any suggested patches were generated by an AI model and have NOT been verified by a human.
Please review all details carefully before triaging. The issue was confirmed by an independent verifier, but for non-ASAN issues, the verifier has been made less strict. Additionally, the root cause analysis and suggested fix may contain errors.
| Reporter | ||
Updated•3 months ago
|
Updated•3 months ago
|
| Assignee | ||
Updated•3 months ago
|
| Assignee | ||
Updated•3 months ago
|
| Assignee | ||
Comment 12•3 months ago
|
||
Needs https://github.com/gfx-rs/wgpu/commit/d5d8ed84c88f553c5d5eed35e3033f18b9f6bc6b (2026-08-03), plus an additional Firefox change.
Updated•3 months ago
|
| Assignee | ||
Comment 13•3 months ago
|
||
Comment 14•3 months ago
|
||
:aleiserson, please update all release status flags to reflect the affected/unaffected/disabled state correctly. Which branches (beta, release, and/or ESR) are affected by this flaw?
| Assignee | ||
Updated•3 months ago
|
Comment 15•3 months ago
|
||
Comment 16•3 months ago
|
||
Comment 17•3 months ago
|
||
The patch landed in nightly and beta is affected, along with ESR.
:aleiserson, is this bug important enough to require an uplift?
- If yes, please nominate the patch for beta and ESR approvals.
- See https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift for documentation on how to request an uplift.
- If no, please set
status-firefox155and the ESR status flag(s) towontfix.
For more information, please visit BugBot documentation.
Updated•3 months ago
|
Comment 18•3 months ago
|
||
firefox-beta Uplift Approval Request
- User impact if declined/Reason for urgency: Security fix
- Code covered by automated testing?: no
- Fix verified in Nightly?: yes
- Needs manual QE testing?: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: Adds validation to protect against a compromised content process, should not affect normal cases.
- String changes made/needed?: n/a
- Is Android affected?: no
| Assignee | ||
Comment 19•3 months ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D318640
| Assignee | ||
Comment 20•3 months ago
|
||
Requested beta uplift. ESR153 uplift is needed as well, but a wgpu revendor (bug 2064236) is required first.
Updated•3 months ago
|
Updated•3 months ago
|
Comment 21•3 months ago
|
||
| uplift | ||
Updated•3 months ago
|
| Assignee | ||
Comment 22•2 months ago
|
||
This still requires an esr153 uplift of the Firefox-side change, but it's tied up with CTS expectation updates and bug 2059599. I am working on it.
| Assignee | ||
Comment 23•2 months ago
|
||
Updated•2 months ago
|
Comment 24•2 months ago
|
||
firefox-esr153 Uplift Approval Request
- User impact if declined/Reason for urgency: Security fix
- Code covered by automated testing?: no
- Fix verified in Nightly?: yes
- Needs manual QE testing?: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: Adds validation to protect against a compromised content process, should not affect normal cases.
- String changes made/needed?: n/a
- Is Android affected?: no
| Assignee | ||
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Comment 25•2 months ago
|
||
| uplift | ||
Updated•2 months ago
|
Updated•5 days ago
|
Description
•