Hack.lu CTF 2021 · difficulty ★★★☆☆ · module: Heap UAF: Reclaiming Freed Objects
A custom socket option on a stock Ubuntu kernel; race its lifetime handling to call a function of your choice.
Mitigations: KASLR, no SMEP/SMAP (default CPU), flag at /mnt/flag in the initramfs (the original mounted a flag disk there)
Also uses techniques from: Races: Double Fetch, userfaultfd and FUSE (08-races).
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 your payload at /home/hacker/exploit first; it is attached to the VM as a raw disk, as in the original challenge.
There is no shell. Your exploit is a 'bot' (a script or static ELF, at most 10 MiB): it is copied to /bot and run as nobody; its output is all you see, and the VM powers off when it exits. The flag is /mnt/flag.
The flag is put at /mnt/flag in the initramfs (the original mounted a flag disk there), so the boot message mount: mounting /dev/sda on /mnt failed: Invalid argument is expected: /dev/sda is an empty placeholder disk.
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): build.sh, initramfs.cpio.gz, module/Makefile, module/dockerfile, module/stonks_socket.c, module/stonks_socket.ko, run_chall.sh, vmlinuz-5.11.0-38-generic.
Original challenge
Description
The bigo hedge fund Whiterock is testing it's new trading bot cloud and we got exclusive beta access. Big news is the addition of extra "secürety" features for TCP connections. We could "convince" one of their employees to provide the source code for the new features.
Access is available at flu.xxx 20020
Points
353
Solves
12
Credits
- Challenge author(s):
Diff-fusion, for Hack.lu CTF 2021
- Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups