3 ms·
I think the post is really confused about what that advice is trying to talk about. It's not talking about programs which call system("sudo ..."), but rather pr
by yuliyp 5y ago
I think the post is really confused about what that advice is trying to talk about. It's not talking about programs which call system("sudo ..."), but rather programs which have privileges which want to run other programs. The behavior of system() is controlled by many environment variables, which means that it's tricky for such a program to be able to safely use system() without allowing for a security hole of using the privileged program to run another arbitrary program as root.
- ptsneves 5y ago> which means that it's tricky for such a program to be able to safely use system() without allowing for a security hole of using the privileged program to run another arbitrary program as root. Not entirely and this is what the post mentions. That compromise of the program calling systemd("sudo <...>") does not necessarily lead to full blown privilege escalation, because the sudoers file can be crafted into letting sudo run pre-specied privileged programs including pre-specified arguments. Also the compromised system caller will not be able to use poisoned environmental variables to influence the privileged program ran by sudo because sudo wipes the environmental variables by default, before running the privileged program.
- yuliyp 5y agoBut where does system() come in to play then? If you're not dealing with privileged/setuid programs, then a program which calls system() isn't doing anything that you couldn't do yourself. A well crafted sudoers file can help control what gets run with sudo, but that happens regardless of how sudo is invoked.