Table of Contents
Summery
The program sudo is used under UNIX operating systems like Linux or macOS to start processes with the rights of another user. In most cases, commands are executed that are only available to administrators. It serves as an additional layer of security or a safeguard to prevent the system and its contents from being damaged by unauthorized users. The /etc/sudoers file specifies which users or groups are allowed to run specific programs and with what privileges.
I sometimes get confused between sudo and su. The key difference from sudo is that su actually switches your current shell/session to another user, whereas sudo normally lets you execute individual commands with another user’s privileges.
Successful authentication is cached for 15 minutes on many Linux distributions. During that period, sudo usually won’t ask for your password again. The exact timeout is configurable through timestamp_timeout in /etc/sudoers.
Commands
sudo - Run something with another user’s privileges. Uses your password, and checks your rights in /etc/sudoers.
sudo -l - List what you are allowed to run.
sudo -i - Get a root login shell - equivalent to su -.
sudo -V | head -n1 - Find out the sudo’s version.
Vulnerabilities
CVE-2021-3156
One of the latest vulnerabilities for sudo carries the CVE-2021-3156 and is based on a heap-based buffer overflow vulnerability. This affected the sudo versions:
- 1.8.31 - Ubuntu 20.04
- 1.8.27 - Debian 10
- 1.9.2 - Fedora 33
- and others
CVE-2019-14287
Another vulnerability was found in 2019 that affected all versions below 1.8.28, which allowed privileges to escalate even with a simple command. This vulnerability has the CVE-2019-14287 and requires only a single prerequisite. It had to allow a user in the /etc/sudoers file to execute some/any specific command.
Miscellaneous
If the /etc/sudoers configurations are too permissive, a user could abuse the short-lived administrative right to obtain permanent root access.
With sudo privilege escalation, we can also use GTFObins for suggestions on how to abuse it.
Other considirations
Beware however, that as with every tool GTFObins’ script might not work because of many reason. Sometimes those scripts relay on programs like python where your target might not have it, sometimes target’s run AV software or security kernel modules like AppArmor.
If you want to investigate the culprit of your not-working script, you can inspect syslog file with a command like cat /var/log/syslog | grep tcpdump.