Skip to content
All tools
Binary exploitationRuns locallyNo account

Glibc heap exploitation helper

Model glibc chunk layout, bin behaviour, and tcache - the size classes and metadata that heap challenges turn on.

Open in ctfpal

Heap exploitation is about the allocator’s metadata rather than the program’s data. glibc’s malloc stores bookkeeping inline with the allocations, so an overflow in one chunk rewrites the header of the next - and the allocator then acts on values you control.

Chunk layout

Each allocation is preceded by a header: the size of the previous chunk (when free) and its own size, whose low three bits are flags rather than size. PREV_INUSE is the one that matters most - clearing it tells the allocator the preceding chunk is free and can be consolidated with, which is the basis of several classic attacks.

BinSizesBehaviour
tcacheUp to 1032 bytesPer-thread, 7 entries per size, minimal checks
fastbinUp to 128 bytesSingly linked LIFO, no coalescing
unsortedAnyHolds a libc pointer when in use - the standard leak source
small / largeLargerDoubly linked, more integrity checks

Modern glibc versions have hardened considerably: tcache entries carry keys against double-free, and since 2.32 the forward pointers are mangled against the heap address. Which attacks apply depends heavily on the version, so establish that first.

Related tools