The Hole, Maps and the Garbage Collector


Browser Exploitation: A CTF Study Path.

Some V8 bugs are not about bounds at all. Internal sentinel values like TheHole were never meant to reach JavaScript; once one does, data structures such as Map misbehave in exploitable ways. A missing write barrier lets the garbage collector free an object that is still referenced. These challenges teach V8's heap layout, its generational GC and how to groom it.

Where to start

Learn the heap before the bugs. With --trace-gc, watch objects move from the young generation (semi-space scavenges) to old space. Use %DebugPrint before and after a gc() (--expose-gc) to see addresses change. For the hole challenges, find which internal value reaches JavaScript and which data structure trusts it. A leaked hole in a Map is a known way to a corrupted length. For write-barrier and UAF bugs, work out what the GC thinks is dead, then groom so the freed slot is reused by an object you control.

Reading



Challenges

HITCON CTF 2022 · difficulty ★★★☆☆ · module: The Hole, Maps and the Garbage Collector

A leaked hole and Map.prototype.delete. Part 1 of HITCON's Fourchain.

Engine: V8 (d8), commit 63cb7fb817e6

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, d8_strip_global.patch, snapshot_blob.bin.

Original challenge

Description

There's a hole in the program ?

Well I'm sure it's not that of a big deal, after all it's just a small hole that won't do any damage right ?

... Right 😨 ?

Points

268

Solves

25

Credits

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

osu!gaming CTF 2024 · difficulty ★★★☆☆ · module: The Hole, Maps and the Garbage Collector

RegExp lastIndex and a write barrier that is not there.

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 /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

You’re probably accessing the osu website with Chromium, right?

Points

265

Solves

17

Credits

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

NexHunt CTF 2025 · difficulty ★★★☆☆ · module: The Hole, Maps and the Garbage Collector

Async iterators, promises and species: who decides what object comes back?

Engine: V8 (d8), 14.4.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 --no-memory-protection-keys 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.

This machine's CPU may have memory protection keys (PKU), which make V8 write-protect WebAssembly code; --no-memory-protection-keys (not an original flag) restores the original server's behaviour.

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 --no-memory-protection-keys ~/exploit.js
gdb -q --args ./d8 --allow-natives-syntax --no-memory-protection-keys ~/exploit.js

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

Original challenge

Description

Another promise he breaks.
iterating through shadows,
in darkness lurking async.
receiver hopes disposed,
but None are left to resolve,
and so the void constructs.

Connection Info : 

Points

449

Solves

10

Credits

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

FCSC 2024 · difficulty ★★★★☆ · module: The Hole, Maps and the Garbage Collector

A patch that hands JavaScript the hole.

Engine: V8 (d8), 10.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 /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, holy-cow.patch, snapshot_blob.bin.

Original challenge

Description

Our adventure began, as is often the case with this kind of project, with a chat over a drink. All of us more tipsy than the last, but with a common resolution: "Let's make our own web browser!

Once half sobered up, we decided to start by choosing the right Javascript engine. The V8 engine is our first choice, as it has the advantage of being open source. Your task today is to check, using the git patch and the supplied executable, that everything is in order. To solve the challenge, you need to read the flag.txt file.

Points

Unknown

Solves

Unknown

Credits

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

DownUnderCTF 2025 · difficulty ★★★★☆ · module: The Hole, Maps and the Garbage Collector

Entangled objects, and a Flag object that only gives up the flag in the right state. No code execution needed.

Engine: V8 (d8), 14.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 (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 patched d8 loads the file named by $FLAG into its Flag object once you corrupt it into the right state.

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): challenge.diff, d8.gz, snapshot_blob.bin.

Original challenge

Description

What will you do now that you are not so isolated?

NOTE: This is a revenge challenge of entangled which fixes an unintended solution in the deployment. The Dockerfile has been updated to make the flag filename random, the challenge.diff file has been fixed and d8 has been rebuilt.

Regards,
grub

AU: 
US: 

Points

359

Solves

11

Credits


30-Day Scoreboard:

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

Rank Hacker Badges Score