Stack overflow vulnerability is one of the most common vulnerabilities and the one that is generally addressed first by exploit mitigation technologies. Its risk has been reduced in recent years thanks to new improvements such as the introduction of DEP/NX technique that will be covered in greater detail below. However, under certain circumstances, it can be successfully exploited or at least used to perform a Denial of Service (DoS) attack.
Let's take a look at the following simple application. As you may know, the space for the Buffer[80] variable (and any local variable) is allocated on the stack, followed by the return address (but first by the EBP value that's pushed at the beginning of the function), as you can see in the following simple C++ code:
int vulnerable(char *arg)
{
char Buffer[80];
strcpy(Buffer, arg);
return 0
}
int main (int argc, char *argv[])
{
//the commandline argument
vulnerable(arg[1]);
}
The output for the application...