100 ways to achieve privilege escalation in Linux
Privilege escalation in a Linux environment can be achieved through a variety of methods, often depending on misconfigurations, vulnerabilities, or unintended behaviors in the system. Here’s a list of 100 potential ways to escalate privileges from a non-root user to a root user. These are categorized into common areas like misconfigurations, vulnerabilities, binaries, and kernel exploits.
1-20: Misconfigurations
- World-writable files in sensitive directories like
/etc/
. - Misconfigured
sudo
privileges allowing execution of unintended binaries. - Misconfigured
setuid
binaries owned by root. - Writable
/etc/passwd
or/etc/shadow
. - Writable
/etc/sudoers
or/etc/sudoers.d/
. - Cron jobs running as root with writable scripts.
- Writable
/var/spool/cron/
directory. - Root-owned files with improper ACL permissions.
- Sticky-bit misconfigurations on sensitive directories.
- Writable scripts executed by services running as root.
- SSH keys in
/root/.ssh/
with world-readable permissions. - World-writable
/var/log/
files. - Incorrect permissions on kernel module files.
- Improper permissions on shared libraries.
- Misconfigured
capabilities
(e.g., binaries withCAP_SYS_ADMIN
). - NFS exports with
no_root_squash
enabled. - Improper mount options (
exec
in/tmp
or/home
). - User writable
/dev
devices. - Writable
LD_PRELOAD
directories. docker
group membership allowing root-level access.
21-40: Exploitable Binaries
- Exploiting
vi
/vim
throughsudo
with improper configurations. - Exploiting
less
when invoked withsudo
. - Using
awk
to escalate privileges viasudo
. - Using
python
to execute arbitrary code withsudo
. - Exploiting
tar
withsudo
for arbitrary file writes. - Using
find
withsudo
to execute arbitrary commands. - Exploiting
bash
withsudo
to open a root shell. - Using
perl
to execute code withsudo
. - Exploiting
rsync
with root permissions. - Using
cp
to overwrite critical files withsudo
. - Exploiting
git
when configured with root access. - Using
scp
to overwrite files viasudo
. - Leveraging
zip
orunzip
for privilege escalation. - Exploiting
mysql
to gain code execution. - Using
vim
temporary files to escalate privileges. - Exploiting
journalctl
with improper configurations. - Using
env
withsudo
for privilege escalation. - Misusing
screen
if running with setuid or sudo. - Exploiting
tmux
session misconfigurations. - Using
node.js
ornode
insudo
context.
41-60: Kernel and Software Vulnerabilities
- Exploiting
Dirty COW
(CVE-2016-5195). - Exploiting
OverlayFS
vulnerabilities (e.g., CVE-2021-3493). - Exploiting
polkit
vulnerabilities (e.g., CVE-2021-4034). - Exploiting vulnerable
sudo
versions (e.g., CVE-2019-14287). - Exploiting
systemd
vulnerabilities. - Exploiting
ptrace
to attach to a privileged process. - Exploiting vulnerable
X11
configurations. - Exploiting
SELinux
bypass vulnerabilities. - Exploiting vulnerable kernel versions (e.g., buffer overflows).
- Exploiting
glibc
vulnerabilities. - Exploiting
snapd
vulnerabilities. - Exploiting
Apache
misconfigurations or vulnerabilities. - Leveraging
CVE-2018-14665
(Xorg exploit). - Exploiting SSH agent forwarding vulnerabilities.
- Exploiting container breakout vulnerabilities.
- Using
overlay
mount escape in containers. - Kernel module exploits like
RDS
(CVE-2010-3904). - Leveraging
cron
race conditions. - Exploiting
chroot
escapes. - Exploiting vulnerable applications with privilege escalation paths.
61-80: Abusing Services
- Exploiting vulnerable web applications.
- Manipulating database services (e.g., MySQL, PostgreSQL).
- Exploiting
openvpn
misconfigurations. - Leveraging misconfigured
rsync
services. - Exploiting
tftp
orftp
with root files. - Exploiting vulnerable SMB shares.
- Using NFS shares with weak permissions.
- Abusing
cups
(printing service) vulnerabilities. - Exploiting email services running as root.
- Abusing
systemd
service file misconfigurations. - Exploiting
docker.sock
for container breakout. - Manipulating
kubernetes
configurations for root access. - Exploiting vulnerable
cron
jobs for root users. - Misconfigurations in
PHP
or web server modules. - Exploiting weak database passwords for services running as root.
- Exploiting vulnerable or exposed admin interfaces.
- Abusing
sudoedit
for file overwrite attacks. - Manipulating
journalctl
for command injection. - Leveraging
nmap
with root capabilities. - Exploiting misconfigured
rsyslog
service.
81-100: Advanced Techniques
- Kernel rootkits for privilege escalation.
- Exploiting
/proc
pseudo-filesystem vulnerabilities. - Leveraging writable
LD_LIBRARY_PATH
for library injection. - Exploiting race conditions in system calls.
- Using
ptrace
to hijack root processes. - Exploiting
/etc/environment
file manipulation. - Using
pivot_root
for privilege escalation. - Exploiting
cgroups
misconfigurations. - Leveraging
dbus
for privilege escalation. - Exploiting
/run
directory misconfigurations. - Manipulating PAM modules for root access.
- Using fake binaries in
PATH
for privilege escalation. - Injecting malicious commands into
.bashrc
of root. - Exploiting writable
/boot/
directory. - Abusing
passwd
command with setuid. - Exploiting
init
system configurations. - Leveraging misconfigured network services (e.g., DHCP).
- Exploiting legacy or abandoned software.
- Using symbolic links to overwrite sensitive files.
- Exploiting user-to-root trust relationships (e.g., SSH keys).
Final Notes
- Always get permission before testing these techniques (penetration testing or ethical hacking).
- Many methods require specific preconditions like vulnerable software, misconfigurations, or inadequate permissions.
- Keeping your Linux system updated and configured properly can mitigate many of these risks.