Definition
Capability security is a way of controlling access in which authority is carried by capabilities. A capability is an unforgeable reference that both names one object, such as a file, a memory region or a device, and grants a set of rights to it, such as read or write. A program can act on an object only by presenting a capability for it. It obtains capabilities only by creating objects or by receiving capabilities from their holders. The system checks what the requester holds, not who the requester is.
The idea
In most operating systems a program’s rights come from the user it runs as: a program running as Alice may open any file that Alice may open, simply by naming it. This is ambient authority: the program holds it all the time and uses it without saying which part it means to use. Ambient authority causes the confused deputy problem §1.25, which Norm Hardy described in 1988 [416]. A compiler service has permission to write a billing file. A user asks the compiler to write debugging output to a file the user names, and names the billing file. The compiler opens that file with its own permission and overwrites the bill. Every check passed; the compiler used authority it held for another purpose.
With capabilities, the user passes the compiler a capability for the output file instead of a name, and the user can hold that capability only if the user may write the file. The compiler writes through it and cannot reach the billing file with it. A house key is a fair picture: the lock opens for whoever holds the key and does not ask who the holder is. The picture stops at copying: anyone with the tools can copy a metal key, while a capability system controls copying and makes it impossible to build a capability from arbitrary bits.
How it works
Jack Dennis and Earl Van Horn introduced the term in 1966 [421]. A capability system needs four things.
A name with rights. Each capability names one object and carries a set of rights, and often bounds, such as the first and last address of a memory region, and a lifetime.
Unforgeability. Only the trusted part of the system, such as the kernel, the hardware or a reference monitor §1.17 (the component that checks every access), can create a capability.
A check on every use. The trusted part confirms that the capability presented is still valid, names this object and includes this right.
Controlled transfer. A holder can pass a capability over a channel it already holds, called delegation, or pass a weaker copy, such as a read-only one, called attenuation. No holder can add rights.
Three implementations are common.
A protected table per holder. The kernel keeps each program’s capabilities in a table that the program cannot write, and the program names an entry by its index. A Unix file descriptor §15.21 works this way: the number 3 means entry 3 of this process’s table and names nothing in another process. The seL4 microkernel §19.5.4, a minimal operating-system kernel, controls all access through capabilities kept in this way.
Tagged hardware. CHERI (Capability Hardware Enhanced RISC Instructions, where RISC means reduced instruction set computer) makes a pointer a capability: an address with bounds and permissions, 128 bits long on a 64-bit processor, plus one tag bit stored apart from ordinary memory. An ordinary write over a capability clears its tag, and the processor refuses to use an untagged value as a capability.
Cryptographic tokens. The capability is a value that only its issuer can produce, such as a random number too long to guess, or an object name and rights protected by a message authentication code §5.7 that the issuer computes. Whoever obtains the bits holds the authority, so such a bearer token must stay secret.
Revocation, taking authority back, is the hard part, because holders may have passed copies on. Either the owner hands out a capability to a forwarder, an object that relays each use and that the owner can disable, which cuts off every copy at once; or each table entry and each capability carries a generation number that the system increases when it withdraws the authority, so that older capabilities stop matching.
Worked example
A guest program asks a host to read and write objects for it. Design 1: raw addresses. Object A is 64 bytes long and starts at address 0x20001000. Since 64 is 0x40 in hexadecimal, A ends at 0x2000103F.
The guest reads at A’s address plus 70. A’s last offset is 63, so the address
0x20001046lies in whatever object follows A: the address carried no bounds.A was given for reading only, yet a write to
0x20001000succeeds: no rights.A is freed and object B is placed at the same address, so the old address now names B: no lifetime.
The guest computes the address of a key buffer it was never told about and presents it: the address was forgeable.
Design 2: checked handles. The host keeps a protected table for this guest. Each entry holds an object, its length, its rights and a generation number, and the guest names an object by a handle, the pair (slot, generation). Slot 2 holds A, 64 bytes, read-only, generation 3, and the guest holds the handle (2, 3). Every request must pass four checks: the slot number lies inside the table and the slot is in use, the generations are equal, the right is included, and every byte accessed lies within the length, so the offset plus the access width is at most the length.
A 4-byte read at offset 10: , read is included, . Allowed.
Write at offset 10: write is not included. Refused.
A 4-byte read at offset 62: , so the last two bytes lie outside A. Refused.
A is freed; slot 2 moves to generation 4 and later holds B. The handle (2, 3) fails because . Refused.
The handle (5, 1) names slot 5, which is empty in this guest’s table. Refused.
The generation needs enough bits. With 4 bits, slot 2’s number returns to 3 after reuses, and the stale handle (2, 3) is accepted again for whatever object then occupies the slot. With 16 bits this takes reuses. A design either makes counter wraparound §6.21 impossible within the life of any handle, or retires a slot before its generation wraps. The failure is a form of the ABA problem §9.25, named after a value that changes from A to B and back to A: an unchanged number is taken as proof that nothing changed.
Stated precisely
Access rights can be drawn as an access matrix: one row per subject (a program or process), one column per object, and in each cell the subject’s rights over the object. An access-control §1.7 list (ACL) stores the matrix by column: each object lists who may do what, and each access is checked against the requester’s identity. A capability system stores the matrix by row: each subject holds capabilities for the cells of its own row, and each access is checked against the capability presented.
Write a capability as a pair , where is an object and is a set of rights. A capability system enforces three rules.
Access only by capability. A subject performs operation on object only if holds some with .
No forgery. The capabilities that holds grow in only three ways: starts with them, creates a new object and receives a capability for it, or a holder passes a capability to over a channel that both already hold.
No amplification. A capability derived from has the form with , where means “is a subset of”.
A system with lifetimes adds a fourth rule, validity: once is destroyed or the capability revoked, every use of the capability fails and none reaches another object.
The rules rest on two assumptions. First, complete mediation §1.16: the trusted part sees every access, and no path bypasses it. Second, untrusted code cannot write the memory where capabilities are kept except through the trusted part, or, for cryptographic tokens, cannot guess or compute a valid token.
Limits and common mistakes
A capability limits who can use an object, not where information goes afterwards. A program that holds a read capability for a secret can copy the secret into any message it is able to send. Information-flow control §1.41 addresses that question.
Copying a transferable capability copies its authority, so a capability system confines a program only by controlling which channels the program holds.
Capabilities do not give least privilege §1.15 by themselves. A system that hands every program a capability for everything has capabilities and no restriction.
A capability is not secret by definition. In the table and hardware forms the system protects it, and another program that learns the index or the bits gains nothing. Only bearer tokens rely on secrecy.
Bounds alone give spatial memory safety §2.28: an access cannot run past its object. Temporal memory safety §2.29, no use of an object after it is freed, also needs lifetime information, such as generation numbers or revocation of every copy.
Questions answered
Why might an integer address be a poor capability?
An integer address is a poor capability because it names a location without establishing any authority: it is forgeable and carries no rights, no bounds and no lifetime. A capability is an unforgeable reference that names one object and grants specific rights to it. Against that standard, a raw address fails in five ways.
Forgeable: any program can compute any integer, so holding one proves nothing about having been granted access.
No rights: the number does not say whether the holder may read, write or both.
No bounds: the address plus an offset can run past the end of the object into a neighboring object.
No lifetime: after the object is freed and its memory reused, the same address names a different object.
No revocation: the holder can keep a copy indefinitely, and nothing records who holds one.
An integer can still serve as a handle if a trusted component resolves it in a protected table that belongs to the holder and checks rights, bounds and a generation number on every use, as a Unix kernel resolves a file descriptor in the process’s own table. The protection then comes from the table and the check, not from the integer.
Related entries: Least privilege (§1.15), Complete mediation (§1.16), Temporal memory safety (§2.29), Confused deputy (§1.25), Authorization (§1.7), Spatial memory safety (§2.28). Further reading: [156, 416, 421].