Master the fundamental concepts of binary exploitation through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksHeap exploitation targets dynamic memory management bugs rather than stack overflows. Corrupting heap metadata via malloc/free bugs can lead to arbitrary memory writes and code execution.
A glibc heap chunk contains:
size: chunk size including metadata (low 3 bits are flags)fd / bk: forward/backward pointers in free listsKey vulnerability classes:
For example, a double-free of chunk A can cause malloc to return the same address twice, giving two pointers to one allocation.
You will simulate a tcache-style allocator over a malloc/free trace: compute the real chunk-size rounding (align16(req + 8), minimum 32 on x64), service allocations LIFO out of the per-size free bucket exactly like tcache, detect double frees the way glibc's tcache key check does, and report the final heap state. The same reuse pattern is what turns a use-after-free into attacker-controlled data.
Glibc's safe unlinking checks that fd->bk == chunk before removing a free chunk from a doubly linked list. Tcache (per-thread cache) added in glibc 2.26 speeds allocation but introduced new double-free checks. Safe-linking XOR-mangles pointers in recent versions. Despite defenses, heap bugs remain the top vulnerability class in browsers, where attackers combine UAF with JavaScript type confusion for reliable exploitation.
Write a C program that processes a malloc/free trace and reports allocator behavior.
Requirements:
A <name> <req> allocates and F <name> freesSuccess Criteria: