Justin Engler, Technical Director, NCC Group
Tyler Lukasiewicz, Security Consultant, NCC Group
WASM (WebAssembly) allows you to take code written elsewhere and run it in a browser.
Crypto minors and archive.org alike are starting to use web assembly.
Browsix is a project to implement POSIX interfaces in the browswer, and JsLinux has an entire OS in the browser. eWASM is a solution for ethereum contracts (an alternative to solidity). (and a bunch of other cool things)>
Remember when... Java Applets used to claim the same things (sandboxing, virtualization, code in browser)...
WebAssembly is a relatively small set of low-level instructions that are executed by browsers. It's a stack machine. You can push and pop things off the stack (to me the code looks a lot like lisp). We do a couple of walkthroughs of sample code - they created a table of function pointers (egads! it's like networking kernel programming).
WASM in the browser - it can't do anything on it's own (can't read memory, write to screen, etc). If you want it to do anything, you need to import/export memory/functionality/etc. Memory can be shared across instances of Wasm.
You can now go from a BOF (Buffer Over Flow) to XSS. Emscripten's API allows devs to reference the DOM from C/C++. CHaracter arrays being written to the DOM create the possibilyt of DOM-based XSS and can use a user-tainted value to overwrite a safe value. This type of attack likely won't be caught by any standard XSS scanners. As JS has control of the WASM memory and tables, XSS should give us control of any running WASM.
And this even creates new exploits here! We can now have a function pointer overflow. Emscripten has functions that run arbitrary code (emscripten_rn_script). Can take advantage of that as lont as it's loaded. They discovered that function tables are constant - across compilations and even on different machines.
You don't necessarily to go after the XSS here, but could use functions written by the developers as long as it has the same signature as the real one.
They also showed a service-side RCE (Remote Code Execution). Showed code in browser starting a process on the server.
Many mitigations from C/C++ won't work on WASM. THey could use things like ASLR and could use some library hardening. Effective mitigations include control flow integrity and function definitions and indexing (prevents ROP-style gadgets).
WASM did cover these in their security warning, in a buried paragraph. It should be mroe obvious.
If you can avoid emscripten_run_script and friends, run the optimizer (removes automatically included functions that might have een useful for control flow attacks), use control flow integrity (but it may be slower) and you still have to fix your C bugs!
There is whitepaper out - Security CHasms of WASM
Aladdin's Genie Bakes Up Some Crappy Quarantine Cake - Meanwhile, at the Agrabah Bakery… [image: Bill+Lep-FB-TP+cakes.jpg] [image: EH NOT ENOUGH.jpg] [image: Donna+Mar-FB-TP+rolls.jpg] [image: STILL NOT ENOUGH...