Suitable for use with untrusted code? #2792
-
Hi there! 👋 I've been thinking about a use case in which a native host application creates a render target, and then exposes a rendering API to untrusted code running in a Wasm VM. However, I couldn't find in my (admittedly brief) searching whether it is a design goal of wgpu itself to provide an API that is suitable for exposing directly to untrusted code. So my question would be: am I barking up the right tree? I understand that wgpu is based on WebGPU in the sense that it can target it directly and be used as a basis for implementing it, but it's not immediately apparent to me whether wgpu itself shares the "sandboxing" goal of WebGPU. I should add that I'm less concerned right now with the level of confidence the maintainers have that it's actually safe to use in this way right now, and more interested in whether or not it is a design goal or if it's out-of-scope of this project. If I am indeed barking up the wrong tree, I guess the more sensible approach would be to wait for or help to implement a proper WebGPU API for Wasmtime (presumably based on wgpu) and have the untrusted code target that? Thanks in advance for any 💭! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Assuming you don't turn on any native only features that aren't hardened, you should be reasonably able to run with untrusted code. The main bit of sandboxing that WebGPU adds on top is process isolation - the "content" process talks with the render process (that has wgpu in it) over IPC. Beyond that, there isn't significant amount of hardening. That is to say assuming you don't need process isolation, you should be good to go :) |
Beta Was this translation helpful? Give feedback.
-
I assume what you have in mind here is that This sounds very much like the way Firefox's WebGPU implementation uses Firefox further isolates untrusted content JS by placing it in a separate process from |
Beta Was this translation helpful? Give feedback.
Assuming you don't turn on any native only features that aren't hardened, you should be reasonably able to run with untrusted code. The main bit of sandboxing that WebGPU adds on top is process isolation - the "content" process talks with the render process (that has wgpu in it) over IPC. Beyond that, there isn't significant amount of hardening. That is to say assuming you don't need process isolation, you should be good to go :)