6 Capability-Based Access Control
More
Depth: Practitioner
Progress saves as you read. Mark sections complete as you go; your progress appears in the sidebar.
6.2 Practitioner: Represent, Compose, and Choose
This section: Practitioner: Represent, Compose, and Choose — In practice, fine-grained rights within a capability are often represented as permission flags — independent bits for operations such as read, write, execute, or audit on the named object.
In practice, fine-grained rights within a capability are often represented as permission flags — independent bits for operations such as read, write, execute, or audit on the named object. A composite rights set combines several flags, and an access check confirms that all required bits are present, not merely some. The rights bits can fit in a couple of bytes, but the capability also needs a protected reference or authenticated token that binds them to an object.
6.2.1 Base, Ceiling, and Elevation
A robust design distinguishes a user’s or device’s base capabilities, granted by default, from its maximum capabilities, an absolute ceiling it can never exceed even when temporarily elevated. A canElevate flag controls whether elevation is allowed at all. When a sensitive action is needed — an emergency shutdown, a firmware write — the holder elevates specific capabilities for a short, time-boxed window, gated by extra authorization such as a supervisor’s approval. This is cleaner than swapping roles or minting a temporary admin account, because (if the grants are logged) the audit trail shows exactly which extra rights were used, when, and under whose approval.
Shelly’s Access Ledger
- Who: the holder elevating specific capabilities for a short, time-boxed window.
- What: elevation can never exceed the maximum ceiling, even temporarily.
- Proof: the audit trail names exactly which extra rights were used and who approved them.
6.2.2 Choosing Among RBAC, Capabilities, and ABAC
| Model | Best When | Strength | Watch Out For |
|---|---|---|---|
| RBAC | Stable job categories with a small number of roles. | Simple to set up, reason about, and audit. | Role explosion when cases need many narrow roles. |
| Capability-based | Per-object custom rights or delegation. | Precise least authority; decentralized sharing. | Revocation of tokens already handed out; tokens must be unforgeable. |
| ABAC | Decisions depend on context (time, location, state). | Expressive, policy-as-code, scales by attribute. | More complex to author and evaluate. |
6.2.3 Worked Example: Shift Reassignment Without Role Explosion
Picture an industrial control room where operators rotate across shifts and certification levels. With pure RBAC, every combination tends to spawn its own role — a day-shift level-three role, a night-shift level-three role, and so on — until the role list is unmanageable. A capability design could instead issue an operator narrowly scoped, time-limited authority for a named control, leaving the resource definitions untouched. Emergency shutdown sits at the operator’s ceiling and requires a second person’s approval. The example avoids a combinatorial role table; RBAC with temporal extensions, or ABAC, could also handle changing shifts.
6.2.4 Capabilities in the Physical World
Digital vehicle keys illustrate narrower rights. A shared or valet key is an attenuated capability: for example, it can drive but cannot open the trunk or exceed a set speed. Early keyless-entry systems relied on weak proprietary ciphers that security researchers were able to clone. A digital key must resist forgery, but a bearer credential can still be copied or stolen, so its storage, transfer, and revocation also matter.
6.2.5 Practitioner Knowledge Check
If you can represent rights as flags, gate elevation by a ceiling, and choose the model by need, you can stop here. Continue to Under the Hood for unforgeability, delegation, and the revocation trade-off.
6.3 Under the Hood: Unforgeability, Delegation, and Revocation
This section: Under the Hood: Unforgeability, Delegation, and Revocation — The deeper layer explains what makes a capability actually work and where the model breaks.
The deeper layer explains what makes a capability actually work and where the model breaks. Two properties carry the whole design: the token must be impossible to forge, and the system must have an answer for taking authority back.
6.3.1 The Bit Mechanics
When the rights within a capability are represented as flags, each permission is an independent bit position, not a step in a ladder — setting the fourth bit does not imply the first three. Composite rights sets are built by OR-ing flags together. An access check is conjunctive: the granted set must contain every required bit, which is the bitwise test (granted & required) == required. A rights set can fit in a small integer on a microcontroller; the complete capability still needs a protected object reference or authenticated token.
Shelly’s Access Ledger
- Who: whoever holds the protected capability presents it for a check; a bitmask alone is not proof of authority.
- What: flags are independent bits, not a ladder -- the fourth bit implies nothing about the first three.
- Proof: the check is conjunctive -- every required bit must be present, not just one.
6.3.2 Unforgeability Is the Whole Game
Because possession grants authority, a capability is only safe if an untrusted holder cannot forge or alter it. Two established approaches are a protected reference, mediated by a runtime or kernel, and a cryptographically authenticated token. Unix file descriptors and seL4 kernel capabilities illustrate protected references; a process can pass a descriptor to another process as a delegation. Macaroons use chained MACs, and a signed or MAC-protected, time-limited URL can also carry authority if it names the resource and permitted operation. The verifier must check the protection, scope, and any expiry. A plain client-editable string of flags is not an unforgeable capability.
6.3.3 Where the Rights Live, and the Revocation Trade-Off
A central design question is whether the rights travel with the client or stay on the server. If you place permission flags in a client-held bearer token, its claims must be cryptographically authenticated — otherwise the client edits its own permissions. Without a live revocation check, a valid token can be used until it expires; RFC 6750 §5.3 recommends short-lived bearer tokens, while RFC 7662 describes token introspection for checking current state. If instead you hand the client an opaque session identifier and keep its rights server-side, revocation can take effect on the next checked request, but you have moved back toward an ACL-style lookup. Kernel-managed capabilities have their own revocation mechanisms, such as seL4’s revocation of derived capabilities. Choose short lifetimes plus a denylist or introspection when authority lives client-side; choose server-side rights when you need revocation on the next request.
6.3.5 Audit as Categorized Events
A capability system should record categorized audit events — access attempted versus granted, elevation requested, and denials — rather than flat log lines. Categorized events let monitoring raise alerts automatically (a burst of denied elevations is a probing signal) and make compliance forensics tractable.
6.3.6 Mechanisms and Failure Modes
| Mechanism | What It Guarantees | Evidence to Request | Failure Mode If Weak |
|---|---|---|---|
| Unforgeable token | Holders cannot fabricate authority. | Kernel-protected references or cryptographically authenticated tokens. | Plain flag strings let a client forge permissions. |
| Conjunctive check | All required rights must be present. | A bitwise all-bits-match test, tested with negatives. | An any-bit match grants access on a partial right. |
| Attenuated delegation | Shared authority is never wider than the original. | Delegation that can only narrow, never widen, rights. | Unbounded delegation escalates privilege. |
| Revocation state | Authority can be withdrawn before expiry if checks reach the verifier. | A denylist or introspection for bearer tokens; server-side rights or kernel revocation where applicable. | An unrevoked bearer token can remain valid until expiry. |
| Least ambient authority | Programs hold only the authority they were given. | Narrow explicit grants, no broad inherited capabilities. | Over-broad inherited rights enable confused-deputy abuse. |
6.3.7 Common Pitfalls
- Unsigned capability flags in client tokens. If the token is not cryptographically protected, the client simply forges its own rights.
- Assuming bearer tokens revoke instantly. A locally validated bearer token can remain usable until expiry unless the verifier checks revocation state.
- Over-broad ambient authority. A broad process privilege such as Linux
CAP_SYS_ADMINcan defeat least authority when inherited or granted unnecessarily. - Treating flags as a hierarchy. Bits are independent; one capability does not imply the ones below it.
- No revocation path at all. Without revocation, a capability system can be weaker than a simple list; define expiry, revocation, or both and test the delay.
6.3.8 Under-the-Hood Knowledge Check
At this depth, a capability is a precise, held authority that is only as good as its unforgeability and its revocation story. Rights within a capability may use independent flags; protect the complete token by the runtime or by cryptography, delegate by narrowing where supported, and choose how the system will revoke authority. A trustworthy review checks that forged tokens are rejected, that delegation cannot widen rights, and that revocation actually works.
6.4 Summary
This section: Summary — Review a capability by the rights it grants, how the holder can delegate them, and how authority is revoked.
Review a capability by the rights it grants, how the holder can delegate them, and how authority is revoked. First, a capability is an unforgeable, held token that designates a specific object and the operations allowed on it; possession is the permission, in contrast to an access-control list checked against identity. Next, fine-grained rights within a capability are commonly represented as independent permission flags, composed with bitwise OR and checked conjunctively so that all required bits must be present. Then, separate base capabilities from a maximum ceiling, and grant sensitive rights only through short, time-boxed elevation with extra authorization, which keeps a clean audit trail. Then, choose capabilities for per-object custom rights and decentralized sharing; choose RBAC for stable categories and ABAC for context-dependent decisions. Then, unforgeability is essential: protect capabilities either as runtime or kernel-mediated references (like file descriptors) or as cryptographically authenticated tokens (like macaroons); plain flag strings are forgeable. Then, the revocation trade-off is central: client-held signed capabilities stay valid until expiry unless you add a denylist or introspection, while server-side rights take effect on the next request but resemble an ACL lookup. Then, capabilities support attenuated delegation and resist the confused-deputy problem, but over-broad ambient (inherited) authority undermines least authority. Finally, the durable lesson is that a capability must be cryptographically strong and fine-grained, since a forgeable capability is worthless.
6.5 Key Takeaway
This section: Key Takeaway — Capability-based access control puts precise, least authority in the holder’s hands as an unforgeable token.
Capability-based access control puts precise, least authority in the holder’s hands as an unforgeable token. Make the token impossible to forge, let delegation only narrow rights, and decide up front where authority lives: client-side for decentralized sharing with short lifetimes and a denylist, or server-side when you need revocation on the next request. A capability you cannot protect or revoke is not access control.
6.6 See Also
This section: See Also
Access Control for IoT
Compare capabilities with the RBAC, ABAC, and OAuth models and the least-privilege principle.
Advanced Access Control
See capability flags put to work in sessions, token lifecycle, and privilege elevation.
Auth & Authorization Basics
Ground the model in identity, authentication, authorization, and accounting.
Find help
3 reviewed answers.
Where should I start in a module?
Open the module page from the sidebar to see its chapters in order. Use the module map to return to a topic you need.
Modules and pathsReviewed
What can I try when a project does not work?
Check the symptom, then work through the diagnostic steps. Keep the error message and the smallest example that reproduces it.
When you are stuckReviewed
How do interactive examples work?
Use the interactive guide to check how examples and simulations work before changing your project.
Interactive examples guideReviewed
