News for hackers. Stuff that matters.
Re:Wasm3 – A high performance WebAssembly interpreter in C by 29athrowaway on Sunday January 12, 2020 @10:13PM (#22031539)
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.

Re:Wasm3 – A high performance WebAssembly interpreter in C by DarthGhandi on Sunday January 12, 2020 @11:23PM (#22031803)
Pardon my wasm illiteracy here, what exactly makes it more secure?

Struggling to see it.

Re:Wasm3 – A high performance WebAssembly interpreter in C by ridiculous_fish on Monday January 13, 2020 @12:19AM (#22032025)
WASM 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.

Re:Wasm3 – A high performance WebAssembly interpreter in C by tasogare on Monday January 13, 2020 @12:28AM (#22032065)
How is that different from CLR or JVM?
Re:Wasm3 – A high performance WebAssembly interpreter in C by ridiculous_fish on Monday January 13, 2020 @12:53AM (#22032159)
I'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.

Re:Wasm3 – A high performance WebAssembly interpreter in C by pjmlp on Monday January 13, 2020 @01:04AM (#22032197)
CLR 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.

Re:Wasm3 – A high performance WebAssembly interpreter in C by johncolanduoni on Monday January 13, 2020 @02:30AM (#22032545)
The CLR doesn’t guarantee control flow integrity (modulo type confusion) or any form of isolation when linear memory accesses are used. So here WASM offers another option in the middle between trust and don’t trust: “trust unsafe module only to not compromise its own functionality; no attacking the rest of the process or kernel” (modulo runtime bugs).
Re:Wasm3 – A high performance WebAssembly interpreter in C by pjmlp on Monday January 13, 2020 @02:39AM (#22032593)
Well for that execution of unsafe Assemblies was already enabled anyway, so there isn't much that the verifier can do.

Which is something that WASM isn't being honest about, corruption of internal data structures is allowed.

If I can control what goes into memory just by calling module public functions with the right data set and access patterns, CFI won't help a thing.

Suddenly the authorization module that would authenticate me as regular user, might give me another set of capabilities and off to the races.

Re:Wasm3 – A high performance WebAssembly interpreter in C by my123 on Monday January 13, 2020 @04:00AM (#22032914)
Note for C++ on the CLR that you can use /clr:safe as an MSVC compilation argument. This errors out when trying to access to random pointers at compile time.

/clr:pure uses unsafe and supports those cases though.

And yeah, WebAssembly only doing bounds checking within a single memory block and not actually offering true bounds checking is a big downgrade, and a pretty much unjustified one (+ it's rare among JITted languages...).

Re:Wasm3 – A high performance WebAssembly interpreter in C by zozbot234 on Monday January 13, 2020 @05:15AM (#22033238)
If you care about "true" bounds checking, just compile to Wasm from a safe source language. Besides, Wasm does support multiple memory blocks so a potentially-unsafe module need not "taint" anything else.
Re:Wasm3 – A high performance WebAssembly interpreter in C by pjmlp on Monday January 13, 2020 @05:24AM (#22033266)
Security is as strong as the weakest link.
Re:Wasm3 – A high performance WebAssembly interpreter in C by my123 on Monday January 13, 2020 @05:28AM (#22033284)
Memory blocks have a page granularity, which makes them useless for pervasive checking. (+ you can do the same thing to a reasonable extent with C even, with guard pages.)
Re:Wasm3 – A high performance WebAssembly interpreter in C by pjmlp on Monday January 13, 2020 @01:01AM (#22032184)
Internally inconsistency is already good enough for possible security exploits, by making the module reveal stuff that would otherwise be forbidden.
Re:Wasm3 – A high performance WebAssembly interpreter in C by cfallin on Monday January 13, 2020 @02:12AM (#22032471)
That's not the goal of a VM/runtime, though: it only ensures that the hosted code cannot escape the sandbox, and provides a correct implementation of the semantics of each VM opcode. The hosted code's computation implemented with those opcodes is a black box to the VM.

Consider: should the VM somehow try to analyze the running code and determine when it's about to commit a logical error and return "forbidden" data? What specification states which data is forbidden?

Consider: even the most high-level VM can execute a program with logical errors if it is Turing-complete. A Java or Erlang program running on a bug-free, fully-compliant implementation of the respective VM can still get (e.g.) an authorization condition wrong, or incorrectly implement a security protocol, or return data from the wrong (in-bounds, but wrong!) index in an array.

Re:Wasm3 – A high performance WebAssembly interpreter in C by pjmlp on Monday January 13, 2020 @02:34AM (#22032571)
Indeed, what WASM advocates cannot do is advocate safety, that it is better than any other bytecode format since 1958, when it isn't so.

Secondly, it could have been designed with bounds checking for any kind of data access.

The CLR is honest about it, when C++/CLI uses C style low level tricks, the Assembly is considered tainted and requires explicit allowance of unsafe assemblies execution.

An idea that goes back to Burroughs B5000, where tainted binaries (code using unsafe code blocks) requires admin permission for execution.

Re:Wasm3 – A high performance WebAssembly interpreter in C by sanxiyn on Monday January 13, 2020 @12:32AM (#22032079)
Unlike in x86 or ARM assembly, you can't overwrite the return address in WebAssembly.
Re:Wasm3 – A high performance WebAssembly interpreter in C by earenndil on Monday January 13, 2020 @12:09AM (#22031990)
Sandboxing is trivial, because you can cover all paths to the outside world.
Re:Wasm3 – A high performance WebAssembly interpreter in C by DarthGhandi on Monday January 13, 2020 @12:14AM (#22032005)
I 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?
Re:Wasm3 – A high performance WebAssembly interpreter in C by 29athrowaway on Monday January 13, 2020 @12:10AM (#22031993)
All 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.

Re:Wasm3 – A high performance WebAssembly interpreter in C by kick on Sunday January 12, 2020 @11:07PM (#22031737)
This is designed for microcontrollers. If you're running untrusted code on microcontrollers, you've got bigger problems.
Re:Wasm3 – A high performance WebAssembly interpreter in C by saagarjha on Monday January 13, 2020 @06:30AM (#22033512)
I 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.