Sudo Misconfigurations and Exploits
You'll learn how improper sudo rules create privilege escalation opportunities that attackers can exploit to gain root access.
What is Sudo Misconfiguration?
Sudo allows users to run commands with elevated privileges. When administrators carelessly configure /etc/sudoers, they often create unintended paths to root. Think of sudo like giving someone the keys to specific rooms in a building—if you accidentally give them a master key disguised as a single-room key, they can go anywhere.
Common Misconfiguration Patterns
Wildcard Vulnerabilities: Rules like user ALL=(ALL) NOPASSWD: /bin/tar * seem safe but are dangerous. An attacker can abuse tar's checkpoint feature:
sudo tar cf /dev/null testfile --checkpoint=1 --checkpoint-action=exec=/bin/sh
This spawns a root shell because the wildcard allows arbitrary arguments.
Command Chaining: If sudo allows commands that can execute others (like find, vim, less, awk), attackers escape to shells:
sudo find /etc -exec /bin/bash \;
CVE-2019-14287: The User ID Bypass
This critical vulnerability let users with ALL permissions except root ((ALL, !root)) bypass the restriction by specifying user ID -1:
sudo -u#-1 id
# Returns: uid=0(root)
The vulnerability exploited how sudo interpreted -1 as 4294967295, which mapped back to root.
Analyzing Sudo Rules
Always check your permissions with:
sudo -l
This reveals what you can run and under which users—your roadmap for privilege escalation.
Key Takeaway: Sudo misconfigurations transform seemingly limited permissions into full root access through wildcards, command injection, and software vulnerabilities—always audit sudo rules and apply least privilege principles.