House of Force
so much shit
Overview
Requirements
The ability to override top chunk size limit with a overflowing limit
0xFFFFFFFFFF
, usually done with a heap overflowBe able to control the size of the heap allocation - program specific - usually able to
glibc≤2.29 (was patched)
What is the Top Chunk?
It is the chunk which borders the top of an arena. While servicing 'malloc' requests, it is used as the last resort. If still more size is required, it can grow using the
sbrk
system call. ThePREV_INUSE
flag is always set for the top chunk.
Steps
Utilizing a heap overflow, overflow the size of the top chunk header
Calculate the distance between the address of the top chunk (get a leak somewhere via
UAF
)This is done so that a malloc with that size will be performed which will move the top chunk to that position
Allocate the size of the distance minus
0x24
(64 bits) or0x10
(32 bits) to account for metadata of the top chunk and new chunkDo another malloc to get a chunk at the target address
What can you do with this?
Overwrite stack/heap variables
Pop shells by overwriting hooks
__malloc_hook
withone_gadget
Example 1 - Initigri CTF 2024 1337UP
Binary has a UAF as it does not null the pointer after freeing and allows for modification of freed memory via
edit_note
Binary also has a heap overflow in the
edit_note
function
Last updated