Buffer overflow
lastmod 2020-08-31created 2017-05-123 edits
A buffer overflow, or buffer overrun, is a program vulnerability in which an error in handling memory causes incorrect behavior. In computer security and programming, it is when a process, while storing data in a buffer, stores it outside the area specified by the programmer. The overflowing data overwrites adjacent memory, which may contain other data; the data that can be corrupted includes program variables and program control-flow data. This can lead to incorrect program behavior, and can result in memory access errors, incorrect results, program termination, or a breach of system security.
A buffer overflow can be triggered by input designed to execute code or to alter the program's operation. It is therefore the basis of many software vulnerabilities and can be exploited maliciously. Bounds checking can prevent buffer overflows.
A buffer overflow usually occurs because, in the process of storing data, the memory location where the data will be stored is not checked for validity. In such cases, values near the location holding the data are corrupted, and that corruption may affect program execution. In particular, malicious attacks may create vulnerabilities in the program.
The programming languages commonly associated with buffer overflows are C and C++, which provide no built-in protection against accessing or overwriting data in any part of memory and do not automatically check whether data written to an array is within the bounds of that array.