hackweb
notes on hacking and technology
IT EN
main menu
user menu
you are not logged in

Use-after-free: using freed memory

September 29, 2025 · 1 min read · #binary-exploitation #heap #uaf

After free(p), p still points (dangling). If the allocator reassigns that chunk to another object, using p reads/writes the new object.

Exploiting it

The classic pattern: free an object with a virtual function (vtable/function pointer), reallocate a buffer of the same size filled with your data, then the old object is "used" and calls the pointer you now control.

free(obj);
spray(size_of_obj, controlled_bytes);  // fill the freed chunk
obj->method();  // jump to the address you wrote

Defence

Null pointers after free. Use smart pointers/ownership (Rust removes this by construction). Quarantine allocators with delayed reuse, ASAN in testing, and mitigations like pointer authentication (ARM) or CFI reduce impact.


« back to home

latest posts
 
your IP address:
216.73.216.108
visitor #1
MOTD:
Every abstraction leaks somewhere.
Here we look at where.
topics