Privilege Escalation: Linux SUID/Sudoers & Windows Token Impersonation

When an ethical penetration tester or adversary initially exploits a web vulnerability (such as a file upload flaw or command injection), they rarely land on the target server as the root superuser or Windows NT AUTHORITY\SYSTEM. Typically, the initial shell executes inside an unprivileged service account (e.g. www-data or a restricted local user). Privilege Escalation (PrivEsc) is the systematic process of exploiting operating system misconfigurations, kernel bugs, or weak permissions to elevate from a restricted user to full administrative control.

Linux Privilege Escalation Vectors

1. Sudo Misconfigurations (NOPASSWD)

The very first command an analyst executes upon catching a Linux shell is sudo -l, which lists what commands the current user can execute with root privileges:

# Check allowed sudo commands
www-data@target:~$ sudo -l

User www-data may run the following commands on target:
    (ALL : ALL) NOPASSWD: /usr/bin/find

If a binary like find can run as sudo without a password, an attacker executes root commands via find's -exec flag:

sudo find . -exec /bin/sh -p ; -quit
# Output: # (You are now ROOT!)

Security researchers reference GTFOBins, an exhaustive curated database of Unix binaries that can be abused to bypass local security restrictions.

2. Exploiting SUID (Set User ID) Binaries

A binary with the SUID bit set (4000) executes with the permissions of the file owner (typically root) rather than the user running it:

Finding SUID Binaries Owned by Root

# Search for all root SUID binaries, discarding error output
find / -perm -4000 -user root -type f 2>/dev/null

Windows Privilege Escalation Vectors

Vulnerability Misconfiguration Mechanism Exploitation Path
Unquoted Service Paths A Windows Service binary path contains spaces and is not wrapped in quotes (e.g. C:\Program Files\My Service\app.exe). Windows interprets spaces as potential executable extensions. An attacker drops a malicious binary at C:\Program.exe; upon reboot, the service executes it as SYSTEM!
AlwaysInstallElevated Windows Registry keys AlwaysInstallElevated set to 1 in both HKLM and HKCU. Allows standard users to install Windows MSI packages with SYSTEM rights. Attacker generates a malicious MSI payload via msfvenom.
Token Impersonation (SeImpersonatePrivilege) Service accounts (like IIS APPPOOL or LOCAL SERVICE) possess the SeImpersonate privilege. Exploited via the "Potato" family of tools (JuicyPotato, SweetPotato) to trick a local RPC service into authenticating and elevating to SYSTEM.

Automated Privilege Escalation Enumerators

Penetration testers automate local enumeration using industry-standard auditing scripts:

  • LinPEAS (Linux Privilege Escalation Awesome Script): Scans Linux systems for kernel CVEs, writable passwords, crons, SUID binaries, and Docker sockets.
  • WinPEAS: Searches Windows machines for service misconfigurations, saved passwords, registry keys, and missing patches.

Frequently Asked Questions (FAQ) - Student & Interview Review

Q1. What is the difference between Vertical and Horizontal Privilege Escalation in OS security?

Vertical Privilege Escalation is moving from a low-privilege user to an administrative superuser (user -> root/SYSTEM). Horizontal Privilege Escalation is accessing another standard user's account at the same privilege tier (userA -> userB).

Q2. How do you remediate an Unquoted Service Path in Windows?

Wrap the service binary path in quotation marks within the Windows Registry: change C:\Program Files\App\service.exe to "C:\Program Files\App\service.exe".

Explore Related Cybersecurity Tutorials & Next Steps

Broaden your defensive and offensive security knowledge across our curriculum:

Penetration Testing Methodology

Post-exploitation tactics to turn a low-privileged shell into full administrative control.

Cyber Kill Chain & MITRE TA0004

Adversary TTPs for elevating privileges on Linux servers and Active Directory.

Container Security Hardening

Mitigating SUID and capability abuses through unprivileged user namespaces.

40+ Hands-on Cybersecurity Labs

Hands-on lab finding misconfigured Sudoers rights and SUID binaries in Linux.

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!