Your first V8 bugs: a patched builtin or a corrupted array length lets you read and write past the end of a JavaScript array. From there the path is always the same, and worth learning by heart: leak an object's address (addrof), forge a fake object (fakeobj), build an arbitrary read/write, and overwrite code that is about to run (classically the RWX page of a WebAssembly instance) with shellcode. Learn pointer compression and tagged values with %DebugPrint before you start.
Where to start
Start with Baby Browser. Run d8 --allow-natives-syntax, make a few arrays and objects, and %DebugPrint them. Find the map, the elements pointer and the length in memory with gdb (job, x/8gx), and work out how pointer compression turns a 32-bit tagged value into an address. Then write addrof and fakeobj from the OOB, an arbitrary read/write on top of them, and finally overwrite a WebAssembly instance's RWX code. Keep the result as a template: most later challenges only change the first step.
Reading
- Fast properties in V8: maps (hidden classes), in-object vs. out-of-object properties and elements: the layout you corrupt.
- JavaScript engine fundamentals: Shapes and Inline Caches: why every object has a map/shape, explained engine-neutrally.
- Pointer Compression in V8: tagged Smis and compressed pointers, so your addresses and fake objects come out right.
- Chrome Browser Exploitation, Part 1: Introduction to V8 and JavaScript Internals: a long, careful walk through V8's object model with gdb.
- Two Birds with One Stone: An Introduction to V8 and JIT Exploitation: the addrof/fakeobj to arbitrary read/write to Wasm shellcode chain, step by step.
- V8 tools/gdbinit: the
joband related gdb commands for printing V8 heap objects.
Challenges
30-Day Scoreboard:
This scoreboard reflects solves for challenges in this module after the module launched in this dojo.
| Rank | Hacker | Badges | Score |