Unchecked return value of setuid/seteuid may leave elevated privileges
ID |
c.race_condition.unchecked_ret_setuid_seteuid |
Severity |
low |
Resource |
Race Condition |
Language |
C / C++ |
Description
The software does not check the return value from a method or function, which can prevent it from detecting unexpected states and conditions. If the program calls a function to drop privileges but does not check the return code to ensure that privileges were successfully dropped, then the program will continue to operate with the higher privileges.
Rationale
The software does not check the return value from a method or function, which can prevent it from detecting unexpected states and conditions. If the program calls a function to drop privileges but does not check the return code to ensure that privileges were successfully dropped, then the program will continue to operate with the higher privileges.
The following code illustrates a vulnerable pattern detected by this rule:
void drop_priv_perm()
{
// VULNERABLE: Unchecked return value of setuid/seteuid may leave elevated privileges
setuid(getuid());
}