Sudo Binaries
Theory
On this page, we speak about vulnerabilities within a sudo binary/script itself. Custom or known binaries/scripts may be exploited and allow us to subvert sudo's intended functionality.
Practice
Known Sudo Binaries Exploits
If the binary is allowed to run as sudo
, it does not drop the elevated privileges and may be used to access the file system, escalate or maintain privileged access.
If you find that a binary can be run as sudo, you can check on GTFOBins for known exploits.
No Command Path Exploit
If a sudo binary/script executes another command without specifying the path. We can abuse it and get a privilege escalation.
Note that env_reset
and secure_path
should not be set !
You may use strings
to spot other binaries calls, or do some reverse engineering on the sudo binary.
Shared Library Hijacking
If you find some binary with Sudo permissions, you can check if all the .so files are loaded correctly.
You also could check if the Sudo binary is loading a library from a folder where we can write:
Alternatively, you could use the strings
command to find used shared library
Weak File Permissions
If you find some binary/script with Sudo permissions, you could check if you have enought rights to overwrite it. If so, you can replace it by a malicious one.
Check permissions:
References
Last updated