Stack Buffer Overflow
Occurs when a program writes more data to a stack-allocated buffer than the buffer can hold, leading to the overflow of adjacent memory regions. This overflow into adjacent memory locations can lead to overwriting other data, corrupting the program's execution, and leading to security vulnerabilities or crashes.
A stack-based buffer overflow condition is a condition where the buffer being overwritten is allocated on the stack (i.e., is a local variable or, rarely, a parameter to a function).
"Stack Overflow" is often used to mean the same thing as stack-based buffer overflow, however it is also used on occasion to mean stack exhaustion, usually a result from an excessively recursive function call. Due to the ambiguity of the term, use of stack overflow to describe either circumstance is discouraged.
Remediation:
- Implement and perform bounds checking on input.
- Do not use dangerous functions such as gets. Use safer, equivalent functions which check for boundary errors.
Metadata
- Severity: high
- Slug: buffer-overflow
CWEs
- 121: Stack-based Buffer Overflow