File Capabilities Narrow Root, but the Wrong Executable Can Widen It
Linux file capabilities let an executable receive a subset of root's powers without running as root. Instead of setting the setuid bit on a binary, an administrator can grant CAP_NET_BIND_SERVICE or another capability to the file. The kernel stores the capability set in a security.capability extended attribute and applies it during execve.
The model is narrower than full root, but it creates a direct relationship between a file and a privilege. A writable or replaceable executable with a powerful capability can become a privilege-escalation path. The risk is greater when a package upgrade, backup restore or deployment tool preserves the extended attribute on a file that is no longer reviewed.
Understand the sets
A process has permitted, effective and inheritable capability sets. File capabilities describe what an executable can add during execution. The effective bit determines whether the permitted capabilities are available to the process immediately. Ambient capabilities can also carry a limited set across execve, but they do not make a script with file capabilities privileged.
Use getcap -r to inventory file capabilities across the filesystem and getcap on individual binaries before and after upgrades. Compare the result with the package's intended behavior and the service's actual needs. A binary that only needs to bind a low port should not receive CAP_SYS_ADMIN, CAP_DAC_OVERRIDE or CAP_SETUID.
The filesystem matters. Mount options and kernel policy can change whether capabilities are honored. A nosuid mount is not a complete substitute for removing file capabilities, and a no_file_caps boot option has system-wide consequences. Test the actual production mount and service unit rather than assuming a security note applies.
Watch the executable transition
Capabilities are attached to a file, but a service may execute another interpreter, wrapper or helper. A shell script with an xattr is not granted the same privilege as a native binary, and an interpreter that loads user-controlled code can change the attack surface. Review the full execution path, including ExecStart, wrapper scripts and environment files.
Package management is a common source of drift. An upgrade may install a new binary without the old capability, causing an outage, or it may preserve a capability that the new version no longer needs. Containers and immutable images need an explicit policy for file capabilities because image builds can copy extended attributes and deployment systems may normalize them differently.
Replace broad capabilities with service design
If a service needs one network privilege, use the smallest capability that satisfies it. If it needs to read a protected file, consider file ownership, an ACL or a dedicated proxy before granting CAP_DAC_OVERRIDE. If it needs to change identity, run it under a service manager with a user and a constrained capability set instead of giving the binary a persistent root-like privilege.
Monitor changes to files with security capabilities as security-relevant configuration. Alert on additions outside an approved package, unexpected changes to ownership or permissions, and capabilities on files in writable deployment directories. Record the package version, file digest and capability set so an investigation can distinguish a legitimate upgrade from a local modification.
File capabilities are useful precisely because they are narrow. That benefit disappears when the executable can be replaced, the capability set is broader than the service needs or the change is never reviewed. The control should be treated as a privileged deployment artifact with an owner and a lifecycle.