Alsalam alikom wa ra7mat Allah wa barakatoh
Huh!! that's what I said when I first saw that title... but let me explain...
Double Free means that you try to free a pointer two times (which is logically can't work).
Actually windows SP2 and later (even Vista) this can be done (in somehow) and can actually corrupt the heap (Vista will shout at your face if u did) and that can make you able to use and browse the heap as you want..
Facts to know about how Windows frees your pointers:
- There is something called Lookaside buffer (fast access, small size) and another thing is FreeList(slower access, the whole memory).
- Chunk is an object of the DataStructure that holds mainly 2 things: pointer to where the next free Chunk is and pointer to the previous free one (think about it like a node in a linked list)
- The first 4 bytes of the Chunk is the BLink (BackLink) and the second 4 bytes is the FLink
- delete ptr1;
delete ptr2;
Windows takes your Chunk (for ptr1) and puts it in the Lookaside slot (and mark it as Busy), then takes ur second chunk and puts it in another free slot (if exists, if not it'll be sent to the FreeList)
Now, the Vulnerability:
If we succeeded to make something like this :
delete ptr;
delete ptr;
And to ensure that the second delete will be sent to the FreeList, guess what, we have two locations pointing to the same chunk (so what ??.. just wait and c)
Now, if we can then re-allocate a chunk
ptr = new Whatever;
Guess what !! u will take the Chunk in the lookAside back to u.. and u still have those precious 8 bytes that you can play with and actually corrupt or control the freeList entries..
* One last note, about Windows Vista:
- They are using random address for FreeList.
- They are using encoded BLink & FLink after XOR'ing them with a random value generated when the process starts
- The Windows Shout when the heap is corrupted (previous windows just ignore this)
All what is above is a quick review after reading these two articles :
Double Free Vulnerabilities Part1 (Symantec.. what is the bug)
Double Free Vulnerabilities Part2 (Symantec.. how to exploit the bug)
That's it... stay away hackers !!!
Alsalam alikom wa ra7mat Allah wa barakatoh
Comments
Post a Comment