Appearance
46. Privilege Escalation
Gaining more access than you're supposed to have — from a normal user up toward root/admin/kernel access.
- Horizontal: accessing another user's resources at the same privilege level (User A reading User B's files).
- Vertical (more dangerous): climbing from a lower privilege ring to a higher one — e.g., Ring 3 (user space) to Ring 0 (kernel).
Common techniques:
- SUID exploitation — a SUID binary runs as its owner, not its caller (
passwdruns as root even for normal users); attackers hunt for exploitable SUID binaries (find / -perm -4000). - Kernel exploits — a bug in the kernel itself lets a user process execute code with kernel-level access.
- Sudo misconfiguration — e.g.,
NOPASSWDaccess to an editor that can shell out (:!bashinsidevim) effectively grants a root shell. - Weak file permissions — a world-writable
/etc/passwdlets an attacker add a root user directly. - PATH hijacking — a root script calling a command without its full path (
system("ls")) can be tricked into running an attacker's malicious binary placed earlier inPATH.
Defense: principle of least privilege, regular SUID audits, keeping the kernel patched (kernel exploits are the most dangerous class), mandatory access control (SELinux/AppArmor), and careful sudo configuration.