House of Einherjar
Last updated
Was this helpful?
Last updated
Was this helpful?
This house is not part of "The Malloc Maleficarum". This heap exploitation technique was given by in 2016. This attack also revolves around making 'malloc' return a nearly arbitrary pointer. Unlike other attacks, this requires just a single byte of overflow. There exists much more software vulnerable to a single byte of overflow mainly due to the famous error. It overwrites into the 'size' of the next chunk in memory and clears the PREV_IN_USE
flag to 0. Also, it overwrites into prev_size
(already in the previous chunk's data region) a fake size. When the next chunk is freed, it finds the previous chunk to be free and tries to consolidate by going back 'fake size' in memory. This fake size is so calculated so that the consolidated chunk ends up at a fake chunk, which will be returned by subsequent malloc.
Consider this sample code (download the complete version ):
Note the following:
The second chunk's size was given as 0xf8
. This simply ensured that the actual chunk's size has the least significant byte as 0
(ignoring the flag bits). Hence, it was a simple matter to set the previous in use bit to 0
without changing the size of this chunk.
The allotedSize
was further decreased by sizeof(size_t)
. allotedSize
is equal to the size of the complete chunk. However, the size allowed for data is sizeof(size_t)
less, or the equivalent of the size
parameter in the heap. This is because size
and prev_size
of the current chunk cannot be used, but the prev_size
of the next chunk can be used.
Fake chunk's forward and backward pointers were adjusted to pass the security check in unlink
.