thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Application & OT Security · Intermediate

Stack Canary

A random value placed before the return address on the stack and checked before a function returns, detecting stack buffer overflows.

Definition

If an overflow overwrites the canary, the program aborts instead of returning to an attacker-controlled address. Enabled with compiler options such as -fstack-protector-strong (GCC/Clang) or /GS (MSVC). Information leaks that reveal the canary can bypass it.

Example

Compiling with -fstack-protector-strong adds canaries to functions with local arrays.

Exam tip

Canaries detect stack overflows at function return; they do not protect the heap.

Related terms