Buffer Overflow Attack Prevention

Detecting Buffer Overflow and Buffer Overflow Attack Prevention

Most Famous Buffer Overflow Attacks

SQL Slammer: In 2003, a bug – termed as SQL Slammer – was implanted in Microsoft SQL. The bug was spread like a wildfire that doubles the size of the buffer after every 8.5 seconds, resulting in a loss of mobile phone coverage and internet outages across the world.

The Morris Worm: It was a buffer overflow attack that occurred in 1988 and resulted in the compromise of more than 60,000 machines. This fraud was also convicted under the Computer Fraud and Abuse Act.

Buffer Overflow Attack Prevention

Avoid Using C and C++ Languages: C/C++ are high-level programming languages that are vulnerable to buffer overflow attacks. Prefer using other programming languages such as Python, Java, and COBOL. These languages don’t allow direct access to memory.

Buffer Overflow Protection: The security of executable programs should be executed by detecting buffer overflows on stack-allocated variables.

Static Code Analysis: Use static application analysis tools such as Kiuwan to scan your code for buffer overflow vulnerabilities.

Bounds Checking: Avoid using standard library functions that do not bound checked such as strcpy, scanf, and gets. In fact, bounds checking in abstract data type libraries can reduce the occurrence of buffer overflows.

Executable Space Protection: Memory regions should be marked as non-executable. Doing so will prevent the execution of machine code in these regions.

Use Modern Operating Systems: Modern operating systems have runtime protections that help mitigate buffer overflow attacks, such as randomly rearranging the address space locations of the main data areas of a process, avoiding knowledge of the exact location of important executable codes and assign a binary value, whether it is "executable" or "non-executable" in a memory area, protecting the non-executable area from exploits.

Conclusion (The Way Forward)

Threat actors exploit buffer overflows by overwriting the memory of the application. Doing so would prevent the normal functioning of the program. The most famous buffer overflow attacks are SQL Slammer and The Morris Worm. Buffer overflow attacks can be prevented by using modern operating systems, executable space protection, bounds checking, static code analysis, and avoid using C and C++ languages.