Intro to stack buffer overflows

A stack buffer overflow is a type of vulnerability that occurs when a program writes more data to a buffer than the buffer is allocated to hold. This can happen in a number of ways, but one common cause is when the program uses gets() or strcpy() to copy user input into a fixed-size buffer without checking the size of the input first.

In an ARM binary, a stack buffer overflow can be used to execute arbitrary code by overwriting the return address of a function with the address of malicious code. This is typically done by sending a carefully crafted input to the vulnerable program that causes the buffer overflow, and then using the overflow to overwrite the return address with the address of the malicious code.

To prevent stack buffer overflows, it is important to use functions that are designed to safely handle user input, such as fgets() or strncpy(), and to always check the size of the input to ensure that it does not exceed the size of the buffer. It is also a good idea to use canaries (also known as “stack cookies”) to detect when the stack has been modified and to terminate the program before the return address can be overwritten