eBPF, JITs and In-Kernel Interpreters


Kernel Exploitation: A CTF Study Path.

The kernel runs user-supplied programs: eBPF (checked by the verifier, then JIT-compiled), classic BPF for seccomp, and sometimes custom interpreters. A verifier that misjudges a register's range gives you out-of-bounds map or stack access; a JIT that emits your constants gives you executable bytes you control, even under SMEP/SMAP or CFI.

What you will learn

  • eBPF basics: maps, helpers, the verifier's register state and range tracking
  • From a verifier range bug to OOB map access to AAR/AAW
  • JIT spraying: hiding instructions in immediates, finding JIT pages
  • Using JIT code as a CFI-valid target
  • Reversing and abusing custom in-kernel bytecode VMs

Prerequisites

Modules 02-03. Basic assembly and comfort reading kernel source.

References



Challenges

UIUCTF 2024 · difficulty ★★★☆☆ · module: eBPF, JITs and In-Kernel Interpreters

Your shellcode runs as root, but the kernel was patched so the process can never create a file descriptor. Some kernel interfaces do work on your behalf without one.

Mitigations: patched prctl: no new fds, ptrace_scope 3

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. /home/hacker/exploit is not copied into this VM. There is no shell: /chal reads your machine code as hex on the console and runs it (as root) after a patched prctl has forbidden creating any new file descriptor. Read /flag anyway. The handout's /init gives a root bash for debugging; here init.dojo starts /chal the way the remote did (after echo 3 > /proc/sys/kernel/yama/ptrace_scope). Debug with the handout's own initrd on your machine.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): README, bzImage, chal_build/0001-prctl-Add-a-way-to-prohibit-file-descriptor-creation.patch, chal_build/0001-ptp_kvm-Silence-initialization-warning.patch, chal_build/Dockerfile, chal_build/chal.c, chal_build/init, chal_build/kconfig, init.dojo, initrd, run.sh.

Original challenge

Description

I made it harder ;)

Hint: It's not a bug, it's a feature!

Points

496

Solves

8

Credits

  • Challenge author(s): YiFei Zhu, for UIUCTF 2024
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

CTF@AC26 Quals · difficulty ★★★☆☆ · module: eBPF, JITs and In-Kernel Interpreters

The kernel runs a small microcode VM; reverse it and find where its sandbox ends.

Mitigations: KASLR disabled (nokaslr), oops=panic, -cpu qemu64 (no SMEP/SMAP)

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /home/ctf/exp. Your exploit is put at /home/ctf/exp, which /init runs (as uid 1000) before it starts the shell, as in the original. The root filesystem has only bash and its libraries (no busybox), so bring static tools.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, initramfs.cpio.gz, run.sh.

Original challenge

Description

`A flight-control microcode engine was pushed into the ship kernel so the pilot could tweak trajectories without rebooting. The vendor insists that this system is secure.`

Points

100

Solves

31

Credits

  • Challenge author(s): thek0der, for CTF@AC26 Quals
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

Google CTF 2021 · difficulty ★★★★☆ · module: eBPF, JITs and In-Kernel Interpreters

A patched eBPF verifier that is wrong about one thing; make it believe a pointer is safe.

Mitigations: SMEP, SMAP, KASLR

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): README.md, bpf_verifier.h.patch, bzImage, gen_cpio.sh, kernel.config, root.cpio.gz, start.sh, verifier.c.patch.

Original challenge

Description

You can now encrypt map pointers in your eBPF programs for even greater security!

ebpf.2021.ctfcompetition.com 1337

Points

298

Solves

20

Credits

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

UofTCTF 2026 · difficulty ★★★★☆ · module: eBPF, JITs and In-Kernel Interpreters

Someone extended the eBPF verifier; check whether its idea of a register's range matches reality.

Mitigations: SMEP, SMAP, KASLR, SMP 1

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit. Log in on the console as ctf (no password).

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, chall.patch, initramfs.cpio.gz, start-qemu.sh.

Original challenge

Description

I extended the eBPF because its cool.

Note: You can log in as the ctf user

Points

N/A

Solves

39

Credits

  • Challenge author(s): White, for UofTCTF 2026
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

SECCON CTF 2021 · difficulty ★★★★☆ · module: eBPF, JITs and In-Kernel Interpreters

A backdoor syscall gives you RIP but takes away your stack; find executable bytes you control.

Mitigations: SMEP, SMAP, KPTI, nokaslr

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit. Booting takes about 17 seconds (the init waits for a network that is not there).

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): README.md, bzImage, rootfs.cpio, start-qemu.sh.

Original challenge

Description

Does any "one gadget" exist in kernel-land?

Points

365

Solves

5

Credits

  • Challenge author(s): ptr-yudai, for SECCON CTF 2021
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

SECCON CTF 2022 Quals · difficulty ★★★★☆ · module: eBPF, JITs and In-Kernel Interpreters

A patched eBPF verifier gets shifts slightly wrong; the classic entry point to verifier bugs.

Mitigations: SMEP, SMAP, KASLR

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, patch/verifier.diff, rootfs.cpio, run.sh.

Original challenge

Description

Introduction to eBPF exploitation in 2022 :)

Points

278

Solves

10

Credits

  • Challenge author(s): ptr-yudai, for SECCON CTF 2022 Quals
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

MaltaCTF 2025 Quals · difficulty ★★★★☆ · module: eBPF, JITs and In-Kernel Interpreters

The kernel ships a DWARF-expression interpreter; reverse its bytecode semantics and see what it can touch.

Mitigations: SMEP, SMAP, KASLR

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit. The handout's initramfs also held /bin/pwn.o, LLVM bitcode of an exploit for this module; it is removed here.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, config, dwarf.zig, initramfs.cpio.gz, kernel.zig, run.sh.

Original challenge

Description

https://lkml.org/lkml/2012/2/10/356. The zig version used is 0.13.0. A small patch was applied to ArrayListAlignedUnmanaged.ensureTotalCapacity to mark the function as noinline to prevent miscompilation issues.

Points

378

Solves

8

Credits

  • Challenge author(s): unvariant, for MaltaCTF 2025 Quals
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

DownUnderCTF 2022 · difficulty ★★★★☆ · module: eBPF, JITs and In-Kernel Interpreters

The kernel JIT-compiles your program after checking it; checks on instructions are not checks on bytes.

Mitigations: SMEP, SMAP, KASLR disabled (nokaslr)

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, initramfs.cpio.gz, launch.sh.

Original challenge

Description

A just-in-time compiler implemented completely within the kernel, wow! It's pretty limited in terms of functionality so it must be memory safe, right?

Points

N/A

Solves

11

Credits

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

DownUnderCTF 2025 · difficulty ★★★★☆ · module: eBPF, JITs and In-Kernel Interpreters

A new eBPF ALU operation was added, and the verifier's reasoning about it is not quite right.

Mitigations: SMEP, SMAP, KASLR

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, initramfs.cpio.gz, kernel.patch, run.sh.

Original challenge

Description

I've decided that we really need to extend extended BPF further, so I've added a new instruction! Have fun ROL'ing to your hearts content.

Note - the commit the kernel is based off of is: f66bc387efbee59978e076ce9bf123ac353b389c

Regards,
ItsIronicIInsist

AU: 
US: 

Points

431

Solves

4

Credits

  • Challenge author(s): ItsIronicIInsist, for DownUnderCTF 2025
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

ToH CTF 2025 · difficulty ★★★★★ · module: eBPF, JITs and In-Kernel Interpreters

You control one indirect call, but control-flow integrity checks every target; find code that is allowed to run.

Mitigations: SMEP, SMAP, KPTI, KCFI (cfi=norand), unprivileged BPF disabled, panic_on_warn, SMP 1

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit. The flag is the raw disk /dev/vda (root only).

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, initramfs.cpio.gz, pwn.c, run.sh.

Original challenge

Description

Too easy?

Points

500

Solves

0

Credits

  • Challenge author(s): Prosti, for ToH CTF 2025
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

WannaGame Championship 2025 · difficulty ★★★★★ · module: eBPF, JITs and In-Kernel Interpreters

The verifier's bounds tracking has a blind spot; unsolved during the event.

Mitigations: SMEP, SMAP, KASLR, KPTI

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit. /init copies the flag disk /dev/vda to /flag (root only), so /flag holds the flag followed by zero padding to 512 bytes. The original's user-mode network card (only for downloading files) is not attached, so /network_setup.sh fails harmlessly.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, challenge.patch, config, initramfs.cpio.gz, launch.sh.

Original challenge

Description

This world is full of lies. Escape this world, NEO, escape the matrix

Points

1000

Solves

0

Credits

  • Challenge author(s): not recorded (credit goes to the WannaGame Championship 2025 organizers)
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout 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