tcache Hardening in Newer glibc
Later glibc versions added integrity checks to the tcache:
- tcache key (glibc 2.29): each freed tcache chunk stores a
keyfield. Onfree, if the key already marks the chunk as cached, malloc suspects a double-free and aborts. - Count tracking: a per-bin counter guards against overflowing the list length.
- Safe-linking (glibc 2.32): the
nextpointer is obfuscated (XORed with a secret derived from its own address). A blind overwrite no longer yields a usable pointer. - Alignment checks (glibc 2.32+): allocations from the tcache must be aligned, blocking some poisoning targets.
Key Takeaway
The tcache key and safe-linking are the main reasons modern heap exploits are harder than 2017-era ones — but bypasses exist.