Stack buffer overflow
lastmod 2018-03-19created 2018-03-191 edits
A stack buffer overflow occurs when a program writes to a memory address on the call stack outside of the data structure the program intended (usually one with a fixed buffer length). Stack buffer overflow bugs occur when a program writes more data to a buffer located on the stack than is allocated for it. This always causes corruption of adjacent data on the stack, and when the overflow happens by mistake, the program crashes or behaves incorrectly. A stack buffer overflow is a type of the general programming malfunction known as buffer overflow. Overwriting a buffer on the stack is more likely to cause problems than overwriting a buffer on the heap, because the stack contains the return addresses for all active function calls.
A stack buffer overflow can be caused deliberately as part of an attack known as stack smashing. If the affected program is running with special privileges or receives data from untrusted network hosts (or a web server), the bug is a potential security vulnerability. If the stack buffer is filled with data supplied by an untrusted user, the user can corrupt it in such a way as to inject executable code into the running program and gain control of the process. This is one of the oldest and most reliable ways for an attacker to gain unauthorized access to a computer.