Concepts / Binary exploitation

Binary exploitation

Memory disclosure

Also called info leak, information leak, format string, format string bug, %p %s

Making a program hand back memory it never meant to reveal — classically through a format string built from untrusted input.

Input used as the format prints the stack
Input used as the format prints the stack

With printf(input), each %p in the input is obeyed and prints a word from the stack. With printf("%s", input) the same text is only printed.

A memory disclosure makes a program print memory it never meant to reveal. The classic is the format-string bug: printf(user_input) instead of printf("%s", user_input). printf then obeys the input: each %p prints a stack word, %s prints the string a stack word points to. That leaks secrets and addresses, and one leaked address defeats [[stack-overflow|ASLR]]. The fix: untrusted input is never the format; -Wformat-security warns about it.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab