User Controlled Authorization Network (UCAN) Specification Protocol Labs, Bluesky, number zero, and Witchcraft Software have published the User Controlled Authorization Network (UCAN) specification, a trustless, secure, local-first, user-originated, distributed authorization scheme that uses public-key verifiable, delegable capabilities and decentralized identifiers (DIDs). The specification aims to improve on traditional access control lists (ACLs) and role-based access control (RBAC) by enabling authorization to scale in distributed systems without a central authority, addressing issues such as confused deputies and data privacy. Irakli Gozalishvili https://github.com/Gozala , Protocol Labs https://protocol.ai/ Daniel Holmgren https://github.com/dholms , Bluesky https://blueskyweb.xyz/ Philipp Krüger https://github.com/matheus23 , number zero https://n0.computer/ Brooklyn Zelenka https://github.com/expede , Witchcraft Software https://github.com/expede The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 https://www.rfc-editor.org/info/bcp14 when, and only when, they appear in all capitals, as shown here. User-Controlled Authorization Network UCAN is a trustless https://blueskyweb.xyz/blog/3-6-2022-a-self-authenticating-social-protocol , secure, local-first https://www.inkandswitch.com/local-first/ , user-originated, distributed authorization scheme. This document provides a high level overview of the components of the system, concepts, and motivation. Exact formats are given in sub-specifications sub-specifications . User-Controlled Authorization Network UCAN is a trustless https://blueskyweb.xyz/blog/3-6-2022-a-self-authenticating-social-protocol , secure, local-first https://www.inkandswitch.com/local-first/ , user-originated, distributed authorization scheme. It provides public-key verifiable, delegable, expressive, openly extensible capabilities https://en.wikipedia.org/wiki/Object-capability model . UCANs achieve public verifiability with late-bound certificate chains and principals represented by decentralized identifiers DIDs https://www.w3.org/TR/did-core/ . UCAN improves the familiarity and adoptability of schemes like SPKI/SDSI https://theworld.com/~cme/html/spki.html for web and native application contexts. UCAN allows for the creation, delegation, and invocation of authority by any agent with a DID, including traditional systems and peer-to-peer architectures beyond traditional cloud computing. If we practice our principles, we could have both security and functionality. Treating security as a separate concern has not succeeded in bridging the gap between principle and practice, because it operates without knowledge of what constitutes least authority. — Miller et al, The Structure of Authority Since at least Multics https://en.wikipedia.org/wiki/Multics , access control lists ACL https://en.wikipedia.org/wiki/Access-control list s have been the most popular form of digital authorization, where a list of what each user is allowed to do is maintained on the resource. ACLs and later RBAC https://en.wikipedia.org/wiki/Role-based access control have been a successful model suited to architectures where persistent access to a single list is viable. ACLs require that rules are sufficiently well specified, such as in a centralized database with rules covering all possible permutations of scenario. This both imposes a very high maintenance burden on programmers as a systems grows in complexity, and is a key vector for confused deputies https://en.wikipedia.org/wiki/Confused deputy problem . With increasing interconnectivity between machines becoming commonplace, authorization needs to scale to meet the load demands of distributed systems while providing partition tolerance. However, it is not always practical to maintain a single central authorization source. Even when copies of the authorization list are distributed to the relevant servers, latency and partitions introduce troublesome challenges with conflicting updates, to say nothing of storage requirements. A large portion of personal information now also moves through connected systems. As a result, data privacy is a prominent theme when considering the design of modern applications, to the point of being legislated in parts of the world. Ahead-of-time coordination is often a barrier to development in many projects. Flexibility to define specialized authorization semantics for resources and the ability to integrate with external systems trustlessly are essential as the number of autonomous, specialized, and coordinated applications increases. Many high-value applications run in hostile environments. In recognition of this, many vendors now include public key functionality, such as non-extractable keys in browsers https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey , certificate systems for external keys https://fidoalliance.org/what-is-fido/ , platform keys https://www.passkeys.com/ , and secure hardware enclaves in widespread consumer devices. Two related models that work exceptionally well in the above context are Simple Public Key Infrastructure SPKI https://www.rfc-editor.org/rfc/rfc2693.html and object capabilities OCAP http://erights.org/elib/capability/index.html . Since offline operation and self-verifiability are two requirements, UCAN adopts a certificate capability model https://web.archive.org/web/20140724054706/http://wiki.erights.org/wiki/Capability-based Active Invocation Certificates related to SPKI https://theworld.com/~cme/html/spki.html . The following analogies illustrate several significant trade-offs between these systems but are only accurate enough to build intuition. A good resource for a more thorough presentation of these trade-offs is Capability Myths Demolished https://srl.cs.jhu.edu/pubs/SRL2003-02.pdf . In this framework, UCAN approximates SPKI with some dynamic features. By analogy, ACLs are like a bouncer at an exclusive event. This bouncer has a list attendees allowed in and which of those are VIPs that get extra access. People trying to get in show their government-issued ID and are accepted or rejected. In addition, they may get a lanyard to identify that they have previously been allowed in. If someone is disruptive, they can simply be crossed off the list and denied further entry. If there are many such events at many venues, the organizers need to coordinate ahead of time, denials need to be synchronized, and attendees need to show their ID cards to many bouncers. The likelihood of the bouncer letting in the wrong person due to synchronization lag or confusion by someone sharing a name is nonzero. UCANs work more like movie tickets http://www.erights.org/elib/capability/duals/myths.html caps-as-keys or a festival pass. No one needs to check your ID; who you are is irrelevant. For example, if you have a ticket issued by the theater to see Citizen Kane, you are admitted to Theater 3. If you cannot attend an event, you can hand this ticket to a friend who wants to see the film instead, and there is no coordination required with the theater ahead of time. However, if the theater needs to cancel tickets for some reason, they need a way of uniquely identifying them and sharing this information between them. Object capability "ocap" systems use a combination of references, encapsulated state, and proxy forwarding. As the name implies, this is fairly close to object-oriented or actor-based systems. Object capabilities are robust http://www.erights.org/talks/thesis/markm-thesis.pdf , flexible, and expressive. To achieve these properties, object capabilities have two requirements: fail-safe https://en.wikipedia.org/wiki/Fail-safe , and locality preservation. The emphasis on consistency rules out partition tolerance 1. Each UCAN includes an assertions of what it is allowed to do. "Proofs" are positive evidence elsewhere called "witnesses" of the possession of rights. They are cryptographically verifiable chains showing that the UCAN issuer either claims to directly own a resource, or that it was delegated to them by some claimed owner. In the most common case, the root owner's ID is the only globally unique identity for the resource. Root capability issuers function as verifiable, distributed roots of trust. The delegation chain is by definition a provenance log. Private keys themselves SHOULD NOT move from one context to another. Keeping keys unique to each physical device and unique per use case is RECOMMENDED to reduce opportunity for keys to leak, and limit blast radius in the case of compromises. "Sharing authority without sharing keys" is provided by capabilities, so there is no reason to share keys directly. Note that a structurally and cryptographically valid UCAN chain can be semantically invalid. The executor MUST verify the ownership of any external resources at execution time. While not possible for all use cases e.g. replicated state machines and eventually consistent data , having the Executor be the resource itself is RECOMMENDED. While certificate chains go a long way toward improving security, they do not provide confinement http://www.erights.org/elib/capability/dist-confine.html on their own. The principle of least authority SHOULD be used when delegating a UCAN: minimizing the amount of time that a UCAN is valid for and reducing authority to the bare minimum required for the delegate to complete their task. This delegate should be trusted as little as is practical since they can further sub-delegate their authority to others without alerting their delegator. UCANs do not offer confinement as that would require all processes to be online , so it is impossible to guarantee knowledge of all of the sub-delegations that exist. The ability to revoke some or all downstream UCANs exists as a last resort. Inversion of control https://en.wikipedia.org/wiki/Inversion of control is achieved due to two properties: self-certifying delegation and reference passing. There is no Authorization Server AS that sits between requestors and resources. In traditional terms, the owner of a UCAN resource is the resource server RS directly. This inverts the usual relationship between resources and users: the resource grants some or all authority over itself to agents, as opposed to an Authorization Server managing the relationship between them. This has several major advantages: - Fully distributed and scalable - Self-contained request without intermediary - Partition tolerance, support for replicated data and machines beyond-single-system-image - Flexible granularity - Compositionality: no distinction between resources residing together or apart ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ │ │ │ │ │ │ ┌─────────┐ │ │ │ │ │ │ │ Bob's │ │ │ │ │ │ │ │ Photo │ │ │ │ │ │ │ │ Gallery │ │ │ │ │ │ │ └─────────┘ │ │ │ │ │ │ │ │ │ │ Alice's │ │ Bob's │ │ Carol's │ │ Stuff │ │ Stuff │ │ Stuff │ │ │ │ │ │ │ │ ┌───────┼───┼─────────────┼───┼──┐ │ │ │ │ │ │ │ │ │ │ │ │ │ ┌───┼───┼──┼────────┐ │ │ │ │ │ Alice's │ │ │ │ │ │ │ │ │ │ Music │ │ │ │Carol's │ │ │ │ │ │ Player │ │ │ │ Game │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └───┼───┼──┼────────┘ │ │ │ │ │ │ │ │ │ │ └───────┼───┼─────────────┼───┼──┘ │ │ │ │ │ │ │ └─────────────┘ └─────────────┘ └─────────────┘ This additionally allows UCAN to model auth for eventually consistent and replicated state beyond-single-system-image . There are several roles that an agent MAY assume: | Name | Description | |---|---| | Agent | The general class of entities and principals that interact with a UCAN | | Audience | The Principal delegated to in the current UCAN. Listed in the aud field | | Executor | The Agent that actually performs the action described in an invocation | | Invoker | A Principal that requests an Executor perform some action that uses the Invoker's authority | | Issuer | The Principal of the current UCAN. Listed in the iss field | | Owner | A Subject that controls some external resource | | Principal | An agent identified by DID listed in a UCAN's iss or aud field | | Revoker | The Issuer listed in a proof chain that revokes a UCAN | | Subject | The Principal who's authority is delegated or invoked | | Validator | Any Agent that interprets a UCAN to determine that it is valid, and which capabilities it grants | flowchart TD subgraph Agent subgraph Principal direction TB subgraph Issuer direction TB subgraph Subject direction TB Executor Owner end Revoker end subgraph Audience Invoker end end Validator end At the very least every object should have a URL Every Erlang process in the universe should be addressable and introspective A Subject represents the Agent that a capability is for. A Subject MUST be referenced by DID https://www.w3.org/TR/did-core/ . This behaves much like a GUID https://en.wikipedia.org/wiki/Universally unique identifier , with the addition of public key verifiability. This unforgeability prevents malicious namespace collisions which can lead to confused deputies https://en.wikipedia.org/wiki/Confused deputy problem . A resource is some data or process that can be uniquely identified by a URI https://www.rfc-editor.org/rfc/rfc3986 . It can be anything from a row in a database, a user account, storage quota, email address, etc. Resource MAY be as coarse or fine grained as desired. Finer-grained is RECOMMENDED where possible, as it is easier to model the principle of least authority PoLA https://en.wikipedia.org/wiki/Principle of least privilege . A resource describes the noun of a capability. The resource pointer MUST be provided in URI https://www.rfc-editor.org/rfc/rfc3986 format. Arbitrary and custom URIs MAY be used, provided that the intended recipient can decode the URI. The URI is merely a unique identifier to describe the pointer to — and within — a resource. Having a unique agent represent a resource and act as its manager is RECOMMENDED. However, to help traditional ACL-based systems transition to certificate capabilities, an agent MAY manage multiple resources, and act as the registrant in the ACL system wrapping-existing-systems . Unless explicitly stated, the Resource of a UCAN MUST be the Subject. The Issuer iss and Audience aud can be conceptualized as the sender and receiver respectively of a postal letter. Every UCAN MUST be signed with the private key associated with the DID in the iss field. For example: "aud": "did:key:z6MkiTBz1ymuepAQ4HEHYSF1H8quG5GLVVQR3djdX3mDooWp", "iss": "did:key:zDnaerDaTF5BXEavCrfRZEk316dpbLsfPDZ3WJ5hRTPFU2169", Please see the Cryptosuite cryptosuite section for more detail on DIDs. The UCAN lifecycle has four components: | Spec | Description | Requirement Level | |---|---|---| | Invocation https://github.com/ucan-wg/invocation Promise https://github.com/ucan-wg/promise Revocation https://github.com/ucan-wg/revocation flowchart TD prm Promise inv Invocation del Delegation rev Revocation prm -- |awaits| inv del -- |proves| inv rev -.- |kind of| inv rev -- |invalidates| del click del href "https://github.com/ucan-wg/delegation" "UCAN Delegation Spec" click inv href "https://github.com/ucan-wg/invocation" "UCAN Invocation Spec" click rev href "https://github.com/ucan-wg/revocation" "UCAN Revocation Spec" It is often useful to talk about a UCAN in the context of some action. For example, a UCAN delegation may be valid when it was created, but expired when invoked. php sequenceDiagram Alice -- Bob: Delegate Bob - Bob: Validate Bob -- Carol: Delegate Carol - Carol: Validate Carol - Alice: Invoke Alice - Alice: Validate Alice - Alice: Execute The period of time that a capability is valid from and until. This is the range from the latest "not before" to the earliest expiry in the UCAN delegation chain. The moment at which a delegation is asserted. This MAY be captured by an iat field, but is generally superfluous to capture in the token. The moment a UCAN Invocation is created. It must be within the Validity Interval. Validation MAY occur at multiple points during a UCAN's lifecycle. The main two are: - On receipt of a delegation - When executing an invocation To avoid the overloaded word "runtime", UCAN adopts the term "execution-time" to express the moment that the executor attempts to use the authority captured in an invocation and associated delegation chain. Validation MUST occur at this time. nbf and exp stand for "not before" and "expires at," respectively. These MUST be expressed as seconds since the Unix epoch in UTC, without time zone or other offset. Taken together, they represent the time bounds for a token. These timestamps MUST be represented as the number of integer seconds since the Unix epoch. Due to limitations 2 in numerics for certain common languages, timestamps outside of the range from The nbf field is OPTIONAL. When omitted, the token MUST be treated as valid beginning from the Unix epoch. Setting the nbf field to a time in the future MUST delay invoking a UCAN. For example, pre-provisioning access to conference materials ahead of time but not allowing access until the day it starts is achievable with judicious use of nbf . The exp field is RECOMMENDED. Following the principle of least authority https://en.wikipedia.org/wiki/Principle of least privilege , it is RECOMMENDED to give a timestamp expiry for UCANs. If the token explicitly never expires, the exp field MUST be set to null . If the time is in the past at validation time, the token MUST be treated as expired and invalid. Keeping the window of validity as short as possible is RECOMMENDED. Limiting the time range can mitigate the risk of a malicious user abusing a UCAN. However, this is situationally dependent. It may be desirable to limit the frequency of forced reauthorizations for trusted devices. Due to clock drift, time bounds SHOULD NOT be considered exact. A buffer of ±60 seconds is RECOMMENDED. Several named points of time in the UCAN lifecycle can be found in the high level spec UCAN . Below are a couple examples: { // ... "nbf": 1529496683, "exp": 1575606941 } { // ... "exp": 1575606941 } { // ... "nbf": 1529496683, "exp": null } Here is a concrete example of all stages of the UCAN lifecycle for database write access. sequenceDiagram participant Database actor DBAgent actor Alice actor Bob Note over Database, DBAgent: Set Up Agent-Owned Resource DBAgent - Database: createDB autonumber 1 Note over DBAgent, Bob: Delegation DBAgent -- Alice: delegate DBAgent, write Alice -- Bob: delegate DBAgent, write Note over Database, Bob: Invocation Bob - DBAgent: invoke DBAgent, write, key, value , proof: ➊,➋ DBAgent - Database: write key, value DBAgent - Bob: ACK Note over DBAgent, Bob: Revocation Alice - DBAgent: revoke ➋, proof: ➊,➋ Bob - DBAgent: invoke DBAgent, write, key, newValue , proof: ➊,➋ DBAgent -X Bob: NAK ➏ rejected A capability is the association of an ability to a subject: subject x command x policy . The Subject and Command fields are REQUIRED. Any non-normative extensions are OPTIONAL. For example, a capability may used to represent the ability to send email from a certain address to others at @example.com . | Field | Example | |---|---| | Subject | did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK | | Command | /msg/send | | Policy | "or", "==", ".from", "mailto:me@example.com" , "match", ".cc", "mailto: @example.com" | For a more complete treatment, please see the UCAN Delegation https://github.com/ucan-wg/delegation spec. Whether to enable cooperation or to limit vulnerability, we care about authorityrather thanpermissions.Permissions determine what actions an individual program may perform on objects it can directly access. Authority describes the effects that a program may cause on objects it can access, either directly by permission, or indirectly by permitted interactions with other programs. The set of capabilities delegated by a UCAN is called its "authority." To frame it another way, it's the set of effects that a principal can cause, and acts as a declarative description of delegated abilities. Merging capability authorities MUST follow set semantics, where the result includes all capabilities from the input authorities. Since broader capabilities automatically include narrower ones, this process is always additive. Capability authorities can be combined in any order, with the result always being at least as broad as each of the original authorities. ┌───────────────────────┐ ┐ │ │ │ │ │ │ │ │ │ │ │ │ │ Subject B │ │ ┌──────────────────┼ ─ ─ x │ │ │ │ Ability Z │ ├── BxZ │ │ │ │ Capability │ │ │ │ │ │ │ │ │ Subject A │ │ │ │ x │ │ │ │ Ability Y ─ ─┼──────────────────┘ ┘ │ │ │ │ │ │ │ │ │ │ └───────────────────────┘ └─────────────────────┬────────────────────┘ │ AxY U BxZ Capability The capability authority is the total rights of the authorization space down to the relevant volume of authorizations. Individual capabilities MAY overlap; the authority is the union. Every unique delegated capability MUST have equal or narrower capabilities from their delegator. Inside this content space, you can draw a boundary around some resource s their type, identifiers, and paths or children and their capabilities. Commands are concrete messages "verbs" that MUST be unambiguously interpretable by the Subject of a UCAN. Commands are REQUIRED in invocations. Some examples include /msg/send , /crud/read , and /ucan/revoke . Much like other message-passing systems, the specific resource MUST define the behavior for a particular message. For instance, /crud/update MAY be used to destructively update a database row, or append to a append-only log. Specific messages MAY be created at will; the only restriction is that the Executor understand how to interpret that message in the context of a specific resource. While arbitrary semantics MAY be described, they MUST apply to the target resource. For instance, it does not make sense to apply /msg/send to a typical file system. Commands MUST be lowercase, and begin with a slash / . Segments MUST be separated by a slash. A trailing slash MUST NOT be present. All of the following are syntactically valid Commands: / /crud /crud/create /stack/pop /crypto/sign /foo/bar/baz/qux/quux /ほげ/ふが Segment structure is important since shorter Commands prove longer paths. For example, / can be used as a proof of any other Command. For example, /crypto MAY be used to prove /crypto/sign but MUST NOT prove /stack/pop or /cryptocurrency . "Top" / is the most powerful ability, and as such it SHOULD be handled with care and used sparingly. The "top" or "any", or "wildcard" ability MUST be denoted / . This can be thought of as something akin to a super user permission in RBAC. The wildcard ability grants access to all other capabilities for the specified resource, across all possible namespaces. The wildcard ability is useful when "linking" agents by delegating all access to another device controlled by the same user, and that should behave as the same agent. It is extremely powerful, and should be used with care. Among other things, it permits the delegate to update a Subject's mutable DID document change their private keys , revoke UCAN delegations, and use any resources delegated to the Subject by others. %%{ init: { 'flowchart': { 'curve': 'linear' } } }%% flowchart BT / /msg -- / subgraph msgGraph /msg/send -- /msg /msg/receive -- /msg end /crud -- / subgraph crudGraph /crud/read -- /crud /crud/mutate -- /crud subgraph mutationGraph /crud/mutate/create -- /crud/mutate /crud/mutate/update -- /crud/mutate /crud/mutate/destroy -- /crud/mutate end end ... -- / The /ucan Command namespace MUST be reserved. This MUST include any ability string matching the regex ^\/ucan\/. . This is important for keeping a space for community-blessed Commands in the future, such as standard library Commands, such as Revocation https://github.com/ucan-wg/revocation . Attenuation is the process of constraining the capabilities in a delegation chain. Each direct delegation MUST either directly restate or attenuate diminish its capabilities. Token resolution is transport specific. The exact format is left to the relevant UCAN transport specification. At minimum, such a specification MUST define at least the following: - Request protocol - Response protocol - Collections format Note that if an instance cannot dereference a CID at runtime, the UCAN MUST fail validation. This is consistent with the constructive semantics https://en.wikipedia.org/wiki/Intuitionistic logic of UCAN. The REQUIRED nonce parameter nonce MAY be any value. A randomly generated string is RECOMMENDED to provide a unique UCAN, though it MAY also be a monotonically increasing count of the number of links in the hash chain. This field helps prevent replay attacks and ensures a unique CID per delegation. The iss , aud , and exp fields together will often ensure that UCANs are unique, but adding the nonce ensures uniqueness. The recommended size of the nonce differs by key type. In many cases, a random 12-byte nonce is sufficient. If uncertain, check the nonce in your DID's crypto suite. This field SHOULD NOT be used to sign arbitrary data, such as signature challenges. See the meta Metadata field for more. Here is a simple example. { // ... "nonce": {"/": {"bytes": "bGlnaHQgd29yay4"}} } The OPTIONAL meta field contains a map of arbitrary metadata, facts, and proofs of knowledge. The enclosed data MUST be self-evident and externally verifiable. It MAY include information such as hash preimages, server challenges, a Merkle proof, dictionary data, etc. The data contained in this map MUST NOT be semantically meaningful to delegation chains. Below is an example: { // ... "meta": { "challenges": { "example.com": "abcdef", "another.example.net": "12345" }, "sha3 256": { "B94D27B9934D3E08A52E52D7DA7DABFAC484EFE37A5380EE9088F7ACE2EFCDE9": "hello world" } } } Across all UCAN specifications, the following cryptosuite MUST be supported: | Role | REQUIRED Algorithms | Notes | |---|---|---| | Hash | | Ed25519 https://en.wikipedia.org/wiki/EdDSA Ed25519 , P-256 https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf page=111 , secp256k1 DID https://www.w3.org/TR/did-core/ did:key All UCANs MUST be canonically encoded with DAG-CBOR https://ipld.io/specs/codecs/dag-cbor/spec/ for signing. A UCAN MAY be presented or stored in other IPLD https://ipld.io/ formats such as DAG-JSON https://ipld.io/specs/codecs/dag-json/spec/ , but converted to DAG-CBOR for signature validation. A UCAN token MUST be configured as follows: | Parameter | REQUIRED Configuration | |---|---| | Version | | Multibase https://github.com/multiformats/multibase base58btc Multihash https://www.multiformats.io/multihash/ SHA-256 https://en.wikipedia.org/wiki/SHA-2 Multicodec https://github.com/multiformats/multicodec DAG-CBOR https://ipld.io/specs/codecs/dag-cbor/spec/ Note All CIDs encoded as above start with the characters zdpu . The resolution of these addresses is left to the implementation and end-user, and MAY non-exclusively include the following: local store, a distributed hash table DHT , gossip network, or RESTful service. All UCAN formats MUST use the following envelope format: | Field | Type | Description | |---|---|---| .0 | Bytes | A signature by the Payload's iss over the SigPayload field | .1 | SigPayload | The content that was signed | .1.h | VarsigHeader | The | .1.ucan/