Search K
Appearance
Appearance
Other ways to support HackTricks:
It's possible to find a great example in how2heap - large bin attack.
Basically here you can see how, in the latest "current" version of glibc (2.35), it's not checked: P->bk_nextsize
allowing to modify an arbitrary address with the value of a large bin chunk if certain conditions are met.
In that example you can find the following conditions:
chunk1->bk_nextsize
to [target-0x20]
chunk1->bk_nextsize->fd_nextsize
with the address of chunk2This is the code (and the reason why chunk2 must be smaller than chunk1). Comments have been added to understand betetr how the address was overwritten:
/* if smaller than smallest, bypass loop below */
assert (chunk_main_arena (bck->bk));
if ((unsigned long) (size) < (unsigned long) chunksize_nomask (bck->bk))
{
fwd = bck; // fwd = p1
bck = bck->bk; // bck = p1->bk
victim->fd_nextsize = fwd->fd; // p2->fd_nextsize = p1->fd (Note that p1->fd is p1 as it's the only chunk)
victim->bk_nextsize = fwd->fd->bk_nextsize; // p2->bk_nextsize = p1->fd->bk_nextsize
fwd->fd->bk_nextsize = victim->bk_nextsize->fd_nextsize = victim; // p1->fd->bk_nextsize->fd_nextsize = p2
}
This could be used to overwrite the global_max_fast
global variable of libc to then exploit a fast bin attack with larger chunks.
Other ways to support HackTricks: