Deep Dive into Linux Privilege Escalation
Exploring SUID abuse, capabilities, sudo misconfigurations, and kernel exploits used to win root on modern Linux systems.
A user shell on a Linux box is the start of a chess game against a kernel that has accumulated 30 years of features, syscalls, and edge cases. The path from nobody or www-data to UID 0 rarely depends on a single exploit; it depends on a methodical reading of sudo -l, getcap -r /, find / -perm -4000, and /etc/cron.d. This deep dive covers the modern Linux escalation arsenal in 2026.
Core Concepts
Linux access control sits on three legs: the UID/GID model with traditional discretionary permissions, capabilities (POSIX.1e) that decompose root's powers into 41+ granular flags, and Linux Security Modules (SELinux, AppArmor) that overlay mandatory access control. Namespaces (mount, PID, user, network) add containerization isolation, and seccomp filters can block syscalls outright.
Privilege boundaries in Linux are surprisingly soft: a single misconfigured setcap cap_dac_read_search+ep /usr/bin/cat lets an attacker read /etc/shadow. Understanding which capabilities, SUID binaries, sudo rules, and writable cron jobs translate to root is the entire game.
The canonical enumeration toolkit:
linpeas.sh— automated, color-coded, comprehensive.LinEnum,linux-smart-enumeration— alternative scanners.pspy— observes process spawns without root, exposes cron and systemd timers.GTFOBins— the curated database of binaries that can be abused to escape restricted shells, escalate, or read files.
SUID, SGID, and Capabilities
The set-user-ID bit makes a binary execute with the owner's UID. Root-owned SUID binaries are escalation gold:
find / -perm -4000 -type f 2>/dev/null
Modern attacks rarely involve exploiting buffer overflows in passwd or mount. Instead, GTFOBins documents how to abuse the intended functionality of dozens of standard binaries:
find . -exec /bin/sh -p \; -quit— iffindis SUID, gives a root shell.awk 'BEGIN {system("/bin/sh -p")}'— SUIDawk.vim.basic -c ':!/bin/sh -p'— SUIDvim.cpSUID with--no-preserve=modeto overwrite/etc/passwd.
Capabilities split root into pieces, but several pieces are equivalent to root:
cap_dac_read_search— read any file (shadow, SSH keys).cap_setuid— change UID;python -c 'import os; os.setuid(0); os.system("sh")'.cap_sys_admin— effectively root; mount filesystems, change namespaces.cap_sys_ptrace— attach to any process, inject shellcode.cap_chown,cap_fowner— overwrite key files' ownership/permissions.
getcap -r / 2>/dev/null
Sudo Misconfigurations
sudo -l is the single most rewarding command on a fresh Linux foothold. Look for:
- NOPASSWD entries for unusual binaries.
- Wildcards in command paths (
/usr/bin/cat /var/log/*) — append arguments to escape. - Editor escapes —
sudoedit,vim,less,more,man,nanoall permit shell escapes (GTFOBins). LD_PRELOAD/LD_LIBRARY_PATHpreserved inenv_keep— write a shared object with_init(), preload it, root.- Sudo CVEs —
Baron Samedit(CVE-2021-3156) heap overflow in sudo, exploitable without any sudo permissions;CVE-2023-22809sudoeditarbitrary file write viaEDITOR=$EDITOR -- /etc/passwd.
# Baron Samedit check
sudoedit -s '\' $(python3 -c 'print("A"*1000)')
# Segfault → likely vulnerable
Cron Jobs, Systemd Timers, and Writable Paths
Scheduled tasks run with the scheduler's privileges. cat /etc/crontab, ls /etc/cron.*, systemctl list-timers --all, and pspy64 reveal them. Common wins:
- World-writable scripts invoked by root cron — append your payload.
- Wildcards in tar/rsync/zip invoked by root —
tarwildcard injection via--checkpoint-action=exec=shfiles like--checkpoint=1in the target directory. - Relative PATH in a root-cron script — drop a malicious binary earlier in PATH.
- Writable systemd unit files (
/etc/systemd/system/*.service) — modifyExecStart=, thensystemctl restart.
Kernel Exploits
When userland is locked down, the kernel surface remains. Modern wins:
- Dirty Pipe (CVE-2022-0847) — splice-flag handling lets a low-priv user write to read-only files (overwrite
/etc/passwdor hijack SUID binaries). Affects 5.8+ until 5.16.11. - Dirty COW (CVE-2016-5195) — classic race in COW handling, used by ransomware and rootkits for years.
- GameOver(lay) (CVE-2023-2640 / 2023-32629) — Ubuntu OverlayFS LPE.
- nf_tables (CVE-2024-1086) — use-after-free in netfilter, root via unprivileged user namespaces.
- PwnKit (CVE-2021-4034) — polkit's
pkexecargument-handling LPE; 12-year-old bug, present on default installs of every major distro.
# PwnKit one-liner check
ls -l $(which pkexec) # SUID? Likely vulnerable on pre-2022 systems.
Container breakouts deserve their own line: Leaky Vessels (CVE-2024-21626) in runc, Dirty Pipe inside containers, and abuse of mounted Docker sockets all turn container root into host root.
Misconfigurations and Stored Credentials
- NFS no_root_squash — mount the export, drop a SUID
bash, execute on the target. - Writable
/etc/passwd— append a line with a known password hash and UID 0. - Docker group membership —
docker run -v /:/mnt -it alpine chroot /mnt sh= root. - LXD/LXC group — similar mount-host trick via an image.
- SSH keys in
/home/*/.ssh/, backup archives, or.bash_history. - Database credentials in
wp-config.php,.env,application.ymlfiles. - Hard-coded credentials in custom service binaries —
stringsis your friend.
Real-world Examples
Volt Typhoon (Chinese state actor) used Linux router and edge-device escalations via vendor-default SSH keys and weak sudo rules to maintain persistence in US critical infrastructure throughout 2023–2024. Looney Tunables (CVE-2023-4911) glibc tunables overflow gave attackers an LPE on virtually every Linux distro for months; Mandiant and Crowdstrike reported active exploitation by initial-access brokers feeding ransomware affiliates. Kinsing cryptominer routinely escalates inside misconfigured Kubernetes pods via mounted Docker sockets and writable /proc/sys/kernel/core_pattern.
Best Practices & Mitigation
- Patch promptly. Sudo, polkit, glibc, and kernel CVEs are the bread and butter of post-exploitation; an unpatched 60-day-old box is a guaranteed root.
- Minimize SUID surface.
chmod u-son binaries you do not need. Replace with capabilities only where strictly required. - Lock down sudoers. No wildcards, no
NOPASSWDfor shells or editors,Defaults env_reset, and explicitDefaults secure_path. - Disable unprivileged user namespaces (
kernel.unprivileged_userns_clone=0) — closes a huge class of recent LPEs. - Enable SELinux/AppArmor in enforcing mode and write profiles for custom services.
- Run containers rootless or with
--security-opt no-new-privilegesand a tight seccomp profile. - Audit cron and systemd for writable scripts, relative paths, and wildcard misuse.
- Linux Audit (
auditd) + Falco for runtime detection ofexecvefrom/tmp, mounts inside containers, capability changes, and unexpected SUID invocations. - Use
pam_faillock,fail2ban, and SSH key-only auth to prevent the foothold in the first place.
Linux privilege escalation rewards patience and pattern recognition. The kernel, sudo, capabilities, and scheduled tasks form a vast misconfiguration surface where a single oversight collapses the security model. The same linpeas.sh run that an attacker performs in 30 seconds will identify 80% of your escalation paths — run it yourself, on every server, and treat the findings with the same urgency as a CVE patch.
Ready to test your knowledge? Take the Linux Privilege Escalation MCQ Quiz on HackCert today!

