CSCTF 2026Pwn
FORGE
A classic House of Force. The note editor (temper) has an off-by-design heap overflow that lets us smash the top chunk's size field with 0xffffffffffffffff.
- Competition
CSCTF 2026- Category
- PwnMedium (425 pts, 25 solves)
- Source status
- Source-documented · not platform-verified
- Document
- PDF edition3 min read
TL;DR
A classic House of Force. The note editor (temper) has an off-by-design heap overflow that lets us smash the top chunk's size field with 0xffffffffffffffff. Because the binary runs glibc 2.27 (no top-chunk size sanity check), we then request one gigantic malloc to drag the top chunk down into libc, land the next allocation on __free_hook, overwrite it with system, and free a chunk containing "/bin/sh".
heap+libc leak → overflow top size = -1 → malloc(target-top) → __free_hook = system → free("/bin/sh")01
Recon
The source (forge.c) is included. It's a 16-slot note manager over malloc:
forge—malloc(size)of any size, thenread_until_nl(p, size)reads content (no NUL terminator written).temper— "append more content":C read_until_nl(p + strlen(p), notes[i].size); // BUG: should be size - strlen(p)It writes up to
sizebytes starting after the current string, so the total write can run past the end of the chunk — a controllable heap overflow.inspect—puts(notes[i].data)→ read primitive / info leak.melt—free+ NULLs the pointer (no classic UAF).
The header comment even names it: // forge - House of Force (glibc 2.27, Ubuntu 18.04). Protections: PIE + full RELRO (so the GOT is read-only — hooks in libc are the target).
02
Leaks
There's no direct UAF (melt nulls the pointer), but we can free a chunk, re-allocate the same size with empty content, then inspect to read the pointers libc left behind.
Heap leak: two
0x20chunks → tcache. Re-forge one with empty content and read itsfd, which is the address of the other freed chunk →heap_base = leak - 0x260.Libc leak: a
0x500request (chunk0x510> tcache max0x410) goes straight to the unsorted bin on free, so itsfd/bkpoint intomain_arena. A0x88guard chunk (not a cached size) is carved after it so the free doesn't just consolidate into the top. Re-forge0x500empty,inspect→libc_base = leak - 0x3ebca0.
03
House of Force
Put
"/bin/sh\x00"in a chunk (reuses the freed tcache chunk, safely mid-heap).Forge a victim right before the top chunk (
forge(0x28), carved fresh from the top so the bytes beyond it are pristine zeros →strlenis predictable).temperthe victim so the write lands exactly ontop->size, setting it to0xffffffffffffffff. The write starts atvictim_data + strlen(0x18); 16 bytes ofpadding + "\xff"*8overwrite the top size.Request the magic size
nb = __free_hook - 0x18 - top(passed asnb - 8sorequest2sizerounds back tonb). This moves the top chunk down to__free_hook - 0x18.__free_hookis≡ 8 mod 16, so we aim the next chunk's user pointer at__free_hook - 8(16-aligned) and prefix the write with 8 junk bytes.
The next
forgereturns__free_hook - 8; writepadding + system.meltthe"/bin/sh"note →free(ptr)calls__free_hook(ptr)=system("/bin/sh").
Shell. flag → /tmp/flag:
CSCTF{7yb54DWvCapfEFMKrlBuaqKf}04
Running
python3 exploit.py # local, against ./forge with the shipped loader+libcpython3 exploit.py remote # w03.ctf.chronos-security.ro:33295Full exploit in exploit.py.
Flag: CSCTF{7yb54DWvCapfEFMKrlBuaqKf}
Flag
Result
Flag
CSCTF{7yb54DWvCapfEFMKrlBuaqKf}
Source-documented · not platform-verified
