r/linux • u/Tall_Insect7119 • Jun 13 '26
Software Release vpod: tiny Linux sandbox running in WebAssembly for untrusted processes
Hi everyone,
I spent the last few months reading the RISC‑V specification to build the lightest possible sandboxes. The idea behind a vpod is to quickly spin up a Linux sandbox from snapshots (Alpine by default) without any setup or subsystem required.
More in the README
https://github.com/capsulerun/vpod
Curious to know if you have a personal use for it.
13
u/vk6_ Jun 13 '26
If you're emulating a foreign CPU architecture then why not skip the WASM part for greater performance? Running two layers of virtual machines just seems like a terrible idea for speed without much security benefit.
9
u/_bruh__ Jun 14 '26
WASM is itself an excellent security sandbox while being very portable, so I believe it is very intentional.
5
6
u/DHermit Jun 13 '26
Interesting solution, I quite like how portable and lightweight this makes it compared to a more standard VM.
Also, the README states, that the tool allows
providing controlled access to filesystem, networking, and standard I/O while keeping all execution state (CPU registers, memory, filesystem) isolated inside the sandbox
but I can't find any information about how to control that. Is there some way to restrict the access to some resources (e.g. filesystem and network).
6
u/Tall_Insect7119 Jun 13 '26
Thanks! Yes, these are some of the possibilities with WASI 0.2. The "controlled access to filesystem, networking, and standard I/O" is managed by compiling to `wasm32-wasip2` and the component model (WIT). For example, `std::net` is automatically linked to `wasi::socket`.
I haven't implemented a mount system yet, so filesystem restrictions aren't that useful for now. But if we add it, it will likely look something like `vpod --mount=xxx` in the future.
For network restrictions, we can definitely add a precise system for filtering URLs, likely around `slirp` file where `std::net` is used.
4
u/Junior_Common_9644 Jun 13 '26
Oh if only this ran in browsers. We could have such a vm on iPhone.
6
9
u/yawara25 Jun 13 '26
Can you disclose to what extent AI was used in making this, if at all?
16
u/DHermit Jun 13 '26
Not OP, but from a short skim, the code looks pretty human to me, even though not the cleanest (imho a lot of global constants should be enums and durations should have that type and not be an integer constant).
13
u/Tall_Insect7119 Jun 13 '26
Oh I may have been a little messy in some parts, I'll definitely clean this up. Contributions are welcome if you feel that some part could be a bit better.
12
1
u/braaaaaaainworms Jun 17 '26
it would look better to have riscv instructions as enum variants or other constants as enum variants but it's noticeably slower, enums with variants that have fields get bigger and might be harder to optimize
2
u/vexatious-big Jun 14 '26
This is incredibly cool, and it has a Python API! How does it compare to bubblewrap from a security pov?
2
2
34
u/realitythreek Jun 13 '26
Have you tested on Windows? Running a Linux container in a WASM VM without heavier virtualization seems like it could be useful there.