Builtins are where JavaScript's dynamic semantics meet hand-written C++ and Torque. A user-defined valueOf can run in the middle of a builtin and change the array it is working on; an array can switch elements kind behind a fast path's back; a typed array can be detached mid-copy. These challenges teach you to read a builtin, spot the assumption it makes, and break it from JavaScript. The older engines here (V8 6-9) predate pointer compression or the sandbox, so expect full 64-bit pointers and, in some, libc-based endings.
Where to start
Read the patch first, then the builtin it changes (in src/builtins/, as C++, CSA or Torque) and list what it assumes about its receiver and arguments: the length, the elements kind, that the buffer is attached. Then look for a way to run your own JavaScript in the middle (valueOf, toString, getters, Symbol.species, proxies) and break that assumption. The 2018-2020 engines here have full 64-bit pointers and no sandbox, so check the version before you reuse your module 01 template.
Reading
- Elements kinds in V8: the PACKED/HOLEY, SMI/DOUBLE/ELEMENTS lattice that fast paths depend on.
- V8 Torque user manual: how to read the Torque builtins most of these patches touch.
- Attacking JavaScript Engines: A case study of JavaScriptCore and CVE-2016-4622 (Phrack 70): the classic valueOf reentrancy bug in a builtin, and where addrof/fakeobj come from.
- Simple bugs with complex exploits (elttam): a Torque rewrite that dropped one length check (Project Zero issue 2046), and how the TurboFan typer turned it into an OOB array.
- A Bug's Life: CVE-2021-21225 (Brendon Tiszka): an out-of-bounds read in Array.prototype.concat taken to renderer code execution.
Challenges
30-Day Scoreboard:
This scoreboard reflects solves for challenges in this module after the module launched in this dojo.
| Rank | Hacker | Badges | Score |