WCU / Cybersecurity
~/CSC 472/Class 09/KP 09
Class 09 · KP 09 / 25

Use-After-Free (UAF): The Idea

allocated chunksizeheaderuser datafreed chunk (tcache)sizeheaderfd → next freereused by UAFUse-after-free: the pointer still works after free — read, or overwrite fd.
glibc heap: a dangling pointer to a freed chunk becomes a read/write primitive.
  • A use-after-free happens when a program keeps using a pointer after the chunk it points to has been freed — a dangling pointer.
  • After free(p), the memory is returned to a bin and can be handed to the next malloc. But p still points there.
  • If the attacker can force a reallocation of that same chunk (a new object of the same size), they now control the bytes the dangling pointer reads or writes.
  • Classic exploitation: free an object holding a function pointer or vtable, reallocate it with attacker data, then trigger the stale pointer to redirect control flow.
Key Takeaway

UAF turns a lifetime bug into type confusion: the same memory is read as one object and written as another.