Class 06 · KP 16 / 18
Defenses: Hardening in Depth
- FORTIFY_SOURCE (
-D_FORTIFY_SOURCE=2): the libc *printf variants refuse %n in writable format strings and add bounds checks —- kills the classic %n write in many cases. - RELRO:
- Partial RELRO: reorders sections, but GOT still writable.
- Full RELRO (
-Wl,-z,relro,-z,now): resolves all symbols at load time and marks the GOT read-only —- defeats GOT overwrite. - ASLR / PIE / stack canaries: still relevant, but remember a format leak is exactly what bypasses these —- so the code fix is the real defense.