Skip to main content
Removed line numbers
Source Link
user163495
user163495

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.

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.

Consider following C code snippet:

void barfoo (int authstatus) {
    char packet[1024];

    fgets (packet, 1023, stdin);
    if (authstatus != 0)
       system (packet);
    else
       syslog ("Not authorised to process packet");

    return;
}

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.

Source Link

Is following code vulnerable?

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.