JIT Compilers: TurboFan and Maglev


Browser Exploitation: A CTF Study Path.

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



Challenges

LINE CTF 2021 · difficulty ★★★☆☆ · module: JIT Compilers: TurboFan and Maglev

A TurboFan patch about minus zero and signed overflow.

Engine: V8 (d8), 9.0.180

Running it

Put your exploit at /home/hacker/exploit.js and run /challenge/run. It passes it to the engine as a file, with the original challenge's flags: d8 exploit.js. The engine runs as an unprivileged user (uid 1001) that cannot read /flag.

Once your code runs inside the engine (shellcode, or a shell it spawns), execute /readflag to print the flag, as in the original challenge.

The original's flag file is replaced by /readflag: run it from the shell or shellcode your exploit gets.

print is removed from this build: use console.log.

Debugging it

Debug your own copy (no root needed; --allow-natives-syntax enables %DebugPrint and %SystemBreak, remove those calls before the real run):

mkdir -p ~/dbg && cd ~/dbg && cp -r /challenge/. . && gunzip -fr . && chmod +x d8
./d8 --allow-natives-syntax ~/exploit.js
gdb -q --args ./d8 --allow-natives-syntax ~/exploit.js

Files in /challenge (executables are gzip-compressed): d8.gz, icudtl.dat, overflow.patch, snapshot_blob.bin.

Original challenge

Description

Another babychrome

Points

445

Solves

8

Credits

  • Challenge author(s): not recorded (credit goes to the LINE CTF 2021 organizers)
  • Compiled by: mito753 in Browser-Exploit-Dojo, which also has the original handout, exploits and writeups

TFC CTF 2025 · difficulty ★★★☆☆ · module: JIT Compilers: TurboFan and Maglev

A new string builtin and the types TurboFan believes it returns.

Engine: V8 (d8), 13.7.0

Running it

Put your exploit at /home/hacker/exploit.js and run /challenge/run. It passes it to the engine as a file, with the original challenge's flags: d8 --allow-natives-syntax --shell exploit.js. The engine runs as an unprivileged user (uid 1001) that cannot read /flag.

Once your code runs inside the engine (shellcode, or a shell it spawns), execute /readflag to print the flag, as in the original challenge.

The original had two flags. The first, from String.prototype.giveMeFlag(), is compiled into the binary and is a fake in the handout build, so here the flag is the second one: get code execution and run /readflag. print is removed from this build: use console.log.

Debugging it

Debug your own copy (no root needed; --allow-natives-syntax enables %DebugPrint and %SystemBreak, remove those calls before the real run):

mkdir -p ~/dbg && cd ~/dbg && cp -r /challenge/. . && gunzip -fr . && chmod +x d8
./d8 --allow-natives-syntax --shell ~/exploit.js
gdb -q --args ./d8 --allow-natives-syntax --shell ~/exploit.js

Files in /challenge (executables are gzip-compressed): d8.gz, patch.diff, snapshot_blob.bin.

Original challenge

Description

Predict the future!

Note: This is part 2. Use this instance for getting both flags.

Points

493

Solves

4

Credits

  • Challenge author(s): mcsky23, for TFC CTF 2025
  • Compiled by: mito753 in Browser-Exploit-Dojo, which also has the original handout, exploits and writeups

ASIS CTF Quals 2021 · difficulty ★★★★☆ · module: JIT Compilers: TurboFan and Maglev

indexOf, as seen by the typer, plus a bounds check that went missing.

Engine: V8 (d8), 9.7.0

Running it

Put your exploit at /home/hacker/exploit.js and run /challenge/run. It passes it to the engine as a file, with the original challenge's flags: d8 exploit.js. The engine runs as an unprivileged user (uid 1001) that cannot read /flag.

Once your code runs inside the engine (shellcode, or a shell it spawns), execute /readflag to print the flag, as in the original challenge.

The original closed the engine's stdout and stderr; here they stay open. The original's flag file is replaced by /readflag: run it from the shell or shellcode your exploit gets.

Debugging it

Debug your own copy (no root needed; --allow-natives-syntax enables %DebugPrint and %SystemBreak, remove those calls before the real run):

mkdir -p ~/dbg && cd ~/dbg && cp -r /challenge/. . && gunzip -fr . && chmod +x d8
./d8 --allow-natives-syntax ~/exploit.js
gdb -q --args ./d8 --allow-natives-syntax ~/exploit.js

Files in /challenge (executables are gzip-compressed): d8.gz, diff.patch, snapshot_blob.bin.

Original challenge

Description

We have a good book for V8 lovers, best book of 2021 😜

Note: If you want to build debug version, just check out the latest from v8 git.

Points

316

Solves

8

Credits

  • Challenge author(s): not recorded (credit goes to the ASIS CTF Quals 2021 organizers)
  • Compiled by: mito753 in Browser-Exploit-Dojo, which also has the original handout, exploits and writeups

UIUCTF 2021 · difficulty ★★★★☆ · module: JIT Compilers: TurboFan and Maglev

String.prototype.indexOf range inference, in a custom embedder that reads the script from stdin.

Engine: V8 (custom embedder), 9.1.269.36

Running it

Put your exploit at /home/hacker/exploit.js and run /challenge/run. It feeds it to the engine on stdin, as the original server did (your shell then gets the terminal), with the original challenge's flags: v8_hello_world. The engine runs as an unprivileged user (uid 1001) that cannot read /flag.

Once your code runs inside the engine (shellcode, or a shell it spawns), execute /readflag to print the flag, as in the original challenge.

As on the original server, the custom v8_hello_world embedder reads the script from stdin: end it with a // END line. The original's shellcode read /flag.txt; here execute /readflag instead. exploit.js.template is the organizers' scaffold.

This embedder's console.log prints nothing: use print.

Debugging it

Debug your own copy (no root needed; --allow-natives-syntax enables %DebugPrint and %SystemBreak, remove those calls before the real run):

mkdir -p ~/dbg && cd ~/dbg && cp -r /challenge/. . && gunzip -fr . && chmod +x v8_hello_world
./v8_hello_world --allow-natives-syntax < ~/exploit.js
gdb -q --args ./v8_hello_world --allow-natives-syntax    # then: run < ~/exploit.js

Files in /challenge (executables are gzip-compressed): diff.patch, exploit.js.template, snapshot_blob.bin, v8_hello_world.gz.

Original challenge

Description

have fun with some v8 pwn. instructions in handout.

cat exploit.js | 

Points

464

Solves

7

Credits

  • Challenge author(s): samsonites, for UIUCTF 2021
  • Compiled by: mito753 in Browser-Exploit-Dojo, which also has the original handout, exploits and writeups

bi0sCTF 2024 · difficulty ★★★★☆ · module: JIT Compilers: TurboFan and Maglev

Reflect.construct and the maps TurboFan infers for it.

Engine: V8 (d8), 12.2.0

Running it

Put your exploit at /home/hacker/exploit.js and run /challenge/run. It passes it to the engine as a file, with the original challenge's flags: d8 exploit.js. The engine runs as an unprivileged user (uid 1001) that cannot read /flag.

Once your code runs inside the engine (shellcode, or a shell it spawns), execute /catflag to print the flag, as in the original challenge.

Debugging it

Debug your own copy (no root needed; --allow-natives-syntax enables %DebugPrint and %SystemBreak, remove those calls before the real run):

mkdir -p ~/dbg && cd ~/dbg && cp -r /challenge/. . && gunzip -fr . && chmod +x d8
./d8 --allow-natives-syntax ~/exploit.js
gdb -q --args ./d8 --allow-natives-syntax ~/exploit.js

Files in /challenge (executables are gzip-compressed): d8.gz, snapshot_blob.bin, v8.patch.

Original challenge

Description

Looks like we have some reliability issues here; what could possibly go wrong?

Points

955

Solves

10

Credits

  • Challenge author(s): spektre, for bi0sCTF 2024
  • Compiled by: mito753 in Browser-Exploit-Dojo, which also has the original handout, exploits and writeups

TRX CTF 2026 · difficulty ★★★★☆ · module: JIT Compilers: TurboFan and Maglev

A Maglev type confusion, and a new builtin that guards the flag behind three string checks.

Engine: V8 (d8), 14.9.0

Running it

Put your exploit at /home/hacker/exploit.js and run /challenge/run. It passes it to the engine as a file, with the original challenge's flags: d8 exploit.js (environment: FLAG=/flag). The engine runs as an unprivileged user (uid 1001) that cannot read /flag.

As in the original challenge, the engine itself may read the flag (/flag): the goal is to make it reveal it.

As in the original, the new triforce() builtin returns the file named by $FLAG if you get past its checks.

Debugging it

Debug your own copy (no root needed; --allow-natives-syntax enables %DebugPrint and %SystemBreak, remove those calls before the real run):

mkdir -p ~/dbg && cd ~/dbg && cp -r /challenge/. . && gunzip -fr . && chmod +x d8
FLAG=/flag ./d8 --allow-natives-syntax ~/exploit.js
gdb -q -ex 'set environment FLAG=/flag' --args ./d8 --allow-natives-syntax ~/exploit.js

Files in /challenge (executables are gzip-compressed): d8.gz, patch.sh, sbx.patch, triforce.patch.

Original challenge

Description

Maglev (derived from magnetic levitation) is a system of rail transport whose rolling stock is levitated by electromagnets rather than rolled on wheels, eliminating rolling resistance.

Points

286

Solves

14

Credits

  • Challenge author(s): Erge, for TRX CTF 2026
  • Compiled by: mito753 in Browser-Exploit-Dojo, which also has the original handout, exploits and writeups

idekCTF 2021 · difficulty ★★★★★ · module: JIT Compilers: TurboFan and Maglev

What happens when TurboFan is stopped from deoptimizing.

Engine: V8 (d8), 9.9.0

Running it

Put your exploit at /home/hacker/exploit.js and run /challenge/run. It passes it to the engine as a file, with the original challenge's flags: d8 exploit.js. The engine runs as an unprivileged user (uid 1001) that cannot read /flag.

Once your code runs inside the engine (shellcode, or a shell it spawns), execute /readflag to print the flag, as in the original challenge.

The original's shellcode read /flag.txt; here execute /readflag instead.

Debugging it

Debug your own copy (no root needed; --allow-natives-syntax enables %DebugPrint and %SystemBreak, remove those calls before the real run):

mkdir -p ~/dbg && cd ~/dbg && cp -r /challenge/. . && gunzip -fr . && chmod +x d8
./d8 --allow-natives-syntax ~/exploit.js
gdb -q --args ./d8 --allow-natives-syntax ~/exploit.js

Files in /challenge (executables are gzip-compressed): d8.gz, diff.patch, snapshot_blob.bin.

Original challenge

Description

Everyone loves browser pwn. Go ham 😄 flag is at /flag.txt 

Points

499

Solves

3

Credits

  • Challenge author(s): JoshL#4217, for idekCTF 2021
  • Compiled by: mito753 in Browser-Exploit-Dojo, which also has the original handout, exploits and writeups

35C3 CTF 2018 · difficulty ★★★★★ · module: JIT Compilers: TurboFan and Maglev

Math.expm1 and minus zero, a classic. The flag lives in another realm.

Engine: V8 (d8), 7.3.0

Running it

Put your exploit at /home/hacker/exploit.js and run /challenge/run. It feeds it to the engine on stdin, as the original server did (your shell then gets the terminal), with the original challenge's flags: d8 worker.js. The engine runs as an unprivileged user (uid 1001) that cannot read /flag.

As in the original challenge, the engine itself may read the flag (/flag): the goal is to make it reveal it.

As on the original server, d8 worker.js reads stdin: the first line must be SheeK6ul, the second is your exploit, run as ONE line in a second realm with the d8 globals stripped. worker.js has already read /flag into the first realm's global flag: escape the realm to read it.

Debugging it

Debug your own copy (no root needed; --allow-natives-syntax enables %DebugPrint and %SystemBreak, remove those calls before the real run):

mkdir -p ~/dbg && cd ~/dbg && cp -r /challenge/. . && gunzip -fr . && chmod +x d8
./d8 --allow-natives-syntax worker.js < ~/exploit.js
gdb -q --args ./d8 --allow-natives-syntax worker.js    # then: run < ~/exploit.js

Files in /challenge (executables are gzip-compressed): d8-strip-globals.patch, d8.gz, natives_blob.bin, open_files_readonly.patch, revert-bugfix-880207.patch, snapshot_blob.bin, worker.js.

Original challenge

Description

Krautflare workers are the newest breakthrough in serverless computing. And since we're taking security very seriously, we're even isolating customer workloads from each other!

For our demo, we added an ancient v8 vulnerability to show that it's un-exploitable! See https://bugs.chromium.org/p/project-zero/issues/detail?id=1710 for details. Fortunately, that was the last vulnerability in v8 and our product will be secure from now on.

Files at https://35c3ctf.ccc.ac/uploads/krautflare-33ce1021f2353607a9d4cc0af02b0b28.tar. Challenge at: 

Note: This challenge is hard! It's made for all the people who asked for a hard Chrome pwnable in this survey at https://twitter.com/_tsuro/status/1057676059586560000. Though the bug linked above gives you a rough walkthrough how to exploit it, you'll just have to figure out the details. I hope you paid attention in your compiler lectures :). Good luck, you have been warned!

Points

451

Solves

3

Credits

  • Challenge author(s): Stephen Röttger (_tsuro), for 35C3 CTF 2018 (source)
  • Compiled by: mito753 in Browser-Exploit-Dojo, which also has the original handout, exploits and writeups

CrewCTF 2023 · difficulty ★★★★★ · module: JIT Compilers: TurboFan and Maglev

An incorrect type in TurboFan's typer. No public writeup.

Engine: V8 (d8), 11.6.0

Running it

Put your exploit at /home/hacker/exploit.js and run /challenge/run. It passes it to the engine as a file, with the original challenge's flags: d8 exploit.js. The engine runs as an unprivileged user (uid 1001) that cannot read /flag.

Once your code runs inside the engine (shellcode, or a shell it spawns), execute /readflag to print the flag, as in the original challenge.

The original's d8 kept read(), and the flag was readable by its user, so a one-line read was an unintended solve; here the engine's user cannot read the flag. The original's flag file is replaced by /readflag: run it from the shell or shellcode your exploit gets.

Debugging it

Debug your own copy (no root needed; --allow-natives-syntax enables %DebugPrint and %SystemBreak, remove those calls before the real run):

mkdir -p ~/dbg && cd ~/dbg && cp -r /challenge/. . && gunzip -fr . && chmod +x d8
./d8 --allow-natives-syntax ~/exploit.js
gdb -q --args ./d8 --allow-natives-syntax ~/exploit.js

Files in /challenge (executables are gzip-compressed): chall.patch, d8.gz, snapshot_blob.bin.

Original challenge

Description

I hope this chall make you learn something new, this is good for an introduction into browser exploitation

Points

1000

Solves

1

Credits

  • Challenge author(s): Linz, for CrewCTF 2023
  • Compiled by: mito753 in Browser-Exploit-Dojo, which also has the original handout, exploits and writeups

PlaidCTF 2024 · difficulty ★★★★★ · module: JIT Compilers: TurboFan and Maglev

Maglev tracks an array's length and forgets to update it.

Engine: V8 (d8), 12.4.254.8

Also uses techniques from: Escaping the V8 Sandbox (06-sandbox).

Running it

Put your exploit at /home/hacker/exploit.js and run /challenge/run. It passes it to the engine as a file, with the original challenge's flags: d8 exploit.js. The engine runs as an unprivileged user (uid 1001) that cannot read /flag.

Once your code runs inside the engine (shellcode, or a shell it spawns), execute /readflag to print the flag, as in the original challenge.

The original's flag file is replaced by /readflag: run it from the shell or shellcode your exploit gets.

Debugging it

Debug your own copy (no root needed; --allow-natives-syntax enables %DebugPrint and %SystemBreak, remove those calls before the real run):

mkdir -p ~/dbg && cd ~/dbg && cp -r /challenge/. . && gunzip -fr . && chmod +x d8
./d8 --allow-natives-syntax ~/exploit.js
gdb -q --args ./d8 --allow-natives-syntax ~/exploit.js

Files in /challenge (executables are gzip-compressed): d8.gz, diff.patch, snapshot_blob.bin.

Original challenge

Description

Upon entering the station, the doors shift and warp and end up in different locations. Auditory reading suggest the presence of spirits, which may be controlling the phenomenon.
Hypotheses. Traditional haunting-type situation
Notes.
Please send help, I've been trapped here all week!

Points

300

Solves

Unknown

Credits

  • Challenge author(s): madStacks, for PlaidCTF 2024
  • Compiled by: mito753 in Browser-Exploit-Dojo, which also has the original handout, exploits and writeups

SekaiCTF 2024 · difficulty ★★★★★ · module: JIT Compilers: TurboFan and Maglev

TurboFan's context specialization, one level too deep. The hardest JIT challenge here.

Engine: V8 (d8), 13.0.0

Running it

Put your exploit at /home/hacker/exploit.js and run /challenge/run. It passes it to the engine as a file, with the original challenge's flags: d8 exploit.js. The engine runs as an unprivileged user (uid 1001) that cannot read /flag.

Once your code runs inside the engine (shellcode, or a shell it spawns), execute /home/ctf/getflag to print the flag, as in the original challenge.

print is removed from this build: use console.log.

Debugging it

Debug your own copy (no root needed; --allow-natives-syntax enables %DebugPrint and %SystemBreak, remove those calls before the real run):

mkdir -p ~/dbg && cd ~/dbg && cp -r /challenge/. . && gunzip -fr . && chmod +x d8
./d8 --allow-natives-syntax ~/exploit.js
gdb -q --args ./d8 --allow-natives-syntax ~/exploit.js

Files in /challenge (executables are gzip-compressed): d8.gz, icudtl.dat, patch.diff, snapshot_blob.bin.

Original challenge

Description

Tinker with the optimizations, watch as boundaries blur and opportunities arise.

❖ Note
Once you have successfully exploited the challenge, you can run /home/ctf/getflag to retrieve your flag.

Points

500

Solves

1

Credits

  • Challenge author(s): rycbar, for SekaiCTF 2024
  • Compiled by: mito753 in Browser-Exploit-Dojo, which also has the original handout, exploits and writeups

30-Day Scoreboard:

This scoreboard reflects solves for challenges in this module after the module launched in this dojo.

Rank Hacker Badges Score