Tcache Vulnerabilities
Use-after-free (UAF)
- Read-after-free: data leakage, user-data corruption
- Write-after-free: metadata corruption
Leakage: heap address
- two chunks of equal sizes are freed
- more recently freed chunk is read: leaks
next
Leakage: sensitive data I
- a chunk of certain size is freed
- the same chunk is allocated due to suitable size
- sensitive data is written to this chunk
- the pointer is read again
Leakage: sensitive data II
- an address has sensitive data
- tcache poisoning is performed, but the allocation is discarded
- the sensitive data was written to
headduring the allocation - a subsequent free will write the sensitive data to
next
Corruption: user-data
free: first 8 bytes are nownext, second 8 bytes are nowkeymalloc:nextis not cleared,keyis cleared to NULL- secrets checks that depend on these 16 bytes will be affected
- if tcache poisoning is possible, secrets can strategically be NULLed out
- the corruption happens regardless of whether the allocation is discarded
Corruption: metadata
Tcache poisoning: pointer to anywhere
- allocate the same size to two pointers
- free both pointers
- corrupt
nextof the more recently freed pointer - allocate the same size twice
before [head:B]->[next:A]->[next:NULL]
after [head:B]->[next:TARGET]->[next:???]
Double-free
- a pointer is freed
- corrupt
key - the pointer can be freed again
- tcache poisoning can be done as described above