Overview
Linux privilege escalation involves finding and exploiting misconfigurations, vulnerable software, weak permissions, or kernel vulnerabilities to elevate from a low-privilege user to root. This page covers the most impactful techniques with practical commands.System Enumeration
OS and Kernel Information
Environment Variables
Interesting information, passwords, or API keys may live in environment variables:Sudo Version Check
Sudo versions before 1.9.17p1 allow unprivileged local users to escalate via
sudo --chroot when /etc/nsswitch.conf is in a user-controlled directory (CVE-2025-32463). For versions below 1.8.28: sudo -u#-1 /bin/bashSUDO and SUID Exploitation
Enumerating Sudo Permissions
Enumerating Sudo Permissions
NOPASSWD Exploitation
NOPASSWD Exploitation
If Exploit it:
sudo -l shows a NOPASSWD entry:SETENV and PYTHONPATH Hijacking
SETENV and PYTHONPATH Hijacking
If sudo allows SETENV:
BASH_ENV Preserved via sudo env_keep
BASH_ENV Preserved via sudo env_keep
If
env_keep includes BASH_ENV:PATH Hijacking via sudo
PATH Hijacking via sudo
If
sudo -l shows env_keep+=PATH or a writable entry in secure_path:LD_PRELOAD Abuse
LD_PRELOAD Abuse
If sudo preserves LD_PRELOAD:
Cron Job Abuse
1
Enumerate Cron Jobs
2
Cron PATH Hijacking
If a cron job runs a script without full path and the cron PATH includes a user-writable directory:
3
Wildcard Injection
When a cron job uses
* in a command like rsync:4
Cron Script Overwrite
If you can modify a cron script:
5
Monitor Frequent Cron Jobs
Use pspy or manual process monitoring to spot short-interval crons:
Services and Systemd
Writable Service Files
Writable Service Files
If you can write to a
.service file, add a backdoor:Systemd PATH Relative Binary Hijacking
Systemd PATH Relative Binary Hijacking
Check the systemd PATH and look for relative command use in service files:Create an executable with the same name in a writable PATH directory.
Writable Socket Files
Writable Socket Files
Add a backdoor to
.socket files:Socket Activation — Missing Service File
Socket Activation — Missing Service File
If a socket references a non-existent service and you can write to
/etc/systemd/system:Process Memory Credential Dumping
Memory Dump Script
mimipenguin
The tool mimipenguin steals cleartext credentials from memory:Network Enumeration
Docker Socket Privilege Escalation
If/var/run/docker.sock is writable:
D-Bus Privilege Escalation
D-Bus is an IPC system that can allow privilege escalation if misconfigured policies exist:SUID / SGID Binaries
SUID binaries run with the file owner’s permissions (typically root). Find and exploit them:Linux Capabilities
Capabilities are fine-grained privileges. Find binaries with dangerous capabilities:
Examples:
Kernel Exploits
Search for kernel exploits matching the target version:Writable PATH and Environment
Credentials in Files
References
- GTFOBins — Unix binaries for privilege escalation
- LinPEAS
- pspy — Process monitoring without root
- linux-exploit-suggester
- CVE-2025-32463 sudo chroot vulnerability