Buffer overflow Attack: Sample Authorization
void A( ) {
int authorized;
char name [128];
authorized = check credentials (...); /* the attacker is not authorized, so returns 0 */
printf ("What is your name?\n");
gets (name);
if (authorized != 0) {
printf ("Welcome %s, here is all our secret data\n", name)
/* ... show secret data ... */
} else
printf ("Sorry %s, but you are not authorized.\n");
}
}
The code is meant to do an authorization check. Only users with the right credentials are allowed to see the top secret data. The function check credentials is not a function from the C library, but we assume that it exists somewhere in the program and does not contain any errors. Now suppose the attacker types in 129 characters. As in the previous case, the buffer will overflow, but it will not modify the return address. Instead, the attacker has modified the value of the authorized variable, giving it a value that is not 0. The program does not crash and does not execute any attacker code, but it leaks the secret information to an unauthorized user.
=> Can the sandboxing technique prevent attack? How?