How to Trace Kernel Security Capability Checks in Linux Using capable

Traditional Unix security follows a coarse-grained binary permission model: a process either executes with standard unprivileged user privileges (UID > 0) or possesses complete, unrestricted superuser privileges (UID 0 / root). To avoid granting full root permissions to daemon processes, Linux partitions superuser authority into discrete POSIX capabilities—such as CAP_NET_ADMIN for network configuration, CAP_SYS_ADMIN for filesystem mounts, or CAP_DAC_OVERRIDE for bypassing file read/write permissions. When configuring secure Docker/Kubernetes container profiles, systemd sandboxes, or debugging permission errors, the BCC eBPF tool capable traces every kernel capability check in real time.

Understanding Linux POSIX Capabilities and kernel Security Checks

Whenever a program performs a privileged operation—such as opening a raw socket, changing system time, or loading a kernel module—the Linux kernel invokes the internal security function cap_capable() (or security_capable()). The kernel checks whether the calling process possesses the necessary capability flag in its effective capability set.

POSIX capabilities are grouped into logical operational domains:

  • CAP_NET_BIND_SERVICE: Grants permission to bind network sockets to privileged ports (port numbers below 1024).
  • CAP_NET_RAW: Allows the use of RAW and PACKET sockets (e.g. for running ping or tcpdump).
  • CAP_SYS_PTRACE: Permits process tracing and memory inspection using ptrace or debugging tools.
  • CAP_SYS_ADMIN: The most powerful general capability, encompassing device mounts, swap configuration, and low-level disk management.
  • CAP_DAC_READ_SEARCH: Bypasses file read permission checks and directory read/execute search permission checks.

Installing the BCC Tools Suite

The capable tool is part of the BPF Compiler Collection (BCC). Install BCC along with corresponding kernel headers:

# Ubuntu / Debian
sudo apt-get update
sudo apt-get install -y bpfcc-tools linux-headers-$(uname -r)

# RHEL 9 / Rocky Linux 9 / AlmaLinux
sudo dnf install -y bcc-tools kernel-devel-$(uname -r)

# Verify executable path
which capable || which /usr/share/bcc/tools/capable

Running capable to Trace Capability Invocations

To begin real-time auditing across the entire operating system, launch capable with superuser privileges:

sudo /usr/share/bcc/tools/capable

Whenever an application invokes a privileged system call, capable prints an event line:

TIME     UID   PID     COMM             CAP                  NAME                 AUDIT  VERDICT
05:14:12 1000  28192   node             CAP_NET_BIND_SERVICE cap_net_bind_service 1      FAIL
05:14:18 0     1420    dockerd          CAP_SYS_ADMIN        cap_sys_admin        1      PASS
05:14:23 1000  29104   ping             CAP_NET_RAW          cap_net_raw          1      PASS
05:14:35 1000  30122   nginx            CAP_DAC_OVERRIDE     cap_dac_override     1      FAIL

Interpreting Output Columns and Verdicts

The output columns convey critical security context:

  • TIME: Timestamp of the kernel permission evaluation.
  • UID: The user ID running the process.
  • PID: The process identifier.
  • COMM: The executable command name.
  • CAP: The numeric constant or macro name of the requested capability.
  • NAME: The human-readable POSIX capability string.
  • AUDIT: Indicates whether the check triggers a Linux audit subsystem log event.
  • VERDICT: Indicates whether the kernel approved or rejected the request (PASS or FAIL).

Filtering Denials and Container Capability Hardening

When authoring least-privilege Dockerfiles or Kubernetes SecurityContext definitions, you need to identify precisely which capabilities a service genuinely requires rather than blindly granting --privileged:

  1. Filter for permission rejections using the -v flag to display non-audit capability requests or pipe through grep:
    sudo /usr/share/bcc/tools/capable -K | grep -i FAIL
  2. The -K flag instructs capable to print the full kernel call stack leading to the capability check, revealing exactly which system call and kernel function required elevated rights.
  3. If an application fails with CAP_NET_BIND_SERVICE FAIL while attempting to bind port 443 as a non-root user, grant only that specific capability using setcap:
    sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/myapp
  4. In Kubernetes manifests, strip all capabilities and add back only the validated essentials:
    securityContext:
      capabilities:
        drop:
          - ALL
        add:
          - NET_BIND_SERVICE

By monitoring security capability evaluations with capable, systems administrators and DevOps engineers can eliminate dangerous root privileges and implement precise, least-privilege security boundaries across Linux infrastructure.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.