The result of a call that drops privileges is ignored, so a failure leaves them in place
What it finds
setuid(uid); as a statement of its own: if the call fails, the program goes on with the privileges it meant to give up. The result must be checked, and the program stop when it is not zero.
From the rule's source, ignored_privilege_change.rs.
#include <unistd.h>#include <stdlib.h> void drop(uid_t uid){ setuid(uid);tx0 reports: the result of setuid is ignored if (setgid(uid) != 0) exit(1);} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/c:ignored-privilege-change" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/c:ignored-privilege-change] reason="..."tx0 explain tx0/c:ignored-privilege-change shows the same in the terminal. Found a false positive? Report it.