Missing required_limits validation in WebGPU dma-buf device creation path allows compromised content process to cause OOB write in parent process [@ vk::Inputs::initialize]
Categories
(Core :: Graphics: WebGPU, defect, P1)
Tracking
()
People
(Reporter: bugmon, Assigned: aleiserson)
References
Details
(6 keywords)
Attachments
(9 files, 1 external file)
|
4.37 KB,
application/octet-stream
|
Details | |
|
1.27 KB,
text/html
|
Details | |
|
112 bytes,
application/json
|
Details | |
|
29 bytes,
text/plain
|
Details | |
|
2.02 KB,
patch
|
Details | Diff | Splinter Review | |
|
6.04 KB,
text/plain
|
Details | |
|
1.08 KB,
patch
|
Details | Diff | Splinter Review | |
|
2.90 KB,
text/plain
|
Details | |
|
10.81 KB,
text/plain
|
Details |
On Linux, when the Vulkan driver advertises the external-memory dma-buf extension set (VK_KHR_external_memory_fd, VK_EXT_external_memory_dma_buf, VK_EXT_image_drm_format_modifier, VK_KHR_external_semaphore_fd — the default for all shipping Mesa drivers: radv, anv, lavapipe), WebGPUParent's device creation in gfx/wgpu_bindings/src/server.rs takes a special branch that constructs the Vulkan device manually and registers it via wgpu-core's unsafe Global::create_device_from_hal. This branch passes the DeviceDescriptor::required_limits deserialized directly from the content process's PWebGPU RequestDevice message without ever validating them against the adapter's actual capabilities. The ordinary path (Global::adapter_request_device) performs this validation via check_limits() and rejects excessive limits with LimitsExceeded; create_device_from_hal instead documents an unsafe contract — "desc must be a subset of hal_device features and limits" — which the server.rs caller violates with attacker-controlled data.
A compromised content process can therefore forge required_limits (e.g. max_vertex_attributes = 2^28) and obtain a parent-side wgpu Device whose internal limits vastly exceed the hardware's. All subsequent wgpu-core validation is performed against these forged limits: a CreateRenderPipeline with a vertex attribute shaderLocation of 0x0FFFFFFF passes the check at wgpu-core/src/device/resource.rs:4833 (location < forged 2^28) and is forwarded to the system Vulkan driver, violating the Vulkan valid-usage requirement that location < VkPhysicalDeviceLimits::maxVertexInputAttributes (16 on the test driver). The result is an out-of-bounds WRITE inside the driver in the parent process at an offset directly scaled by the attacker-controlled location (fault address = heap base + location * 40 in SwiftShader's vk::Inputs::initialize), i.e. a largely attacker-controlled wild write usable as a sandbox-escape primitive. A control run with honest limits shows the identical pipeline is cleanly rejected ("Vertex attribute location 268435455 must be less than limit 16"), confirming the missing parent-side limits check is the root cause and that ordinary web content cannot reach the bug.
Build Info
- Branch: main
- Revision: ad248604ee7179fefa7fe5107281241792925253
- Timestamp: 2026-07-16T04:49:24+00:00
Affected Code
File: gfx/wgpu_bindings/src/server.rs, line 3009-3015
Message::RequestDevice {
adapter_id,
device_id,
queue_id,
desc, // <-- DeviceDescriptor (incl. required_limits) deserialized
} => { // from content-process IPC, fully attacker-controlled
let error = adapter_request_device(global, adapter_id, desc, device_id, queue_id);
File: gfx/wgpu_bindings/src/server.rs, line 504-614
#[cfg(target_os = "linux")]
{
let support_dma_buf = hal_adapter.as_ref().is_some_and(|hal_adapter| {
let capabilities = hal_adapter.physical_device_capabilities();
capabilities.supports_extension(khr::external_memory_fd::NAME)
&& capabilities.supports_extension(ash::ext::external_memory_dma_buf::NAME)
&& capabilities.supports_extension(ash::ext::image_drm_format_modifier::NAME)
&& capabilities.supports_extension(khr::external_semaphore_fd::NAME)
});
match (hal_adapter, support_dma_buf) {
...
(Some(hal_adapter), true) => {
...
let hal_device = match hal_adapter.device_from_raw(
raw_device,
None,
&enabled_extensions,
sanitized_desc.required_features,
&sanitized_desc.required_limits, // <-- forged limits, never checked
...
let res = global.create_device_from_hal( // <-- unsafe API; caller must
self_id, // guarantee limits <= adapter
hal_device.into(), // caps, but never checks
&sanitized_desc,
Some(new_device_id),
Some(new_queue_id),
);
File: third_party/rust/wgpu-core/src/instance.rs, line 1014-1024, 1098-1100
/// # Safety
///
/// - `hal_device` must be created from this adapter.
/// - `desc` must be a subset of `hal_device` features and limits. // <-- contract violated by server.rs
pub unsafe fn create_device_and_queue_from_hal(...) -> ... {
// NO check_limits() here
let device = Device::new(hal_device.device, self, desc, instance_flags)?;
...
}
// The ordinary path that the dma-buf branch bypasses DOES validate:
// (inside Adapter::request_device)
if let Some(failed) = check_limits(&desc.required_limits, &caps.limits).pop() {
return Err(RequestDeviceError::LimitsExceeded(failed));
}
File: third_party/rust/wgpu-core/src/device/resource.rs, line 4833-4837
if attribute.shader_location >= self.limits.max_vertex_attributes {
// self.limits is the FORGED per-device limit (2^28), so
// shader_location = 0x0FFFFFFF passes and reaches the Vulkan driver,
// violating Vulkan valid usage (location < maxVertexInputAttributes = 16)
...
The dma-buf branch builds the Vulkan device manually and registers it with the forged limits; the checked path it bypasses validates limits against adapter capabilities; downstream pipeline validation then trusts the forged device limits.
Exploit Chain
- Attacker achieves code execution in a content process (renderer RCE) on Linux where the Vulkan driver advertises the dma-buf extension set (default for Mesa radv/anv/lavapipe) and WebGPU is enabled.
- The compromised content process sends a PWebGPU RequestDevice message with forged required_limits, e.g. max_vertex_attributes = 0x10000000 (2^28), far above the adapter capability of 16.
- In the parent process, wgpu_bindings::server::adapter_request_device takes the Linux dma-buf branch (server.rs:504-614) because the driver supports the four external-memory extensions; this branch calls device_from_raw + Global::create_device_from_hal with the forged limits, skipping the check_limits() validation performed by the normal Global::adapter_request_device path. Device creation SUCCEEDS (the checked path would have returned LimitsExceeded).
- The compromised process sends a CreateRenderPipeline device action with a vertex attribute whose shaderLocation is 0x0FFFFFFF.
- wgpu-core validates shader_location against the forged device limit (0x0FFFFFFF < 2^28 passes, resource.rs:4833) and forwards the descriptor to wgpu-hal, which calls vkCreateGraphicsPipelines with VkVertexInputAttributeDescription.location = 268435455 — violating the Vulkan valid-usage contract (location must be < maxVertexInputAttributes = 16).
- The Vulkan driver in the parent process performs an out-of-bounds write while building its per-location vertex-input tables (SwiftShader: vk::Inputs::initialize writes at heap_base + location*40, i.e. base + ~10 GB). The write offset scales linearly with the attacker-chosen location (28 bits of range), giving a controlled-offset wild write in the parent process — a memory-corruption primitive for sandbox escape.
- Attacker refines the location value (and heap grooming) to convert the controlled-offset OOB write into parent-process code execution, escaping the content sandbox.
IPC Path
-
PWebGPU RequestDevice
- Protocol: PWebGPU
- Parent process: Main
- Child process: Content
- Message flow: Content -> Main: Messages(RequestDevice{desc.required_limits forged to 2^28})
-
PWebGPU CreateRenderPipeline
- Protocol: PWebGPU
- Parent process: Main
- Child process: Content
- Message flow: Content -> Main: Messages(Device(CreateRenderPipeline{shaderLocation=0x0FFFFFFF}))
Steps to Reproduce
- Provision a Vulkan driver that advertises the dma-buf extension set (matching shipping Linux Mesa drivers). In the offline container: curl -o chrome.zip https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/1663147/chrome-linux.zip && unzip chrome.zip 'chrome-linux/libvk_swiftshader.so' -d /opt/vk/
- Build the ICD shim that forwards to SwiftShader but additionally advertises VK_EXT_external_memory_dma_buf and VK_EXT_image_drm_format_modifier (and strips them at vkCreateDevice): clang -shared -fPIC -O2 -o /opt/vk/shim/libvk_shim.so vk_shim.c -ldl
- Install the ICD manifest at /usr/share/vulkan/icd.d/shim_icd.json pointing at /opt/vk/shim/libvk_shim.so
- Apply compromised-child-simulation.patch (child-side only, XRE_IsContentProcess()-gated: forges required_limits in RequestDevice when the device label is FORGE_LIMITS_PWN) to /firefox
- Build with build_firefox using mozconfigs/mozconfig.linux.asan.fuzzing
- Run testcase.html via browser_evaluator with prefs {"dom.webgpu.enabled": true}
- Observe console logs 'PWN: adapter maxVertexAttributes=16' and 'PWN: device created despite forged limits (2^28) > adapter cap (16)', followed by a parent-process ASAN SEGV WRITE in vk::Inputs::initialize (crashed_parent=true)
- Control: the same pipeline on a device requested with honest limits is cleanly rejected with 'Vertex attribute location 268435455 must be less than limit 16' and no crash
Security Impact
- Severity: High
- Attacker capability: A compromised content process obtains a parent-process (GPU host process) out-of-bounds write at a largely attacker-controlled offset (write address = allocation base + shaderLocation * element_size, with 28 bits of index range), by violating the Vulkan driver's API contract through forged WebGPU device limits. This is a memory-corruption primitive in the privileged process suitable for sandbox escape; the same missing validation also lifts every other wgpu-core limit check (buffer/texture/bind-group limits), exposing broad additional driver attack surface.
- Preconditions: Content-process compromise (renderer RCE) is required; Linux with a Vulkan driver exposing VK_KHR_external_memory_fd, VK_EXT_external_memory_dma_buf, VK_EXT_image_drm_format_modifier and VK_KHR_external_semaphore_fd (default on Mesa radv/anv/lavapipe); WebGPU enabled (dom.webgpu.enabled).
ASAN Report
==10959==ERROR: AddressSanitizer: SEGV on unknown address 0x7bd211af3168 (pc 0x79eee83c18d3 bp 0x79ef0e892a50 sp 0x79ef0e892980 T58)
==10959==The signal is caused by a WRITE memory access.
#0 0x79eee83c18d3 in vk::Inputs::initialize(VkPipelineVertexInputStateCreateInfo const*, VkPipelineDynamicStateCreateInfo const*) Context.cpp:0:0
#1 0x79eee838913a in vk::GraphicsPipeline::GraphicsPipeline(VkGraphicsPipelineCreateInfo const*, void*, vk::Device*) VkPipeline.cpp:0:0
#2 0x79eee839710c in VkResult vk::ObjectBase<vk::GraphicsPipeline, VkNonDispatchableHandle<VkPipeline_T*>>::Create<VkGraphicsPipelineCreateInfo, vk::Device*>(VkAllocationCallbacks const*, VkGraphicsPipelineCreateInfo const*, VkNonDispatchableHandle<VkPipeline_T*>*, vk::Device*) libVulkan.cpp:0:0
#3 0x79eee8397002 in vkCreateGraphicsPipelines libVulkan.cpp:0:0
#4 0x79ef794022ff in <ash::device::Device>::create_graphics_pipelines /firefox/third_party/rust/ash/src/device.rs:2157:24
#5 0x79ef794022ff in <wgpu_hal::vulkan::Device as wgpu_hal::Device>::create_render_pipeline /firefox/third_party/rust/wgpu-hal/src/vulkan/device.rs:2174:22
#6 0x79ef78aca6a6 in <wgpu_hal::vulkan::Device as wgpu_hal::dynamic::device::DynDevice>::create_render_pipeline /firefox/third_party/rust/wgpu-hal/src/dynamic/device.rs:429:18
#7 0x79ef78cba77b in <wgpu_core::device::resource::Device>::create_render_pipeline_inner /firefox/third_party/rust/wgpu-core/src/device/resource.rs:5553:33
#8 0x79ef78c9bcd8 in <wgpu_core::device::resource::Device>::create_render_pipeline /firefox/third_party/rust/wgpu-core/src/device/resource.rs:4710:51
#9 0x79ef793119b0 in <wgpu_core::global::Global>::device_create_general_render_pipeline /firefox/third_party/rust/wgpu-core/src/device/global.rs:943:40
#10 0x79ef7930e8c1 in <wgpu_core::global::Global>::device_create_render_pipeline /firefox/third_party/rust/wgpu-core/src/device/global.rs:835:14
#11 0x79ef789c2815 in <wgpu_bindings::server::Global>::device_action /firefox/gfx/wgpu_bindings/src/server.rs:2406:39
#12 0x79ef789c2815 in wgpu_bindings::server::process_message /firefox/gfx/wgpu_bindings/src/server.rs:3026:20
#13 0x79ef789d2e07 in wgpu_server_messages /firefox/gfx/wgpu_bindings/src/server.rs:2792:9
#14 0x79ef6ca07ee2 in mozilla::webgpu::WebGPUParent::RecvMessages(unsigned int, mozilla::ipc::ByteBuf&&, nsTArray<mozilla::ipc::ByteBuf>&&, nsTArray<mozilla::ipc::shared_memory::Handle<(mozilla::ipc::shared_memory::Type)0>>&&) /firefox/obj-firefox-asan/dom/webgpu/./../../../dom/webgpu/ipc/WebGPUParent.cpp:1700:3
#15 0x79ef6ca0cd07 in mozilla::webgpu::PWebGPUParent::OnMessageReceived(IPC::Message const&) /firefox/obj-firefox-asan/dom/webgpu/./../../ipc/ipdl/PWebGPUParent.cpp:322:80
#16 0x79ef68995cb5 in mozilla::gfx::PCanvasManagerParent::OnMessageReceived(IPC::Message const&) /firefox/obj-firefox-asan/gfx/ipc/./../../ipc/ipdl/PCanvasManagerParent.cpp:273:32
#17 0x79ef666fbab5 in mozilla::ipc::MessageChannel::DispatchAsyncMessage(mozilla::ipc::ActorLifecycleProxy*, IPC::Message const&) /firefox/obj-firefox-asan/ipc/glue/./../../../ipc/glue/MessageChannel.cpp:1797:25
#18 0x79ef666f7e8e in mozilla::ipc::MessageChannel::DispatchMessage(mozilla::ipc::ActorLifecycleProxy*, std::unique_ptr<IPC::Message, std::default_delete<IPC::Message>>) /firefox/obj-firefox-asan/ipc/glue/./../../../ipc/glue/MessageChannel.cpp:1723:9
#19 0x79ef666f8e47 in mozilla::ipc::MessageChannel::RunMessage(mozilla::ipc::ActorLifecycleProxy*, mozilla::ipc::MessageChannel::MessageTask&) /firefox/obj-firefox-asan/ipc/glue/./../../../ipc/glue/MessageChannel.cpp:1512:3
#20 0x79ef666fa2ee in mozilla::ipc::MessageChannel::MessageTask::Run() /firefox/obj-firefox-asan/ipc/glue/./../../../ipc/glue/MessageChannel.cpp:1614:14
#21 0x79ef6646f1ca in nsThread::ProcessNextEvent(bool, bool*) /firefox/obj-firefox-asan/xpcom/threads/./../../../xpcom/threads/nsThread.cpp:1174:16
#22 0x79ef66478939 in NS_ProcessNextEvent(nsIThread*, bool) /firefox/obj-firefox-asan/xpcom/threads/./../../../xpcom/threads/nsThreadUtils.cpp:471:10
#23 0x79ef6670801c in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) /firefox/obj-firefox-asan/ipc/glue/./../../../ipc/glue/MessagePump.cpp:327:5
#24 0x79ef665a0764 in MessageLoop::RunInternal() /firefox/obj-firefox-asan/ipc/chromium/./../../../ipc/chromium/src/base/message_loop.cc:371:10
#25 0x79ef665a0764 in MessageLoop::RunHandler() /firefox/obj-firefox-asan/ipc/chromium/./../../../ipc/chromium/src/base/message_loop.cc:364:3
#26 0x79ef665a0764 in MessageLoop::Run() /firefox/obj-firefox-asan/ipc/chromium/./../../../ipc/chromium/src/base/message_loop.cc:346:3
#27 0x79ef66466fe4 in nsThread::ThreadFunc(void*) /firefox/obj-firefox-asan/xpcom/threads/./../../../xpcom/threads/nsThread.cpp:375:10
#28 0x7def91beb8cf in _pt_root /firefox/obj-firefox-asan/config/external/nspr/pr/./../../../../../nsprpub/pr/src/pthreads/ptthread.c:190:3
#29 0x572d812fab36 in asan_thread_start(void*) _asan_rtl_:28
#30 0x7def923f7aa3 in pthread_condattr_setpshared ??:?
#31 0x7def92484a63 in clone ??:0:0
==10959==Register values:
rax = 0x00007bcf91af3178 rbx = 0x00007bcf91af2f80 rcx = 0x0000000000000000 rdx = 0x0000000000000000
rdi = 0x000000004ffffffb rsi = 0x00007a4f9226abe0 rbp = 0x000079ef0e892a50 rsp = 0x000079ef0e892980
r8 = 0x000000000000006d r9 = 0x0000000000000006 r10 = 0x0000000000000004 r11 = 0x0000000000000000
r12 = 0x00007a9f91b43d08 r13 = 0x0000000000000000 r14 = 0x000079ef0d16ac40 r15 = 0x000079eee0ad3820
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/opt/vk/chrome-linux/libvk_swiftshader.so+0x1758d3) (BuildId: 1d3c093fb6f55d65103c57ecc9608ed8f901a0b7)
==10959==ABORTING
| Reporter | ||
Comment 1•4 months ago
|
||
| Reporter | ||
Comment 2•4 months ago
|
||
| Reporter | ||
Comment 3•4 months ago
|
||
| Reporter | ||
Comment 4•4 months ago
|
||
| Reporter | ||
Comment 5•4 months ago
|
||
| Reporter | ||
Comment 6•4 months ago
|
||
| Reporter | ||
Comment 7•4 months ago
|
||
| Reporter | ||
Comment 8•4 months ago
|
||
| Reporter | ||
Comment 9•4 months ago
|
||
Updated•4 months ago
|
Updated•4 months ago
|
Comment 13•3 months ago
|
||
This is a mass re-assignment of sec keywords. sandbox-escape is reserved for attacks that originate in the content process and target the parent process, and excludes the GPU process as a target. Automated analysis indicates this situation did not apply to this bug, if this is in error, please revert the change. Change UUID: 898281a8-414d-4583-a92c-d5f62da4b2d0
| Assignee | ||
Updated•3 months ago
|
| Assignee | ||
Comment 14•3 months ago
|
||
dx12 has a similar problem, but unlike vulkan, the special path is for adapter creation rather than device creation. This avoids the limit bypass security issue affecting vulkan. However, the way we're doing device construction for presentation is effectively duplicating code from wgpu in the bindings, which is a pretty big risk for code that is doing critical validation.
| Assignee | ||
Updated•3 months ago
|
| Assignee | ||
Comment 15•3 months ago
|
||
For bug 2050871, I asked Claude to audit the rest of our *_from_raw usage, and it did look at this, but got it wrong:
| Sink | Path | Verdict |
|---|---|---|
| device_from_raw+create_device_from_hal | RequestDevice (Linux/Vulkan) | trusted (only limits/features values are content-derived, and they're sanitized/asserted before the HAL call) |
| Assignee | ||
Comment 16•3 months ago
|
||
Needs https://github.com/gfx-rs/wgpu/commit/7a655581ff7d3fd9f38e4ede2bdd9c16bfcba899 (2026-07-30), and then an additional Firefox change after that is vendored.
Updated•3 months ago
|
| Assignee | ||
Comment 17•3 months ago
|
||
Comment 18•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 19•3 months ago
|
||
Comment 20•3 months ago
|
||
| bugherder | ||
Updated•3 months ago
|
| Assignee | ||
Comment 21•3 months ago
|
||
I wasn't sure before if we would uplift Linux-specific WebGPU security fixes to ESR 153, since it's not supported, but can be manually enabled by setting dom.webgpu.enabled. Talking with :jimb today, the answer is that we aren't going to, so clearing tracking for ESR153.
Updated•3 months ago
|
Updated•4 days ago
|
Description
•