Course contentsShow
← Security
Lesson 2143 of 3,05242. Penetration Testing and Red TeamingFree lesson

Exploiting Capabilities for Escalation

Understanding Linux capabilities and exploiting binaries with dangerous capabilities like CAP_SETUID.

Exploiting Capabilities for Escalation

You'll learn: How Linux capabilities can be abused to escalate privileges even without SUID binaries.

What Are Linux Capabilities?

Traditional Unix systems have a binary privilege model: you're either root (all-powerful) or a regular user (limited). Linux capabilities break root's power into smaller, granular privileges that can be assigned independently to processes and files.

Think of capabilities like specialized keys on a janitor's keyring. Instead of one master key (root), you might have separate keys for "open doors" (CAP_DAC_OVERRIDE), "change ownership" (CAP_CHOWN), or "become any user" (CAP_SETUID). This allows programs to perform specific privileged operations without needing full root access.

The Security Risk

The problem arises when dangerous capabilities are assigned to binaries that regular users can execute. If you find a binary with CAP_SETUID, for example, it can change its effective user ID to any user—including root—without being SUID root itself.

Real-World Exploitation

Check capabilities with:

getcap -r / 2>/dev/null

If you discover /usr/bin/python3 has CAP_SETUID, you can exploit it:

import os
os.setuid(0)  # Become root (UID 0)
os.system("/bin/bash")

Other dangerous capabilities include:

  • CAP_DAC_OVERRIDE: Read/write any file
  • CAP_SYS_ADMIN: Mount filesystems, load kernel modules
  • CAP_SYS_PTRACE: Inject code into other processes

Capabilities bypass traditional SUID detection tools, making them a stealthy privilege escalation vector during penetration tests.

Key Takeaway: Linux capabilities fragment root privileges into granular permissions—when dangerous capabilities like CAP_SETUID are assigned to user-accessible binaries, they create privilege escalation paths that bypass traditional SUID protections.