A stack is a last-in, first-out data structure. New values are placed on the top, and the most recent value is removed first. Programs use stacks constantly to track function calls, local variables, temporary results, and return addresses while computation unfolds.
Stacks matter in cyber security because many attacks target the memory stored on the stack. A classic example is a stack-based buffer overflow, where writing past a fixed buffer can corrupt nearby data, including control information used to direct execution. Defenders harden stack use with techniques such as stack canaries, non-executable stack protection, address randomization, and safer coding practices that limit unchecked writes and recursion depth.


