Fast Bin Attack
Here are a list of key properties of FastBins
Single Linked List - LIFO
10 bins, sizes of 8 bytes to 80 bytes
Two Adjacent Freed FastBins will not consolidate
FD and BK pointers point to the next and previous chunk respectively
So what happens if we perform a double free on a FastBin chunk? Let's look at this example by how2heap
First we allocate 3 FastBin Chunks
We then follow up with a double free with a alternate chunk in the middle so as to not trigger
malloc(): memory corruption (fast)
Our fastbin free list is now circular and if we allocate three times more with the same size,
malloc
returns the same fastbin address twice!
We can leverage this to allow malloc to return a arbitrary pointer address to the stack or heap by utilizing UAF
to change the fd
pointer of the duped fastbin chunk to an address that we want.
Something to take note of here is to ensure that the fake chunk that fd
is pointing to must have a valid chunk size.
This can be combined with heap consolidation via unsorted bin to get a libc leak.
We can see that the last two malloc
calls return the same pointer to p1 which has been consolidated with the large chunk allocated. If we have a UAF
on p1, we can potentially get a libc leak via main_arena+88
.
Last updated