
Linux Security
Linux privilege escalation techniques, system hardening, and vulnerability exploitation for penetration testing and security assessments.
Overview
These notes cover local privilege escalation on Linux: the misconfigurations that turn a low-privileged shell into root, the kernel bugs to fall back on when nothing else works, and the hardening steps that close each path.
Privilege escalation techniques
Sudo and permissions
- Sudo Misconfigurations: dangerous sudo rules and how to abuse them
- Capabilities: binaries with Linux capabilities that hand out root-level actions
- Privileged Groups: groups such as docker, lxd, disk and adm that amount to root
Code execution and injection
- Python Library Hijacking: get code into a root-run Python script through its imports
- Shared Object Hijacking: LD_PRELOAD, RUNPATH and missing libraries
- PATH Abuse: plant a binary earlier in PATH than the one a privileged script calls
Scheduled tasks and services
- Cron Job Abuse: writable cron scripts and the directories around them
- Logrotate Exploitation: the logrotate race condition and logrotten
- Wildcard Abuse: filenames that become options when a root script expands
*
Kernel exploitation
- Kernel Exploits: public kernel exploits for when the misconfiguration paths come up empty
System hardening
- Linux Hardening: the defensive side of the same paths
Attack methodology
Phase 1: enumeration
Run LinPEAS or LinEnum and read the output for:
- User privileges and group memberships
- Sudo permissions and SUID binaries
- Cron jobs and scheduled tasks
- Kernel version and installed software
- File permissions and capabilities
- Network services and configurations
Phase 2: privilege analysis
Look for:
- Dangerous sudo rules (NOPASSWD, wildcards)
- SUID/SGID binaries
- Writable files in privileged locations
- Exploitable capabilities
- Cron jobs with path injection points
- Outdated kernel versions
Phase 3: exploitation
- Abuse the misconfigurations found in phase 2
- Exploit vulnerable software versions
- Abuse intended functionality
- Chain several weaker issues when no single one gets you root
Phase 4: persistence
- SSH key installation
- Cron job backdoors
- Modified system binaries
- PAM backdoors
- Kernel module rootkits
Enumeration tools
| Tool | Primary use |
|---|---|
| LinPEAS | Automated privilege escalation enumeration |
| LinEnum | System enumeration script |
| pspy | Process monitoring without root |
| GTFOBins | SUID/sudo exploit database |
Common SUID binaries
These standard binaries can give root command execution or file access when they have the SUID bit set (nmap only in old versions with --interactive):
/usr/bin/find/usr/bin/vim/usr/bin/nmap/usr/bin/python/usr/bin/perl
GTFOBins has the exact command for each.
Related resources
- Windows Security: the Windows side of privilege escalation
- Container Security: Docker and container escapes
- Network Protocol Attacks: SSH and other protocols
Living Off the Land Binaries (LOLBAS)
Abusing signed Windows binaries for proxy execution, file downloads and defense evasion without dropping custom malware.
Linux Capabilities Exploitation for Privilege Escalation
Technical guide to exploiting Linux capabilities for privilege escalation, focusing on dangerous capabilities like CAP_DAC_OVERRIDE, CAP_SYS_ADMIN, and CAP_SETUID.