Use after free
Last updated
Last updated
Use-After-Free (UAF) is a vulnerability related to incorrect use of dynamic memory. If after freeing a memory location, the program does not clear the pointer to that memory, an attacker can still use this pointer with possibly arbitrary values.
As explained , when a chunk is freed, it's stored into a bins ( fastbins for shorter chunks, unsorted bins for the others. ) and when the program need a new chunck, it will take if from that bins first depending on the required size.
Then, if the size is compliant, the allocated bin is the same than the previously freed chunk.
So, the new pointer has the exact same value as the old pointer and then, if the old pointer isn't clear, it will point with this new value.
This behavior can easily be highlight by the followed code :