5 ms·
I think server-side WASM is going to be huge, because it could finally give us an easy to run code in a secure sandbox. Imagine being able to run a complex C d
by simonw 5y ago
I think server-side WASM is going to be huge, because it could finally give us an easy to run code in a secure sandbox.
Imagine being able to run a complex C dependency (with a high risk of buffer overflows) risk-free because it's running in a WASM sandbox?
Or building features that allow users to provide their own executable code (for plugins and extensions and other customization features) where they code is executed in a sandbox with strictly controlled CPU/memory/network and API access control.
- Matthias247 5y agoI’m not sure the amount of C code that one wants to run into a server that is not system level code (doesn’t make syscalls itself and implements the server/ business logic) is noticeable. And only if that would be the case the use of WASM would be an advantage. For general extensibility we had Java servlets, Lua modules, PHP modules, etc in webservers for decades. Maybe it’s interesting for source code obfuscation purposes or in order to allow migration of server logic between different languages. But even that was possible before - and I don’t think the Market need was huge.
- watermelon0 5y agoThere are many tools such as ffmpeg, that you might want to run on untrusted input (e.g. file uploads), and in many cases performance is not that important. Java servlets, Lua and PHP modules cannot be run securely, and there are vulnerabilities for all of them.
- fiddlerwoaroof 5y ago> Java servlets, Lua and PHP modules cannot be run securely, and there are vulnerabilities for all of them The thing is, the JVM was designed with the explicit intention of making it possible to run untrusted code safely: how do we know we got it right this time? The problem really isn't the VM, it's the APIs and authorization model for access to the underlying system's features.
- gpm 5y agoBecause browsers have a good track record of getting this right, and sufficient funding to get this right, and the server-side work gets to piggy-back on that. Also because the API surface area that server side apps need is really just not big, JVM had a lot of problems because it tried to do too much.
- simonw 5y agoI want to use the best-of-breed libraries for image handling, movie decoding and suchlike - and most of those are still written in C.
- croes 5y agoIf you want safe code you have to write safe code. Putting it into a sandbox gives you fake security.
- wtetzner 5y ago> If you want safe code you have to write safe code That doesn't help if you need to run other people's code.
- croes 5y agoThen you have to forgo safety.
- simonw 5y agoTell that to Heroku, GitHub (Actions), Vercel and the whole of AWS, Google Cloud and Microsoft Azure! Running other people's code is a multi-billion dollar business opportunity.
- croes 5y agoSince when does multi-billion dollar opportunity corelate with safety?
- wtetzner 5y agoIt depends on what you mean by "safety". Yes, if you're running other people's code, you can't expect it to be entirely safe. However, you can mitigate the damage it can cause.
- skybrian 5y agoRunning untrusted code in a sandbox made client-side web apps possible, so I think there’s more to it than that.
- croes 5y agoBut you wouldn't say it's safe just less unsafe.
- pjmlp 5y agoYou mean like CLR or IBM mainframes language environments? Yeah, I wonder how it would look like. /s
- irq-1 5y agoRight. WASM will protect the server from the apps, which means you don't need to audit or trust what you run. That old PHP website? Compile to WASM and you might lose any data it can touch, but it won't expose the server in any way -- no getting a login shell or sudo exploits, etc...
- nerdponx 5y agoForgive me if this is a newbie question, but what makes the Wasm runtime more of a "sandbox" than e.g. CPython or the JVM? Do you need explicit permission/authorization from the host machine in order to do things like file and network i/o? Surely such a system isn't any more foolproof than SSH w/ a restricted shell, KVM, etc.?
- irq-1 5y agoWeb Assembly comes from JavaScript on the client, which means: -it's extremely secure, tested for many years, etc... -it's different than other VMs, almost no types or functions, the VM cannot access outside memory, only call functions supplied by the host (or write to stdout, again supplied by the host.) -It loads fast, runs fast. Browser JavaScript has been very optimized. -unrelated to the browser, but many languages can be compiled to WASM What you see in this project is the WASI interface that provides the normal libc functions like fopen(), allowing WASM to act like a normal binary. But you can run WASM with other sets of functions, or none and the host can do all the moving of bytes. Cloudflare, Netlify and others are trying to figure out how to host WASM for cloud functions because it's perfect for their systems: small, fast and safe.
- nextaccountic 5y agoI think there are some misconceptions here. Wasm on the server using WASI (which nowadays is probably either wasmtime or wasmer) doesn't have anything to do with Javascript. Actually, wasm on the browser doesn't have anything to do with javascript either! This is actually unfortunate, because wasm in the browser can't natively interface with JS's GC yet [0]. On the other hand, I think a great strength of wasm is that wasm isn't tied to a single memory management system: if it forced a GC on you, it would also need to dictate the memory layout, and would need to determine how this GC gets run, all this would add unnecessary overheard and inflexibility when compiling low-level languages. Or when compiling any language that don't quite conform to the memory management model, different languages want to manage memory differently. This is a pain in the JVM and wasm fixed that. Another strength is vendor neutrality. All major browsers embraced wasm, and it's got multiple implementations in the server as well. There isn't really a dominant implementation that others must conform, and wasm tools are interoperable between implementations. There are also embedded implementations (I know of wamr and wasm3). On a darker note, I'm sad to see see one WASI runtime bashing another [1]; I wish the competition was more cordial, or at least, more professional. [0] see the issues in this repo https://github.com/WebAssembly/gc https://github.com/WebAssembly/gc [1] https://wasmer.io/wasmer-vs-wasmtime https://wasmer.io/wasmer-vs-wasmtime - makes outlandish claims and uses benchmarks without clearly specifying what is being benchmarked (ideally it would link to a Github repo)