SUID / SGID Binary Abuse
Concept
A SUID binary runs with its owner's privileges (often root) regardless of who executes it. If that binary can be made to spawn a shell, read arbitrary files, or write files, a low-privileged user can leverage it to escalate.
When to Use
- Always check on every box — it's one of the first privesc enumeration steps.
- After LinPEAS/manual enumeration flags a non-default SUID binary.
Workflow
- 1Enumerate SUID/SGID binaries
find across the filesystem.
- 2Diff against a known-default list
Focus on anything non-standard.
- 3Check GTFOBins for each binary
Look up a working escalation primitive.
- 4Execute the GTFOBins technique
Confirm shell/file-read as root.
Commands
find / -perm -4000 -type f 2>/dev/nullfind / -perm -4000 -type f 2>/dev/null
Lists every file on the filesystem with the SUID bit set.
-perm -4000— Match files with the SUID bit (4000 octal) set.2>/dev/null— Suppress 'Permission denied' noise from directories you can't read.
When to use: Standard first command in Linux privesc enumeration.
Expected output:
/usr/bin/passwd /usr/bin/find /usr/local/bin/backup
Look for: Anything outside the standard set (passwd, su, sudo, mount, ping, etc.) — e.g. find, vim, python, or a custom script.
Next step: Look up each non-default binary on GTFOBins for a SUID exploitation technique.
find / -perm -2000 -type f 2>/dev/nullfind / -perm -2000 -type f 2>/dev/null
Lists SGID binaries (run with the owning group's privileges).
-perm -2000— Match the SGID bit.
When to use: Alongside the SUID check — SGID to a privileged group (e.g. shadow, docker) is also exploitable.
Expected output:
/usr/bin/wall
Look for: Binaries SGID to an interesting group, not just the common defaults.
Next step: Check what that group grants access to (e.g. SGID shadow could let you read /etc/shadow).
BINARY_PATH -p/usr/bin/find . -exec /bin/sh -p \; -quit
GTFOBins-style example: abusing SUID 'find' to spawn a root shell via -exec.
-p— Tells sh to preserve privileges (don't drop the effective UID) when started by a SUID binary.
When to use: When 'find' itself is SUID-root (rare but a classic CTF setup).
Expected output:
# (root shell prompt)
Look for: Prompt changes to # and 'id' shows uid=0(root).
Next step: Confirm with id; then grab the flag or continue persistence/cleanup per the challenge.
Tools
GTFOBins
Curated database of Unix binaries and their privilege-escalation/shell-escape techniques when SUID, sudo-able, or otherwise abusable.
When to use: Any time you find a SUID/SGID/sudo-allowed binary — check it here before assuming it's a dead end.
Browse gtfobins.github.io, search the binary name (offline copy recommended for CTFs without internet).Example workflow: find turns up /usr/bin/php as SUID -> GTFOBins shows: php -r "posix_setuid(0); system('/bin/sh');"
LinPEAS
Automated Linux privilege-escalation enumeration script; flags SUID/SGID/capabilities/cron/etc. in one pass.
When to use: Run early on every box once you have a shell, to not miss anything manual enumeration would catch anyway.
Preinstalled nowhere by default — download from the PEASS-ng GitHub release and transfer to the target../linpeas.sh | tee linpeas-output.txtExample workflow: Transfer via python3 http.server + curl/wget on target, run, then grep output for highlighted (colored) findings.
Findings & Interpretation
Interesting
- Non-default SUID binaries (custom scripts, scripting-language interpreters, archive tools)
Suspicious
- A SUID binary that is world-writable — can be replaced entirely with a malicious binary
False Positives
- Default OS SUID binaries (passwd, su, mount, umount, ping) are expected and not exploitable without a specific known CVE
How to Validate
- Cross-check the exact binary name/version against GTFOBins before spending time crafting a custom exploit
Next Step
- If no SUID binary helps, move to sudo misconfigurations and cron jobs.
- If a shell is obtained as root, confirm persistence isn't required by the challenge and grab the flag.
Troubleshooting
find returns a huge list with no obvious standout.
Likely cause: You're looking at the default OS baseline without a comparison point.
Verify: Compare against a fresh install's SUID list for the same distro, or just check each result on GTFOBins quickly.
Fix: Pipe through LinPEAS instead, which highlights non-default binaries automatically in color.
Recovery: Narrow the search to /opt, /home, /usr/local first — custom binaries are usually placed outside system paths.
Avoid repeating: Don't manually triage huge find output every time — let LinPEAS do the first pass.