New mechanism of libc malloc Angelboy

65
Tcache in glibc New mechanism of libc malloc Angelboy

Transcript of New mechanism of libc malloc Angelboy

tcacheAngelboy
• Weakness in tcache
• Weakness in tcache
New Structure • tcache_entry
• fastbin chunk
• freed linked list chunk data
New Structure • tcache_perthread_struct
New Structure • tcache_perthread_struct
Outline • New Structure
• Weakness in tcache
tcache_perthread_struct
• small bin chunk size malloc tcache fastbin
• fastbin fd chunk tcache user data header
tcache • free chunk chunk small bin size
• fastbin unsorted bin
• tcache
• chunk fastbin unsorted bin
• tcache chunk inused bit )
tcache 0x20size 0x30 0x40 …. 0x70 ….
fast bin array 0. 0 0 …… 0 …..
First time malloc(0x60)
fast bin array 0. 0 0 …… 0 …..
First time malloc(0x60)
fast bin array 0. 0 0 …… 0 …..
free(0x6030c0) NULL
fast bin array 0. 0 0 …… 0 …..
free(0x6030c0)
0x6030c0 … … …
… 1 ….
Heap
fast bin array 0. 0 0 …… 0 …..
free(0x603130) (size:0x70)
fast bin array 0. 0 0 …… 0 …..
free(0x6031a0) (size:0x70)
fast bin array 0. 0 0 …… 0 …..
free(xxx) (size:0x70) ……
fast bin array 0. 0 0 …… 0 …..
free(0x603cd0) (size:0x70)
fast bin array 0. 0 0 …… 0x6033c0 …..
0x6033360 … … …
… 7 ….
Heap
• tcache tcache bin
• Tcache fastbin/smallbin/unsorted bin size chunk fastbin/smallbin/unsroted bin chunk tcache tcache tcache
• bin tcache
tcache 0x20size 0x30 0x40 …. 0x70 ….
fast bin array 0. 0 0 …… 0x6033c0 …..
0x6033360 … … …
… 7 ….
Heap
fast bin array 0. 0 0 …… 0x6033c0 …..
0x60332e0 … … …
… 6 ….
Heap
fast bin array 0. 0 0 …… 0x6033c0 …..
0x60332e0 … … …
… 6 ….
Heap
fast bin array 0. 0 0 …… 0x6033c0 …..
NULL … … …
… 0 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0x603cd0 … … …
… 1 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
NULL … … …
… 0 ….
Heap
header0x6030b0
header
fast bin array 0. 0 0 …… 0x6033c0 …..
NULL … … …
… 0 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0x6033c0 …..
NULL … … …
… 0 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0x6033c0 …..
NULL … … …
… 0 ….
Heap
header0x6030b0
tcache 0x20size 0x30 0x40 …. 0x70 ….
fast bin array 0. 0 0 …… 0x603430 …..
0x6033d0 … … …
… 1 ….
Heap
header0x6030b0
0x6033c0
fast bin array 0. 0 0 …… 0 …..
0x603440 … … …
… 2 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0x603440 … … …
… 2 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0x6033d0 … … …
… 1 ….
Heap
header0x6030b0
• Weakness in tcache
• memory corruption tcache next
• chunk
fast bin array 0. 0 0 …… 0 …..
0x603440 … … …
… 2 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0x603440 … … …
… 2 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0xdeadbedef … … …
… 1 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0xdeadbedef … … …
… 1 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0xdeadbedef … … …
… 1 ….
Heap
header0x6030b0
• free
• fastbin attack chunk
• tcache count
fast bin array 0. 0 0 …… 0 …..
NULL … … …
… 0 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0x6033d0 … … …
… 1 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0x6033d0 … … …
… 1 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0x6033d0 … … …
… 2 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0x6033d0 … … …
… 1 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0x6033d0 … … …
… 1 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0x6033d0 … … …
… 0 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0x6033d0 … … …
… 0 ….
Heap
header0x6030b0
fast bin array 0. 0 0 …… 0 …..
0x6033d0 … … …
… 0 ….
Heap
header0x6030b0
Small bin attack • small bin tcache
• small bin unlink
• chunk double linked list
• unsorted bin attack
• count segment fault
tcache perthread corruption • tcache

• partial overwrite
tcache perthread corruption 0x20size 0x30 0x40 …. 0x70 ….
fast bin array 0. 0 0 …… 0 …..
0x6033d0 … … …
… 2 ….
Heap
header0x6030b0
0x6033d0 … … …
… 2 ….
Heap
header0x6030b0
0x6033d0 … … …
… 2 ….
Heap
header0x6030b0
0x6033d0 … … …
… 2 ….
Heap
header0x6030b0
0x6033d0 0x13371337 0xfacebooc