GPURenderBundle externalTexture lifetime tracking bypass causes GPU-process use-after-free
Firefox WebGPU tracked external texture lifetime for direct render passes but not for textures captured inside a render bundle, so a page could expire the video source before executing the bundle. The stale Metal texture then reached the GPU process and caused a use-after-free crash in objc_retain during texture binding.
- Fixed in 16 days
- Paid in 34 days
- Disclosed after 16 days
Created attachment 9586359 FX-AUDIT-2026-0012-self-contained-submission.zip
Title
[Graphics/WebGPU] Security vulnerability in Firefox: GPURenderBundle externalTexture lifetime tracking bypass causes GPU-process use-after-free
Product / Component
Firefox / Graphics: WebGPU (dom/webgpu, gfx/wgpu_bindings, third_party/rust/wgpu-core, Metal backend)
Affected Versions
Tested on Firefox Nightly 152.0a1.
- Source revision:
cf6415620d92de30e1e1a413ef98b58684eb160e - Build ID:
20260514203623 - ASAN binary:
obj-asan/dist/NightlyDebug.app/Contents/MacOS/firefox
Also tested on:
- Earlier local ASAN Nightly build
BuildID=20260513010200, where the same bug was reproducible. - A release build was used only as an additional behavioral check for GPU/device-loss behavior; the primary security evidence is from the ASAN build above.
Environment
- OS: macOS 26.4.1, Darwin 25.4.0, arm64
- Hardware/backend: Apple M4, WebGPU Metal backend
- Build type: local Firefox Nightly ASAN debug/optimized build
- ASAN/Debug/Release: ASAN + debug,
--enable-address-sanitizer,--enable-debug,--enable-optimize=-O1,--disable-jemalloc - Relevant prefs used by the testcase:
dom.webgpu.enabled=truedom.webgpu.external-texture.enabled=truedom.webgpu.allow-present-without-readback=truegfx.webgpu.ignore-blocklist=truedom.webgpu.wgpu-backend="metal"media.autoplay.default=0
Summary
Firefox WebGPU tracks GPUExternalTexture lifetime for direct render passes, but the same lifetime dependency is lost when the external texture is first captured inside a GPURenderBundle.
A web page can import an external texture from a video source, bind it in a render bundle, finish the bundle, then tear down the video/external texture source before executing the bundle in a later render pass. The direct render-pass path correctly rejects the stale external texture with External texture is expired. The render-bundle path bypasses this validation and reaches the Metal backend with a stale texture object, causing a GPU-process use-after-free in objc_retain while wgpu_hal::metal::command::Encoder::set_texture binds the texture.
This is a remotely reachable WebGPU memory-safety issue from web content when WebGPU/external texture are enabled.
Steps To Reproduce
- Build Firefox with ASAN enabled.
- Start Firefox with the WebGPU prefs listed above.
- Save the attached PoC file as
webgpu_renderbundle_externaltexture_lifetime.htmland serve it over HTTP from any local directory. - Open the PoC with the query parameter
mode=bundle, for example:
http://127.0.0.1:8000/webgpu_renderbundle_externaltexture_lifetime.html?mode=bundle&source=video&loop=1&batch=1&readbackEvery=0&deferSubmitMs=100&teardownVideo=1&close=0&beacon=1
- For the direct-path control, open the same PoC with
mode=direct:
http://127.0.0.1:8000/webgpu_renderbundle_externaltexture_lifetime.html?mode=direct&source=video&loop=1&batch=1&readbackEvery=0&deferSubmitMs=100&teardownVideo=1&close=0&beacon=1
Expected Result
Firefox should apply the same GPUExternalTexture lifetime validation to render bundles and direct render passes. If an external texture source has expired before submit, both paths should reject the command with a WebGPU validation error and should not pass stale backend texture objects to Metal/wgpu.
Actual Result
The direct render-pass path reports the expected WebGPU validation error:
RESULT=EXPIRED_VALIDATION
JavaScript warning: Uncaptured WebGPU error: External texture is expired
The render-bundle path bypasses the expired-external-texture validation and crashes in the GPU process:
RESULT=ASAN_BUS
SUMMARY: AddressSanitizer: BUS (/usr/lib/libobjc.A.dylib:arm64+0x791c) in objc_retain+0x10
Crash / ASAN / Sanitizer Output
Short top stack from the latest ASAN build:
AddressSanitizer:DEADLYSIGNAL
==51263==ERROR: AddressSanitizer: BUS on unknown address
==51263==The signal is caused by a READ memory access.
#0 objc_retain
#1 wgpu_hal::metal::command::Encoder::set_texture
#2 wgpu_hal::metal::command::<impl CommandEncoder>::update_bind_group_state
#3 wgpu_hal::metal::command::<impl CommandEncoder>::set_bind_group
#4 wgpu_core::command::bundle::RenderBundle::execute
#5 wgpu_core::command::render::encode_render_pass
#6 wgpu_core::command::CommandEncoder::finish
#7 wgpu_core::global::Global::command_encoder_finish
#8 wgpu_bindings::server::process_message
#9 wgpu_server_messages
#10 mozilla::webgpu::WebGPUParent::RecvMessages
#11 mozilla::webgpu::PWebGPUParent::OnMessageReceived
#12 mozilla::gfx::PCanvasManagerParent::OnMessageReceived
#13 mozilla::ipc::MessageChannel::DispatchAsyncMessage
Earlier NSZombie-assisted runs also showed the same object-lifetime failure more directly:
-[AGXG16GFamilyTexture retain]: message sent to deallocated instance
Root Cause Analysis
Affected files/functions:
dom/webgpu/RenderBundleEncoder.cppRenderBundleEncoder::SetBindGroupRenderBundleEncoder::Finish
dom/webgpu/RenderBundle.hRenderBundle
dom/webgpu/RenderPassEncoder.cppRenderPassEncoder::ExecuteBundlesRenderPassEncoder::End
dom/webgpu/CommandEncoder.cppCommandEncoder::EndRenderPassCommandEncoder::Finish
dom/webgpu/Queue.cppQueue::Submit
dom/webgpu/ExternalTexture.cppExternalTexture::MaybeDestroy- external texture source destruction path
gfx/wgpu_bindings/src/server.rs- external texture creation / backend resource binding
third_party/rust/wgpu-core/src/command/bundle.rsRenderBundle::execute
third_party/rust/wgpu-hal/src/metal/command.rs- Metal texture binding
Code path:
- A page imports a
GPUExternalTexturefrom a video source. - The page creates a bind group containing that external texture.
- The page records
setBindGroup()into aGPURenderBundleEncoder. RenderBundleEncoder::Finish()creates aRenderBundle.- The external texture source is torn down after bundle creation but before bundle execution/submission.
- The page executes the render bundle inside a later render pass.
- The command encoder is finished and sent to the WebGPU parent/GPU process.
- wgpu/Metal executes the bundle and attempts to bind the stale texture object.
Why the input reaches the vulnerable state:
Direct render passes retain enough external-texture metadata for CommandEncoder / CommandBuffer / Queue::Submit to detect that the external texture is expired. In that path, Queue::Submit rejects the command and reports External texture is expired.
The render-bundle path drops this dependency:
RenderBundleEncoder::SetBindGroup()records the bind group while encoding the bundle.RenderBundleEncoder::Finish()transfers only canvas-context usage into the resultingRenderBundle.RenderBundlestoresmUsedCanvasContexts, but does not store theExternalTextureobjects or their source ids.RenderPassEncoder::ExecuteBundles()merges only canvas-context dependencies from each bundle.RenderPassEncoder::End()collects external textures only from direct render-pass bind groups, not from bind groups captured inside executed bundles.CommandEncoder::EndRenderPass()andCommandEncoder::Finish()therefore create a command buffer without the bundle's external-texture lifetime dependency.Queue::Submit()only validates the external textures present in the command buffer metadata, so the bundle's stale external texture is not rejected.
As a result, the JavaScript-visible GPUExternalTexture source can expire while the backend bundle still contains a stale Metal texture binding. The stale object is later used by wgpu_core::command::bundle::RenderBundle::execute, reaching wgpu_hal::metal::command::Encoder::set_texture and crashing in objc_retain.
Security Impact
Potential impact:
- GPU-process use-after-free / use-after-destroy of a Metal texture object.
- Memory corruption reachable from web content through WebGPU render bundle commands.
- The crash occurs in the GPU/WebGPU parent-side execution path, not as a JavaScript exception in content.
Exploitability notes:
- The attacker controls the render bundle, shader/bind group layout, external texture lifetime timing, submit order, and additional GPU allocation pressure around the stale object.
- The direct path provides a strong control case: the same stale external texture is normally rejected, so the crash is caused by the render-bundle lifetime tracking gap.
- The ASAN stack and NSZombie output identify a freed Objective-C Metal texture object being retained during backend command execution.
Attacker requirements:
- Ability to run web content with WebGPU and external texture support enabled.
- No browser extension or privileged script is required.
- The observed testcase uses the Metal backend on macOS.
Attachments
webgpu_renderbundle_externaltexture_lifetime.html
Suggested Fix Direction
Render bundles should preserve the same external-texture lifetime dependencies as direct render passes.
Recommended fix direction:
- Store external texture dependencies, or source ids, in
RenderBundle. - Transfer external texture dependencies from
RenderBundleEncoder::Finish()into the producedRenderBundle. - Merge external texture dependencies from executed bundles in
RenderPassEncoder::ExecuteBundles()orRenderPassEncoder::End(). - Ensure
CommandEncoder::EndRenderPass()/CommandEncoder::Finish()include bundle-introduced external textures in the command buffer. - Keep
Queue::Submit()as the final validation point for both direct and bundle paths. - Add a regression test that records an external texture into a render bundle, expires the source, executes the bundle, and verifies that Firefox returns
External texture is expiredinstead of crashing.
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
Render bundles stored only canvas-context dependencies and not the external texture objects or source ids, so the command buffer built from a bundle lacked the lifetime dependency that Queue::Submit validates against.
Impact
A web page could trigger a GPU-process use-after-free of a Metal texture object, a memory-safety issue reachable from content without any extension or privileged script; the observed testcase used the Metal backend on macOS.
What the attacker needed
WebGPU and external texture enabled; Victim loads attacker web content; Metal backend (macOS observed)
The fix
Render bundles should carry external texture dependencies (or source ids) through Finish, ExecuteBundles and command buffer creation so Queue::Submit rejects expired textures on both paths; the text does not say a fix has landed.
How it was found
- Build Firefox with AddressSanitizer enabled and start it with the WebGPU and external texture preferences set.
- Serve the proof-of-concept page over local HTTP.
- Open the page in bundle mode so the external texture is recorded into a render bundle and the video source is torn down before submission.
- Observe the GPU-process crash in the sanitizer output, and compare with direct mode which reports the expired texture validation error.
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 web page can borrow a texture from a playing video and reuse it in drawing commands. Firefox normally checks that the video texture is still alive before running those commands, but when the commands were packed into a reusable bundle that check was skipped. The result was that the browser's graphics process tried to use a texture that had already been freed, which crashed it.
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.