CSG CYBER DEFENSE EDUCATION & RESEARCH FOUNDATION
CSG CYBER DEFENSE EDUCATION & RESEARCH FOUNDATION
Explore fixed-size stack buffer boundaries, step-by-step byte spills into adjacent variables and return pointers, and how bounds checking, stack canaries, ASLR, DEP/NX, and safer APIs prevent memory corruption.
Observe how copying more bytes than a fixed 16-byte stack buffer can store spills across adjacent stack structures. All operations are strictly sandboxed inside this page's client-side simulation model — zero host memory is accessed and execution cannot occur.
Safe Zone (15 / 15 payload chars + '\0'): Writing inside buffer[14] (s / 0x73). Adjacent variable isAdmin remains 0.
Verifies input byte length against destination capacity before writing so excess data is rejected or truncated before touching adjacent stack variables.
Compiler places a randomized secret guard value between local buffers and Saved RBP/RIP; mismatch at function epilogue aborts execution via __stack_chk_fail().
Randomizes stack, heap, and shared library base virtual addresses on every launch so fixed jump addresses fail unpredictably instead of redirecting control flow.
CPU MMU enforces W^X (Write XOR Execute): stack and heap data pages are marked RW- only, triggering an instant hardware fault if treated as instructions.
Eliminate unbounded C functions (strcpy, gets, sprintf) in favor of length-bounded APIs (fgets, snprintf, strlcpy), compiler sanitizers (-fsanitize=address), or memory-safe languages like Rust, Go, and managed runtimes that enforce slice bounds at compile/runtime.