I read from some books that the seteuid together with euid and saved UID can be used to drop root privilege temporarily. The case is:
- set euid to a non-root one.
- do something which does not require root privilege.
- set euid to root again (this works because root is still the saved UID).
I think this is flawed. During step 2, some malicious code could also invoke seteuid to root so this method of dropping root privilege doesn't prevent hijacking code from gain root privilege. Is my analysis correct? If so, what could seteuid-on-saved-UID be used for?