---
title: "Capabilities"
url: https://www.daytona.com/compute-glossary/kernel/capabilities
---

# Capabilities

Part of the [Compute Glossary](https://www.daytona.com/compute-glossary.md), section [Kernel](https://www.daytona.com/compute-glossary/kernel.md).

Also called Linux capabilities.

Capabilities are the separate privileges into which Linux splits the powers of the root user. Traditional Unix knew two kinds of process: those run by root, which pass every permission check, and all others. Linux instead checks one capability for each privileged action, such as CAP_NET_ADMIN for changing network settings. The kernel defines about forty of them, and a process can hold any mix.

They exist so that a program can get only the privileges its job needs. A web server that must listen on a port below 1024 needs only CAP_NET_BIND_SERVICE, not full root. An attacker who takes over such a program gains that one power rather than the whole machine. Program files can also carry capabilities, which replaces many programs that used to run as setuid root.

Capabilities sit inside the permission checks of the [kernel](https://www.daytona.com/compute-glossary/kernel/kernel.md), so they cost almost nothing to use. Together with [namespaces](https://www.daytona.com/compute-glossary/kernel/namespace.md) and [seccomp](https://www.daytona.com/compute-glossary/kernel/seccomp.md) filters, they turn ordinary [processes](https://www.daytona.com/compute-glossary/kernel/process.md) into a [container](https://www.daytona.com/compute-glossary/virtualization/container.md). A sandbox that shares the host kernel runs its code with most capabilities removed. In a sandbox built on a [virtual machine](https://www.daytona.com/compute-glossary/virtualization/virtual-machine.md), code may hold every capability, because the guest kernel is not the host's.

## Capability sets

Capability sets are the lists through which the kernel tracks which capabilities each thread has. The effective set holds the ones the kernel checks right now, and the permitted set holds the ones the thread may switch on. A thread can drop a capability from its effective set and raise it again later, as long as it stays permitted. Once it leaves the permitted set, the thread cannot raise it again itself, though starting a program with file capabilities can restore it.

The bounding set limits which capabilities a process can gain from the file of a program it starts. Children inherit it, and a capability removed from it cannot be added back. Two more sets, inheritable and ambient, control what passes on when a process starts a new program. A capability in the inheritable set of the process can still pass to a program whose file also marks it inheritable. A root process that starts a new program gets the capabilities in its bounding set, not all of them.

## Container defaults

Container defaults are the capabilities a runtime leaves to the processes in a container, a short list chosen so that common programs still run. Docker keeps 14 by default, such as changing file owners and binding to low ports, and removes the rest from every set. Among those removed are CAP_SYS_ADMIN and CAP_SYS_MODULE, which loads code into the kernel. A process that runs as root in such a container therefore fails at most privileged actions, even though its user ID is 0.

Configuration can add single capabilities back, which grants far less than full root. Stricter policies drop every capability and allow only a few to return, such as the one for binding to low ports. A privileged container gets every capability and loses most other protections, so it is close to running on the host. Runtimes can also set a flag that stops programs from gaining new privileges, so a setuid program cannot raise them again.

## User namespaces

User namespaces are the kind of [namespace](https://www.daytona.com/compute-glossary/kernel/namespace.md) that gives capabilities a scope. A process that creates one holds every capability inside it, but those capabilities reach only resources the namespace owns. Root in the namespace can, for example, set up network devices in a network namespace of its own, yet cannot touch the devices of the host. In a rootless setup, its user ID 0 maps to an ordinary user outside, so files it creates on the host belong to that user.

The catch is that this scoped root reaches kernel code that was once open only to the real root. Bugs in that code have led to many privilege escalations, which is why some distributions restrict unprivileged user namespaces. Runtimes that use them for containers still drop capabilities inside, so the scoped root holds less as well. Docker's default seccomp filter, for example, blocks creating new namespaces inside a container.

## Security

Capability security is the risk that comes with each power a process keeps, and that risk differs widely between capabilities. Some give near-total control, because the action they allow can be turned into any other. CAP_SYS_MODULE loads code into the kernel, and CAP_SYS_PTRACE lets a process read and change the memory of other processes. Either can lead to full control of the host when nothing else stops it.

CAP_SYS_ADMIN is nearly root, because it became the default for privileged actions that fit nowhere else. It covers mounting file systems and many device and namespace operations, among many checks across the kernel. Mounting alone lets a process reshape the files it sees, and several known container escapes start from it. Newer kernels split some powers out of it, such as CAP_BPF and CAP_PERFMON in Linux 5.8.

Capabilities limit what the kernel lets a process do, but not which kernel code it can reach. A process with no capabilities still makes [system calls](https://www.daytona.com/compute-glossary/kernel/system-call.md), and a kernel bug can still give it full privileges. Capabilities are therefore paired with seccomp filters, and sandboxes for [untrusted code](https://www.daytona.com/compute-glossary/agents/untrusted-code.md) often add a virtual machine boundary as well. Inside such a guest, root can hold every capability, and only a flaw in the hypervisor would let it reach the host.

| **Capability**           | **Description**                                                                 |
| ------------------------ | ------------------------------------------------------------------------------- |
| **CAP_SYS_ADMIN**        | CAP_SYS_ADMIN allows mounting file systems and many other administration tasks. |
| **CAP_SYS_MODULE**       | CAP_SYS_MODULE allows loading code into the running kernel as modules.          |
| **CAP_SYS_PTRACE**       | CAP_SYS_PTRACE allows tracing other processes and changing their memory.        |
| **CAP_NET_ADMIN**        | CAP_NET_ADMIN allows changing network interfaces and firewall rules.            |
| **CAP_NET_BIND_SERVICE** | CAP_NET_BIND_SERVICE allows listening on ports below 1024, and little else.     |

## Use cases

Capabilities let a process keep the few privileged actions it needs and give up the rest of root.

- **Container defaults.** A container runtime keeps a short list of capabilities and removes the rest. Root inside the container then fails at most privileged actions, even though its user ID is 0.

- **Single extra powers.** A program that needs one privileged action can get just that capability back. Listening on a port below 1024, for example, needs only CAP_NET_BIND_SERVICE.

- **Rootless containers.** A user namespace gives its creator every capability, but only over resources the namespace owns. Root inside maps to an ordinary user outside, so files it creates on the host belong to that user.

- **Untrusted code.** Capabilities do not limit which kernel code a process can reach, so a kernel bug can still give it full privileges. Sandboxes for untrusted code pair them with seccomp filters and often a virtual machine boundary.

## Related terms

- [Namespace](https://www.daytona.com/compute-glossary/kernel/namespace.md)
- [Seccomp](https://www.daytona.com/compute-glossary/kernel/seccomp.md)
- [System call](https://www.daytona.com/compute-glossary/kernel/system-call.md)
- [Container](https://www.daytona.com/compute-glossary/virtualization/container.md)
- [Isolation](https://www.daytona.com/compute-glossary/sandboxes/isolation.md)
- [Untrusted code](https://www.daytona.com/compute-glossary/agents/untrusted-code.md)
