Challenges › Binary Exploitation

Reuse the Freed Region

hard · 50 XP · flag · free · solves: 0

A small program called reuse-the-freed-region manages four same-size heap slots with alloc, free, edit, leak and check. checksec shows NX enabled, stack canary found, PIE enabled, and full RELRO. It runs on glibc 2.39, so freed chunks use safe-linking: the forward pointer a freed chunk stores is XORed with its own address shifted right by 12 bits, not stored plainly.

leak shows you where a hidden flag variable lives. Free two slots, then edit the second one's raw bytes to redirect the allocator's freelist at that address, accounting for the scramble. Two further allocations will then hand you a chunk aliasing the flag variable itself; write a nonzero value into it and check again.

Submit the flag once the check command reports unlocked.

Tags: learn

Try next