4 ms·
The motivation for WebAssembly rather than plain ARM or x86 assembly = portability, security. It would be interesting to see how this is designed for security
by 29athrowaway 7y ago
The motivation for WebAssembly rather than plain ARM or x86 assembly = portability, security.
It would be interesting to see how this is designed for security in mind.
- kick 7y agoThis is designed for microcontrollers. If you're running untrusted code on microcontrollers, you've got bigger problems.
- saagarjha 7y agoI wouldn't go as far as to say it's designed for microcontrollers; as others have mentioned, there's a number of potential applications for this in other contexts as well.
- DarthGhandi 7y agoPardon my wasm illiteracy here, what exactly makes it more secure? Struggling to see it.
- earenndil 7y agoSandboxing is trivial, because you can cover all paths to the outside world.
- DarthGhandi 7y agoI edited my earlier comment to remove the sandboxing part thinking this may be embedded specific, so not sure you saw that, so ask again how is this special? would you rather inspect potentially malicious wasm or js?
- 29athrowaway 7y agoAll web APIs are designed to be secure in the context of the web. Needs to be memory safe otherwise a wasm program can execute arbitrary code, access memory that it should not, etc.
- ridiculous_fish 7y agoWASM has a sandboxing model. The idea is: 1. Control flow is always checked. You can't jump to an arbitrary address, you jump to index N in a control flow table. 2. Calls out of the sandbox are also table based. 3. Indexed accesses are bounds checked. On 64 bit platforms, this is achieved by demoting the wasm to 32 bit and using big guard pages. On 32 bit platforms, it's explicit compares. The result is something which may become internally inconsistent (can Heartbleed) but cannot perform arbitrary accesses to host memory.
- tasogare 7y agoHow is that different from CLR or JVM?
- ridiculous_fish 7y agoI'll speak to JVM; I'm less familiar with CLR but I believe it's the same. JVM and WASM both have statically-verifiable control flow. No wild jumps, no executable stacks, etc. Phew. Arrays and pointer arithmetic are a big difference. WASM has a big linear memory block, and instructions may access arbitrary locations within it - the runtime performs bounds checking only at the edges. So your `sprintf` can still overflow the buffer, and smash the stack's data, but can't affect the host, or the control flow. JVM goes further: it prohibits pointer arithmetic and pushes array accesses down into the instruction stream. To access a JVM array, you must provide the array reference itself, and the runtime will perform bounds checking using the length. The JVM approach gives you better runtime safety - no Heartbleed! The WASM approach is lower-level and is more easily adapted to existing system languages: C++, Rust, other LLVMites.
- pjmlp 7y agoCLR was designed to support C++ since day one. And while WASM trumps the security trumpet, without actually supporting proper bounds checking, the CLR will taint C++ pointer arithmetic as unsafe, thus making the whole module unsafe. So I as consumer can decide if I am willing to trust an unsafe module or not.
- sanxiyn 7y agoUnlike in x86 or ARM assembly, you can't overwrite the return address in WebAssembly.