tcache Poisoning: Arbitrary Allocation
- Goal: make
mallocreturn an arbitrary address of the attacker's choosing — an arbitrary write primitive. - Recipe (unhardened tcache):
- Free a chunk so it enters the tcache; its
nextpointer is now writable via a UAF or overflow. - Overwrite
nextwith the target address. malloconce (pops the real chunk), thenmallocagain — the allocator returns your target address.- Write through that pointer: arbitrary write achieved.
- Common targets: a GOT entry, a saved return address, a function pointer, or (older glibc) a malloc hook.
Key Takeaway
Corrupting a free-list pointer converts a heap bug into "malloc returns whatever I want," the core heap primitive.