Builtin Bugs: Coercion, Reentrancy and Elements Kinds


Browser Exploitation: A CTF Study Path.

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



Challenges

Null CTF 2025 · difficulty ★★☆☆☆ · module: Builtin Bugs: Coercion, Reentrancy and Elements Kinds

A builtin that converts its argument to a number at the wrong moment.

Engine: V8 (d8), 14.5.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 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, patch.diff, snapshot_blob.bin.

Original challenge

Description

I usually find myself moving around elements in an array, so I thought I should make a built-in function for that.

Original commit: f91f6775b20929d862d7e9c508139466e2102d96

Points

497

Solves

10

Credits

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

Securinets CTF Quals 2025 · difficulty ★★☆☆☆ · module: Builtin Bugs: Coercion, Reentrancy and Elements Kinds

Array length bookkeeping that does not survive user code running in the middle.

Engine: V8 (d8), 12.8.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 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, patch, snapshot_blob.bin.

Original challenge

Description

i ran out of descriptions . Just solve it ig ??!!

Points

487

Solves

14

Credits

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

UTCTF 2025 · difficulty ★★☆☆☆ · module: Builtin Bugs: Coercion, Reentrancy and Elements Kinds

An elements-kind transition that goes somewhere it should not. A starter poc.js is included.

Engine: V8 (d8), 12.8.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 was a d8 REPL on a socket; the challenge text says to run ./d8 ./poc.js, which is what happens here. 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, patch, snapshot_blob.bin.

Original challenge

Description

Last year, your internship at E-Corp (Evil Corp) ended with a working router RCE exploit. Leadership was very impressed. As a result, we chose to extend a return offer. We used your exploit to get a MiTM position on routers around the world. Now, we want to be able to use that MiTM position to exploit browsers to further our world domination plans! This summer, you will need to exploit Chrome!

One of our vulnerability researchers has discovered a new type confusion bug in Chrome. It turns out, a type confusion can be evoked by calling .confuse() on a PACKED_DOUBLE_ELEMENTS or PACKED_ELEMENTS array. The attached poc.js illustrates an example. You can run it with ./d8 ./poc.js. Once you have an RCE exploit, you will find a file with the flag in the current directory. Good luck and have fun!

Points

991

Solves

31

Credits

  • Challenge author(s): Aadhithya (@aadhi0319 on discord), for UTCTF 2025
  • Compiled by: mito753 in Browser-Exploit-Dojo, which also has the original handout, exploits and writeups

DownUnderCTF 2022 · difficulty ★★☆☆☆ · module: Builtin Bugs: Coercion, Reentrancy and Elements Kinds

A fast path in Array.prototype.concat; the exploit must fit on one line.

Engine: V8 (d8), 10.6.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 --no-wasm-write-protect-code-memory worker.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.

As on the original server, worker.js reads ONE line from stdin and evaluates it in a fresh Realm: keep your exploit on a single line. 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 --no-wasm-write-protect-code-memory worker.js < ~/exploit.js
gdb -q --args ./d8 --allow-natives-syntax --no-wasm-write-protect-code-memory worker.js    # then: run < ~/exploit.js

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

Original challenge

Description

I just made my first contribution to V8! The base commit hash is 1e98dd917ec4e8234174eea326fe8cf8fa283d2f.

Points

499

Solves

10

Credits

  • Challenge author(s): sradley#1448, for DownUnderCTF 2022
  • Compiled by: mito753 in Browser-Exploit-Dojo, which also has the original handout, exploits and writeups

0CTF/TCTF 2020 Quals · difficulty ★★★☆☆ · module: Builtin Bugs: Coercion, Reentrancy and Elements Kinds

TypedArray.prototype.set and an ArrayBuffer that is not what it used to be. Ends with libc rather than Wasm.

Engine: V8 (d8), 8.5.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 ran on Ubuntu 18.04 (glibc 2.27): libc offsets in public solves need redoing for this image's glibc 2.31. 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, snapshot_blob.bin, tctf.diff.

Original challenge

Description

It's v8, but it's not a typical v8, it's CTF v8! Please enjoy pwning this d8 :)


Attachment here

Enviroment: Ubuntu18.04

Update: If you want to build one for debugging, please git checkout f7a1932ef928c190de32dd78246f75bd4ca8778b

Points

282

Solves

29

Credits

  • Challenge author(s): Gengming Liu, for 0CTF/TCTF 2020 Quals (source)
  • Compiled by: mito753 in Browser-Exploit-Dojo, which also has the original handout, exploits and writeups

S㎩mAndFlags 2020 · difficulty ★★★☆☆ · module: Builtin Bugs: Coercion, Reentrancy and Elements Kinds

The only change is an innocent command-line flag: --allow-natives-syntax. Find a native that trusts its arguments.

Engine: V8 (d8), 8.1.307.31

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 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): 0001-Remove-globals.patch, d8.gz, snapshot_blob.bin.

Original challenge

Description

Your mission, should you choose to accept it, is to exploit this tiny proof-of-concept JavaScript engine, called v8, that I wrote for a high-school assignment. I removed some stuff to make it more interesting and added an innocent little command-line flag, --allow-natives-syntax, to make it easier on you. See the build.sh file for helpful information.

Server: 
Note: this is not an nday or 0day challenge.

Points

312+21

Solves

8

Credits

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

PlaidCTF 2018 · difficulty ★★★★☆ · module: Builtin Bugs: Coercion, Reentrancy and Elements Kinds

Array.from on a 2018 V8 (before pointer compression), with the output thrown away on the original server.

Engine: V8 (d8), 6.6.346.11

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 --max-semi-space-size=4096 --max-old-space-size=8192 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 discarded the engine's output (only the exit code came back), so its solves used a reverse shell; here the terminal stays attached, so a shell spawned by your shellcode works directly. print is removed from this build (with read, load, Realm, ...): 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 --max-semi-space-size=4096 --max-old-space-size=8192 ~/exploit.js
gdb -q --args ./d8 --allow-natives-syntax --max-semi-space-size=4096 --max-old-space-size=8192 ~/exploit.js

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

Original challenge

Description

Roll a d8 and win your game. 

Last year, hackers successfully exploited Chakrazy. 
This time, we came back with d8 powered by V8 JavaScript engine. 

You can download relevant material here. 

This might only be helpful to Google employees... or is it? https://crbug.com/821137

Points

350

Solves

8

Credits

  • Challenge author(s): not recorded (credit goes to the PlaidCTF 2018 organizers)
  • 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