6 ms·
> Security and performance were part of Java and .NET design, hence why they have validation as part of their execution workflow. Java and CLR bytecode verific
by naasking 8y ago
> Security and performance were part of Java and .NET design, hence why they have validation as part of their execution workflow.
Java and CLR bytecode verification is crap because they weren't designed for efficient verification from the start, WASM was: they're expensive, slow, and imprecise. WASM verification gives you much stronger properties, and it's significantly cheaper. It's a much better universal bytecode than any other offerings currently available.
- pjmlp 8y agoBenchmarks regarding meaningful impact in production code? Also WASM remains to be battle tested regarding exploits in the wild.
- naasking 8y agoThe WASM spec was developed with formal verification in mind, and the core specification, interpreter and type checker had mechanized safety proofs very early on [1]. This is backwards from how most bytecodes were designed, so that's very promising. Note also that the specification is an explicitly single-pass type checking, which is very efficient. The difficulty of full safety verification on the JVM is well studied [2]. The security-focused Joe-E language actually decompiles JVM bytecodes back to Java to avoid the many full abstraction failures that have been documented. The CLR is a little better on the safety record, but the verification costs can be even higher because the CLR supports various pointer types. Proper verification requires control-flow analysis, but instead they partition the bytecode into safe/unsafe variants and only the safe variant is "verifiable". IIRC, WASM doesn't have this limitation. [1] https://www.cl.cam.ac.uk/~caw77/papers/mechanising-and-verifying-the-webassembly-specification.pdf https://www.cl.cam.ac.uk/~caw77/papers/mechanising-and-verif... [2] http://www-master.ufr-info-p6.jussieu.fr/2005/IMG/pdf/leroy-bytecode-verification-JAR.pdf http://www-master.ufr-info-p6.jussieu.fr/2005/IMG/pdf/leroy-...
- pjmlp 8y agoWell, repolfx already pointed out a couple of issues with WASM security. As for the links I will check them later. Thanks providing them.
- readittwice 8y agoNo, repolfx didn't. There were some security bugs with WASM, but why shouldn't have that happened with Java Bytecode? Also the JVM isn't immune to security bugs either.
- pjmlp 8y agoThe point is that it did, with more than 20 years experience in production to fine tune its security. WASM still needs to prove itself in similar scenarios.
- naasking 8y agoJava's security is still terrible. Read up on the Joe-E work to see why. "Fine-tuning security" is typically symptomatic of bad security design. Security is not a separable concern.
- pjmlp 8y agoWell WASM has been fined tuned already, given the referred bug fixes. I will read the paper later on.
- naasking 8y ago"Fine tuned" != "bug fixes". Fine tuning means they start changing the security model and the properties it can enforce because it was poorly designed to begin with. That is the case with the JVM but not with WASM.
- steipete 8y agoA great WASM benchmark: http://iswebassemblyfastyet.com/ http://iswebassemblyfastyet.com/
- pjmlp 8y agoThanks, but I was refereeing to some kind of benchmark where WASM verification wins against JVM verification, in similar scenarios.
- repolfx 8y agoCan you back that up? Modern JVM bytecode is cheap to verify and gives you very strong properties like memory and type safety, i.e. the app will not have buffer overflows or type confusion attacks in it. WASM gives you virtually no guarantees about the software running in it, beyond that it (maybe) can't escape its sandbox. It's a much better universal bytecode than any other offerings currently available. I think that's a very strong statement for something so debatable. WASM appears, to me eyes, to have numerous serious flaws that make me wonder why people are so excited about it. JVM bytecode appears to beat it in every aspect. 1. No GC support, no real workable plan to get there because there's also no type system worth a damn. They've been looking at it for years and this article says all they've got is a tiny stepping stone - no actual GC, just a way to mark pointers to things that came from JS in the type system. This wouldn't matter if the future of the web was software written in C, but if it is, god help us all. 2. No threading. JVM has been thread safe from the start, and has had a huge amount of work put into its memory model, so you can reason about the nature of bytecode when run on different CPUs and in the presence of multi-threading. Moreover making a runtime like V8 fast is much harder if you try to make it thread safe. JVMs have a long history of being fast in the presence of large scale threading but no WASM supporting VMs do. 3. No support for exceptions, apparently at least one failed attempt to add it. Even LLVM has support for exceptions. Again, no big deal if the future of the web is C99 but what a bad joke if it is. 4. No FFI of any use. 5. No dynamic code loading. 6. Tooling is poor or non-existent. 7. Ignoring these differences, WASM bytecode looks a lot like JVM bytecode e.g. is a stack based language that requires compilation client side via JITC to approach good performance. As far as I can tell it's a significant regression from what Java could do even 20 years ago. And don't start talking about security. WASM integrations already opened up critical security bugs in browsers: https://bugs.chromium.org/p/chromium/issues/detail?id=729991 https://bugs.chromium.org/p/chromium/issues/detail?id=729991 https://bugs.chromium.org/p/chromium/issues/detail?id=794091 https://bugs.chromium.org/p/chromium/issues/detail?id=794091 https://news.ycombinator.com/item?id=15712270 https://news.ycombinator.com/item?id=15712270 If you think WASM is magically immune to sandbox bugs, you're wrong.
- naasking 8y ago> WASM appears, to me eyes, to have numerous serious flaws that make me wonder why people are so excited about it. The reason to be excited about it is to have a universal sandbox to portably run untrusted code regardless of the source. That's unprecedented flexibility for something so widely deployed. Neither the JVM or the CLR provide such a sandbox for code that uses pointers. LLVM IR is not portable, is not sandboxed and is always in flux. As for your list of "flaws", they aren't flaws at all. A flaw is a feature that cannot be supported, even in principle. Everything you list are possible as extensions to the core type system. WASM was designed with efficient verification in mind, and with mechanized formal proofs as I point out at [1]. Java's verification was always a hack, and the mechanized proofs of Java's verification procedure never encompassed all JVM bytecodes, and full verification was always too costly to perform at runtime. Java has numerous security problems, not just with verification, but also vulnerabilities due to full abstraction failures. As I mentioned in [1], the security-focused Joe-E language explicitly chose to decompile JVM bytecode to plain Java to avoid all of the numerous documented full abstraction failures of the JVM [2]. The similarities between the stack-oriented bytecodes are entirely superficial. [1] https://news.ycombinator.com/item?id=17575111 https://news.ycombinator.com/item?id=17575111 [2] http://lambda-the-ultimate.org/node/3830 http://lambda-the-ultimate.org/node/3830