5 ms·
Java failed to deliver safe sandbox. Browsers finally booted it because of numerous vulnerabilities. For me wasm looks exactly like another JVM attempt, but it'
by vbezhenar 7y ago
Java failed to deliver safe sandbox. Browsers finally booted it because of numerous vulnerabilities. For me wasm looks exactly like another JVM attempt, but it's a good thing, because the idea is good, we just need better implementation.
Now if I don't need sandbox, it's going to be a tougher sell. But who knows, may be it'll outperform JVM on bare metal some day.
- pjmlp 7y agoWebAssembly also has its security issues. Lack of bounds checking for multiple data accesses mapped to the same linear memory block.
- gridlockd 7y agoHow would you enforce bounds checking while supporting unsafe languages?
- pjmlp 7y agoThat is exactly the point, don't advertise WebAssembly as safe bytecode, if unsafe languages are part of the picture without any kind of control. Secondly, nor ISO C or ISO C++ forbid implementations that do bounds checking by default. In fact that is what most modern compilers do by default in debug mode. Finally look at memory tagging in Solaris SPARC ADI, Apple iOS or the upcoming ARM extensions support on Android for how bounds checking is enforced at hardware level while supporting unsafe languages.
- saagarjha 7y ago> In fact that is what most modern compilers do by default in debug mode. Assuming that “debug mode” is -g or equivalent, then I have not seen a modern compiler that does this.
- swiley 7y agoHe’s probably talking about instrumentation (valgrind, ASAN etc.) That’s part of why running instrumented code feels like running python.
- pjmlp 7y agoNo, just plain bounds checking on C++ standard library and integration with hardware memory tagging when available.
- pjmlp 7y agoThen get to use Visual C++, which does bounds checking on collection types (array, string, vector,...), memory dumps leaks at exit. Or Solaris SPARC and iOS compilers that make use of hardware memory tagging. Clang and GCC do need extra flags to enable FORTIFY mode though. However on Android FORTIFY is now a requirement and future versions will make use of memory tagging on ARM hardware. So ironically something like Android does have a better sandboxing model as WebAssembly.
- saagarjha 7y ago> iOS compilers that make use of hardware memory tagging No iOS devices ship with ARMv8.5, so while I think compilers are implementing this today I am not sure if Xcode ships with this or if it's functional. > So ironically something like Android does have a better sandboxing model as WebAssembly. …you're not understanding what sandboxing means.
- pjmlp 7y agoApple has their own CPUs, https://developer.apple.com/documentation/security/preparing_your_app_to_work_with_pointer_authentication https://developer.apple.com/documentation/security/preparing... I do understand what sandboxing means, and how WebAssembly advocates keep overselling its security capabilities, by ignoring issues that other bytecode formats have taken a more serious approach, already in the mid-60's.
- connicpu 7y agoThe point of the byte code being safe is that no operations performed by WASM code could cause a memory unsafety bug from the perspective outside the sandbox. If your code violates its own memory rules then it will only mess up the logical state of its VM memory chunk, and probably produce an incorrect result. The same thing can happen in any safe language if you access the wrong indexes in an array because of a logical error in your code
- pjmlp 7y agoThat incorrect results might lead to security exploits, the same way that browsers now get exploited by taking advantage how their VMs work. So hand waving such security issues is rather strange, when it should be the top concern when selling an infrastructure to run code from unknown sources.
- afiori 7y ago> the same way that browsers now get exploited by taking advantage how their VMs work The difference is if the exploit is run by the browser or the VM. If the VM has a logic error, gives back the wrong result, the browser decides to trust the result and be exploited then it is a browser bug; not a sandbox issue. The other situation is when a browser spins up a VM to add 2 and 2 but then the VM starts downloading malicious files from the internet. No kind of safe language can avoid the first class, wasm avoids the second.
- BubRoss 7y agoCan you link to an example of this exploit? Does javascript suffer from the same problem?
- pjmlp 7y agoAny kind of typical C memory corruption that you can think of that fails to validate the buffer sizes that you give as parameters. WebAssembly memory access bytecodes only do bounds checking of the linear memory block that gets allocated to the module. You then do your own memory management taking subsets from that memory block and assigning it to the respective internal heap allocations or global memory blocks. So you just need to have a couple of structs or C string/arrays, living alongside each other and overwrite one of them by writing too much data due to miscalculations of the memory segment holding the data.
- BubRoss 7y agoWouldn't that just corrupt your own program? If there is a security flaw you could demonstrate it.
- pjmlp 7y agoExcept that you load code from multiple sources and one could eventually have a piece of JavaScript code that makes use of such behaviour to have access to some feature that by default is not accessible. I rather let WebAssembly turn out to be the next Flash, when black hats start looking at it with the same care they had before, no need to waste cycles myself, as it is a lost battle against WebAssembly advocacy.
- maoeurk 7y ago> Except that you load code from multiple sources and one could eventually have a piece of JavaScript code that makes use of such behaviour to have access to some feature that by default is not accessible. With all due respect, that doesn't make WebAssembly unsafe in any way. By the same logic, any program that takes any kind of user input is unsafe because the program could trust data it should not trust and then execute incorrectly. If a program does not validate (untrusted) input then it is the program's fault. Not the input's fault or the input-producing-method's fault. I agree with where you're coming from though. People are going to make mistakes and if the average developer has to interpret blobs of bits as meaningful data structures just to get things done, then we are going to see a lot of these types of problems. However, there are already projects in the works that are automating the $LANGUAGE to Wasm glue code which should completely mitigate this issue.
- saagarjha 7y agoRight, but this isn’t a sandboxing issue.
- zekrioca 7y agoTechnically I agree, but nowadays with 5G+Edge computing, where low latency application requirements are essential, there will be other performance constraints not tackled by Java that needs new solutions. Previous JVM attempts mostly focused on "write once, run anywhere". But now, "anywhere" means "anywhere and quickly" :)
- vbezhenar 7y agoWith proper implementation JVM could be kept running and loading applet would be extremely fast.