hackweb
notes on hacking and technology
IT EN
main menu
user menu
you are not logged in

Stack canary: how it is bypassed

September 5, 2025 · 1 min read · #binary-exploitation #canary #stack

The compiler inserts a random value (canary) between buffers and the return address. Before ret it checks it: if changed, it aborts. A linear overflow must cross it, so it alters it and gets detected.

The ways out

Leak: a format string or overread prints the canary; you rewrite it unchanged in the payload.

Brute-force: in processes that fork() the canary does not change across children; you guess it byte by byte (256 tries per byte).

Non-linear write: an overflow that skips the canary (arbitrary index, off-by-one on a pointer) reaches the return address without touching it.

Defence

The canary is a mitigation, not an absolute barrier: combine it with ASLR, PIE, RELRO and with removing memory bugs upstream. Prevent leaks (no format strings, no overreads).


« back to home

latest posts
 
your IP address:
216.73.216.108
visitor #0
MOTD:
Every abstraction leaks somewhere.
Here we look at where.
topics