Capabilities Abuse
Linux capabilities provide a more fine-grained access control system than the traditional Linux permissions model. They allow specific privileges to be granted to processes without giving them full root access.
Finding Files with Capabilities
# List all files with capabilities set on the system
getcap -r / 2>/dev/nullCommon Dangerous Capabilities
CAP_SETUID
The CAP_SETUID capability allows a process to set user IDs, including setting the effective user ID to root.
Example of exploitation with Python:
# If Python has cap_setuid capability
getcap -r / 2>/dev/null | grep python
# Example output: /usr/bin/python3.7 = cap_setuid+ep
# Exploit to get a root shell
/usr/bin/python3.7 -c 'import os; os.setuid(0); os.system("/bin/bash")'CAP_SETGID
Similar to CAP_SETUID, but for group IDs.
Example:
CAP_DAC_READ_SEARCH
This capability allows bypassing file read permission checks and directory read/execute permission checks.
Example:
CAP_DAC_OVERRIDE
This capability bypasses file read, write, and execute permission checks.
Example:
Exploitable Binaries with Capabilities
Python with cap_setuid
If Python has the cap_setuid capability, you can exploit it to get a root shell:
Perl with Capabilities
Perl with certain capabilities can also be exploited:
Node.js with Capabilities
Node.js can be exploited if it has capabilities:
Other Languages and Binaries
Similar techniques can be used with other interpreted languages if they have capabilities set:
Ruby
PHP
Lua
Setting Capabilities (for Educational Purposes)
If you want to understand how capabilities are set:
Viewing Information About Capabilities
Capabilities During Penetration Testing
When performing penetration testing on a Linux system:
Always check for files with capabilities set
Focus on binaries with dangerous capabilities like setuid, setgid, and dac_override
Check interpreted language binaries especially (Python, Perl, Ruby, etc.)
Look for unusual or custom binaries with capabilities
Additional Resources
GTFOBins - Check for capabilities section for each binary
Last updated