Optimizing compilers prove facts about your code (this index is always in range, this value is always a Smi) and delete the checks those facts make unnecessary. A wrong proof is an out-of-bounds access or a type confusion in optimized code. Learn to read Turbolizer graphs (--trace-turbo), to trigger optimization reliably (%PrepareFunctionForOptimization, %OptimizeFunctionOnNextCall) and to turn a mis-typed range into a corrupted array length.
Where to start
Before attacking TurboFan, watch it work: optimize a small function with %PrepareFunctionForOptimization and %OptimizeFunctionOnNextCall, run d8 with --trace-turbo, and open the JSON in Turbolizer. Find the typer's range for each node and the CheckBounds nodes it removes. For each challenge, find the phase the patch changes and write the smallest function whose typed range differs from its real value. Then turn that difference into an array length or index the compiler no longer checks. --trace-deopt tells you when your proof attempt was thrown away.
Reading
- Introduction to TurboFan (Jeremy Fetiveau): sea of nodes, the typer and bounds-check elimination, through a complete exploit.
- Modern attacks on the Chrome browser: optimizations and deoptimizations: how speculation and deoptimization work, and how later hardening changed JIT exploitation.
- Exploiting Logic Bugs in JavaScript JIT Engines (Phrack 70): saelo's introduction to JIT bugs, redundancy elimination and side effects, using CVE-2018-17463.
- Trashing the Flow of Data (Project Zero): a TurboFan element-kind confusion turned into a heap R/W, by Stephen Röttger.
- Getting RCE in Chrome with incorrect side effect in the JIT compiler (GitHub Security Lab): a modern, pointer-compressed TurboFan exploit end to end.
- Maglev: V8's Fastest Optimizing JIT: the mid-tier compiler that triforce and PlaidCTF's Maglev target.
- Turbolizer: how to build and use the graph viewer for
--trace-turbooutput.
Challenges
30-Day Scoreboard:
This scoreboard reflects solves for challenges in this module after the module launched in this dojo.
| Rank | Hacker | Badges | Score |