Attacking Program Memory
A Buffer Overflow is a classic and very dangerous vulnerability. It occurs when a program tries to write more data into a memory block (buffer) than it was designed to hold.
The Mechanism
- Fixed-size Buffer: A program allocates 10 bytes of memory for a username.
- Input Exceeds Limit: An attacker provides 50 bytes of input.
- Overflow: The excess 40 bytes spill over into adjacent memory, typically overwriting critical data like the function's return address.
- Redirection: When the function finishes, the program tries to jump to the overwritten return address, which the attacker has replaced with the memory address of their malicious code (shellcode).
Security Implication
Buffer overflows directly lead to arbitrary code execution (RCE) and are often used for privilege escalation.