TEACHING YOU HOW TO SECURE YOUR SOFTWARE
What does buffer overflow mean?
Say you have some buffer you created called B. During a programs execution, if more data is attempted to be put into B then the allotted memory space, then a buffer over condition exists. When attempting to write outside a block of memory, it can corrupt the data or execute malicious code. This is known as a buffer overflow attack.
What does this have to do with software security?
If you are not familiar with how programs execute, you might not quite understand why this is such a big deal. One of the main problems is the variety of ways a buffer overflow can occur. It is common for these attacks to be used against legacy and new applications. However, buffer overflows are generally not easy to discover and exploit. Here is a general example of a classic buffer overflow exploit. Data is sent to a program by an attacker which is stored in a stack buffer which is too small. Information on the call stack is then overwritten and the value of the return pointer is such that malicious code of the attacker is executed. Other examples of buffer overflow are heap buffer overflow, off-by-one error, and format string attack. At the programming level, a codes vulnerability is sometimes due to poor assumptions by the programmer. In languages such as C or C++, bound checking does not occur in certain instances which can lead to the allocated bounds to be overwritten in a buffer.
How can this be prevented?
First, if a program is being coded in C or C++, the programmer needs to take extra care of memory management. This is because these languages have no built-in protection in overwriting data in their memory. Modern programming languages such as Java and C# have more precautions to reduce buffer overflow errors but are still vulnerable to them.