Skip to content
Pwnversity
LIN-PRIVESCintermediate · 6 min · upd. 2026-10

Linux Privilege Escalation

T1548

Escalating from an unprivileged user to root is the goal after getting access to a Linux host. You rarely need a kernel exploit: the norm is abusing misconfigurations —SUID, sudo, cron, capabilities, loose permissions, reused credentials— that the admin left exploitable. This card is the overall map of local post-exploitation; each vector has its own card with the detail and commands.

flowchart TD
    A[Low-privilege shell] --> B[Orderly enumeration]
    B --> C{Vector found}
    C -->|sudo -l| D[Sudo abuse / GTFOBins]
    C -->|find -perm -4000| E[SUID/SGID]
    C -->|getcap -r /| F[Capabilities]
    C -->|pspy / cron| G[Cron and timers]
    C -->|grep secrets| H[Reused credentials]
    C -->|groups| I[docker / lxd / disk]
    C -->|uname -a| J[Kernel exploit]
    D & E & F & G & H & I & J --> K[root]
    K --> L[Persistence]

The system trusts permissions, paths, and privileges configured by the admin. The attacker doesn’t break Linux: they use its rules against it. A badly chosen SUID binary, an over-permissive sudo, or a cron task that runs a writable script are, in effect, root for whoever can spot them. Escalation is finding that link; enumeration almost always reveals it, and firing exploits blindly is noisy and unnecessary.

The objective sets the aggressiveness: in a scoped pentest you prioritize reliability and avoiding crashes; in a lab (OSCP, HTB) anything goes. Always work within the agreed scope.

Almost every local escalation exploits one of these misplaced trusts:

  • Trust in a binary’s owner — SUID/SGID runs with the owner’s permissions, not the caller’s.
  • Trust in a delegation rule — sudoers grants running something as root that can be diverted to a shell.
  • Trust in a path or environment — relative PATH, LD_PRELOAD, unsanitized wildcards (wildcard injection).
  • Trust in a granular power — a capability (cap_setuid, cap_dac_read_search) equivalent to partial root.
  • Trust in a recurring process — cron/timer that runs a resource you control as root.
  • Trust in group membership — docker/lxd are root by design.

The kernel only comes into play when none of those trusts is broken: a memory bug in the kernel itself ignores permissions and configuration.

Methodology (most reliable to last resort)

Section titled “Methodology (most reliable to last resort)”
  1. Enumerate methodically (see Linux Enumeration); linpeas summarizes every vector at a glance.
  2. sudo -l and SUID/caps: the most reliable and quietest quick wins.
  3. Cross-reference binaries with GTFOBins for the exact abuse recipe.
  4. pspy to see root cron/processes without privileges.
  5. Reused credentials toward root or another user.
  6. Dangerous groups (docker/lxd/disk).
  7. Kernel only if the rest bears no fruit: noisy and can crash the host.
Ventana de terminal
sudo -l # what can I run as root? (do this FIRST)
find / -perm -4000 -type f 2>/dev/null # root SUID binaries
getcap -r / 2>/dev/null # binaries with capabilities
id # docker/lxd/disk/adm group?
cat /etc/crontab; ls -la /etc/cron.* # scheduled tasks
uname -a # kernel version (last resort)

Each finding is detailed in its own card: Sudo Abuse, SUID/SGID Binaries, Linux Capabilities, Cron Jobs and Timers, Credential Theft, Container and Docker Escapes, Kernel Exploits.

Ventana de terminal
# PATH hijacking: binary/cron calling a command without an absolute path
export PATH=/tmp:$PATH; printf '#!/bin/sh\n/bin/bash -p\n' > /tmp/service; chmod +x /tmp/service
# LD_PRELOAD via sudo with env_keep
sudo LD_PRELOAD=/tmp/x.so <allowed_command>
# NFS no_root_squash: mount the export, create a SUID binary as remote root
# writable /etc/passwd -> add a UID 0 user with a known hash
# openssl emits only the HASH; build the full record and append it yourself:
h=$(openssl passwd -1 -salt x pwn); echo "pwn:$h:0:0:root:/root:/bin/bash" >> /etc/passwd
# then: su pwn (password: pwn) -> UID 0
  • linpeas.sh (PEASS-ng): automatic detection of all the above vectors, highlighted by likelihood.
  • pspy: root processes/cron without privileges.
  • GTFOBins: how to abuse a specific binary (sudo/SUID/caps).
  • linux-exploit-suggester: kernel-exploit candidates by version.
  • auditd on execve of interpreters and shells spawned by EUID 0 processes that previously ran as a user, setuid/setresuid to 0, and writes to /etc/passwd, /etc/shadow, /etc/sudoers.
  • Enumerator execution: linpeas, pspy patterns, bursts of find / -perm, getcap -r /.
  • Execution telemetry (auditd/eBPF, e.g. Falco) over file signatures: record what runs and with which arguments.
  • Least privilege in sudoers: no wildcards, no GTFOBins binaries, NOPASSWD only where essential, env_reset.
  • Review SUID/SGID and capabilities: remove unneeded ones; mount nosuid where applicable.
  • Secure cron: absolute paths, scripts owned by root and non-writable.
  • No credentials in text: managed secrets, 600 permissions.
  • Patch the kernel and sudo/polkit promptly (see patch management); AppArmor/SELinux; no unnecessary dangerous groups.

On signs of escalation: isolate the host, preserve artifacts (Linux DFIR), rotate credentials and keys, and if root was reached, assume persistence compromise and rebuild.