It feels like we're constantly getting closer to this. We've been mostly able to do this in the browser for years now.
I continue to have high hopes for non-browser WebAssembly. I really, really want to be able to run Python, JavaScript, Rust code etc on my phone and laptop inside a WebAssembly sandbox that tightly limits the filesystem, network, memory and CPU access of that code.
I'm seeing glimpses of this being possible - https://til.simonwillison.net/webassembly/python-in-a-wasm-s... and https://til.simonwillison.net/deno/pyodide-sandbox for example - but it's still not as easy as I want it to be.
Everything else feels like trying to patch over the shaky security foundations with just one more abstraction.
I want a sandbox that's robust, widely used and widely tested. WebAssembly feels like it should be the best possible option.
If you have a better idea for a sandbox I can use to run untrusted code on my laptop (and phone) I'd love to hear what it is!
Use KVM if you're on Linux/Android. It's not about the binaries but where and how it's running, there is 0 isolation in WASM alone, and creating a new runtime to run it outside of browsers will not give you what you're looking for.
Android recently announced they're going the KVM route.
Pyodide provides one that works well for Python.
I'm finding it surprisingly hard to find a good option for JavaScript. QuickJS or one of its forks might work but I've not yet figured out the incantations necessary to do that.
Then there's Lua, Ruby, PHP, etc - ideally I'd like there to be robust, well maintained, well documented WebAssembly versions of any language that I might want to run code from.
Firecracker is the best I've seen in terms of container security - it was designed by AWS for Lambda and is trusted by people I trust. It's not really packaged for easily running on macOS etc though.