Capability-based security

On this page 7

Capability-based security is an access control model in which a program can use a resource only by holding a capability, an unforgeable token that both names an object and carries the rights to use it. In OS security, the model replaces the question “who is this user and what does the list allow” with a simpler one: “does this process hold a valid reference to the object”.

The approach dates back to the work of Dennis and Van Horn in 1966 and shaped research systems such as Hydra, KeyKOS, EROS and the seL4 microkernel. Modern operating systems use it in hybrid form: file descriptors, FreeBSD Capsicum, Fuchsia handles and WebAssembly System Interface (WASI) all apply the same idea of authority carried by reference.

How capabilities grant authority

A capability works because possession equals permission: the kernel checks only that the token is genuine and that its rights include the requested operation. There is no global lookup of the caller identity against a per-object list. The token is usually an index into a kernel-protected table, so a process cannot fabricate or alter one; it can only receive capabilities from the kernel or from another process that already holds them.

Three properties define a sound capability system. Unforgeability means tokens are created only by the kernel or a trusted manager. Explicit delegation means authority moves only when one holder passes a capability to another, typically over interprocess communication. Attenuation means a holder can derive a weaker copy, for example a read-only capability from a read-write one, before passing it on.

The following table lists the core elements of a capability and what each contributes.

ElementRoleTypical form
Object referenceIdentifies the resourceKernel object pointer or slot index
Rights maskLimits allowed operationsRead, write, execute, grant bits
Protection mechanismPrevents forgingKernel table, tagged memory or cryptographic seal
Badge or labelLets a server identify the senderInteger attached at derivation
Core elements of a capability

Implementation styles in operating systems

Operating systems store and protect capabilities in three main ways, and the choice determines performance, revocation cost and hardware requirements. Partitioned designs keep tokens in kernel memory, tagged designs mark capabilities in hardware, and sparse designs rely on cryptography or large random values that are infeasible to guess.

StyleWhere tokens liveExamplesMain trade-off
Partitioned (kernel-held)Kernel tables, user sees indicesseL4 CNodes, Unix file descriptors, Zircon handlesEvery use needs a system call
Tagged hardwareOrdinary memory with a hidden tag bitIBM System/38, CHERI on Arm MorelloRequires special processors
Sparse or cryptographicAnywhere, protected by secrecyAmoeba, macaroons, signed URLsTokens can leak if copied
Ways to protect capabilities

The seL4 microkernel is the most rigorous example: every kernel object, including memory, threads and interrupt lines, is reachable only through capabilities stored in capability nodes (CNodes), and its isolation properties have been formally verified down to the binary. CHERI extends conventional instruction sets with 128-bit capability pointers that carry bounds and permissions, so the processor itself enforces memory safety at pointer granularity.

Capabilities compared with access control lists

Capabilities and access control lists (ACLs) are two views of the same access matrix: an ACL stores the matrix by column, attached to each object, while a capability list stores it by row, attached to each subject. The practical difference lies in where authority is decided and how easily it can be narrowed for a single task.

AspectCapability modelACL model
Check performedIs the token valid with this rightIs this identity on the object list
Granularity of subjectPer process or per referencePer user or group
DelegationPass the token, optionally attenuatedChange the list, often needs owner rights
Confused deputy riskLargely eliminatedCommon when programs act for others
RevocationHarder, needs indirectionEasy, edit the list
Auditing who can accessMust trace all holdersRead the list on the object
Capabilities versus ACL-based discretionary access control

The confused deputy problem shows why the distinction matters. A compiler service with write access to a billing log might be tricked into writing output there because it acts with its own identity. In a capability system the caller must hand the compiler a capability for the output file, so the service cannot use authority the caller never had. Mandatory access control and multilevel security answer different questions, namely system-wide policy and classification, and they are often layered on top of capability mechanisms.

The principle of least authority in practice

Capabilities make the principle of least authority (POLA) practical, because a component receives exactly the references it needs and nothing reachable by name alone. Ambient authority, such as opening any path the current user may read, disappears inside the sandbox. This is a stronger guarantee than privilege separation by user accounts, which still grants each account broad rights.

FreeBSD Capsicum illustrates the hybrid approach. A program opens the files and sockets it needs, restricts each descriptor with cap_rights_limit, then calls cap_enter to enter capability mode, after which global namespaces such as absolute paths are unavailable. Tools such as tcpdump, dhclient and gzip have been sandboxed this way with modest code changes.

The table below suggests where capability techniques fit best.

SituationRecommended approachReason
Parser handling untrusted inputCapsicum or similar capability modeLimits damage from a parser exploit
High-assurance embedded systemseL4-based designVerified isolation between components
Plugin or extension runtimeWASI or object-capability languageHost grants only chosen resources
Legacy desktop applicationDescriptor passing plus OS hardeningFull redesign is rarely feasible
Choosing a capability approach

Limitations and common misconceptions

Capability-based security is not free of cost, and several recurring misunderstandings lead to weak designs. The most important practical issue is revocation, which requires extra indirection because holders may have copied or delegated a token.

  • Revocation needs design: systems use revoker objects, caretaker proxies or derivation trees, as seL4 does, to invalidate copies.
  • Sparse tokens can leak: a bearer token stored in a log or URL grants its rights to anyone who reads it.
  • Hybrid systems keep ambient authority: holding descriptors in Linux does not stop a process from opening new paths unless a sandbox removes that ability.
  • Capabilities do not enforce confinement alone: preventing information flow between holders requires additional policy, which is why classic critiques focused on the *-property of multilevel security.
  • Not the same as Linux capabilities: POSIX capabilities such as CAP_NET_ADMIN are coarse privilege flags attached to processes, not object references.

In everyday language

Think of a hotel key card. The door does not ask who you are; it simply opens for a valid card coded for that room. Capability-based security works the same way: a program can touch a file or device only if it holds a key that the system created for it.

Because every key is specific, a program can be given only the keys it really needs. If a hacker takes over that program, the attacker finds a small ring of keys instead of a master key to the whole building.

Seen in the real world

A security team maintaining a network monitoring appliance on FreeBSD worries about its packet-capture tool, which decodes hundreds of protocols and has a long history of parser bugs. They modify the tool so that it opens the capture device and the output file first, limits the output descriptor to write and seek rights, and then enters Capsicum capability mode before parsing a single packet.

Months later, a malformed packet triggers a memory corruption bug in one dissector. The exploit gains control of the process but cannot open files, create sockets or read credentials, because no capability for those resources exists inside the sandbox. The incident ends as a crash and a patch rather than a breach, which is the practical payoff of least authority.