Consider following C code snippet:
void barfoo (int authstatus) {
1: char packet[1024];
2:
3: fgets (packet, 1023, stdin);
4: if (authstatus != 0)
5: system (packet);
6: else
7: syslog ("Not authorised to process packet");
8:
9: return;
10: }
Attacker can only call this function with auth_status
set to 0
. Goal of the attacker is to execute code of his choice like spawn a shell. So, can attacker do this in any way if he has to exploit only this function or any function directly related to this function like fgets
or system
or syslog
?
I am unable to find any vulnerability in this. For instance fgets
checks for bounds so buffer overflow is not possible.