Saltar al contenido ForoHackers

What each exploit mitigation really takes away (CTF edition)

Análisis de binariosCTFDesarrollo de exploits
#1124 · rop_gadget_goblin · · Denunciar

When a CTF binary says "all mitigations enabled", it helps to know what each one removes from the attacker's toolbox and what it leaves alone. Conceptual view, for the defender and the player who wants to understand a challenge's design:

Mitigation What it changes What it does not cover
NX / DEP Stack and heap memory is not executable, so injected bytes cannot run as code Reusing code that is already in the program
ASLR / PIE Addresses of stack, heap and libraries (and the binary itself, with PIE) differ every run Information leaks that reveal an address, or bugs that need no address
Stack canary A secret value before the return address; a linear overflow that damages it is detected at function exit Overwrites that skip the canary, data-only corruption, and leaks of the canary
RELRO (full) The GOT is read-only after startup Everything that is not the GOT
CFI Indirect calls and returns may only go to valid targets Bugs that change data without changing control flow
Shadow stack A protected copy of return addresses is compared on return Corruption of function pointers or data

The pattern is that each mitigation closes one technique, not one bug. The memory bug stays; what changes is what you can build on top of it. That is why layered defence works, and also why the real fix is still removing the bug: bounds checks, memory-safe languages, sanitizers in testing, fuzzing.

If you are learning, the most instructive exercise is the reverse one: write a small program with a bug, turn the mitigations on one by one, and observe in the debugger how the crash changes. You will remember a crash you saw better than a table you read.

#1828 · hexdump_hermit · · Denunciar

Add -fstack-protector-strong versus -fstack-protector-all to the lab list. The "strong" heuristic does not protect every function, only those with arrays or address-taken locals. Seeing which functions got a canary in the disassembly is a nice 10-minute exercise.

#1829 · ghost_in_the_heap · · Denunciar

Heap side of the same story: safe-linking for tcache and checks on the size of freed chunks are the allocator-level equivalents. They do not fix use-after-free in your code, they make some ways of exploiting it harder. The honest fix is the same: do not have the bug.

#1830 · null_terminated_hopes · · Denunciar

"Each mitigation closes one technique, not one bug" should be printed on a banner in every C shop. We keep patching the shadow, the object is still standing there.

#1831 · rop_gadget_goblin · · Denunciar

Thanks both. Hexdump, I will do the strong versus all comparison and post the function list. Ghost, yes: the allocator hardening and compiler hardening are two lines of defence for the same bad idea, which is writing past what you own.

Inicia sesión o únete para responder.