--- name: acls-dont description: >- ACLs don't: allowlists and access lists are an anti-pattern; hand out a narrowed capability instead of checking who's asking. Use when about to write or review an allowlist, whitelist, ACL, permission table, role check, `isAllowed(user)`, `allowed.includes(sender)`, or an `access.json`; when deciding who may use a bot, service, endpoint, device, or store; when someone says "allowlist", "ACL", "ACLs don't", or "confused deputy". Not for choosing which narrowing to hand out, or how to shape the API that narrows (that's pola). --- # ACLs don't ```js // anti-pattern: the bot hears everyone, then checks a list E(gateway).subscribe(msg => { if (allowed.includes(msg.author.id)) respond(msg); }); // therefore: whoever holds "hear everyone" narrows it, and the bot gets only that const fromDan = M.splitRecord({ author: M.splitRecord({ id: danId }) }); const bot = makeBot({ messages: E(all).narrow(fromDan) }); ``` ## Context A component can do things for several parties, and not every party should get all of it: a bot in a shared channel, an HTTP endpoint, a device, a store. ## Problem **How does the component keep each party to what it may do?** ## Forces - An allowlist looks simple and auditable: one list, one check. - Frameworks offer one by default, so it's the first thing to hand. The Discord plugin keeps one in `access.json`. - To check the list, the component must hold the authority for every party and choose, on each request, whose to use. That is the setup for a **confused deputy**: it uses one party's authority on behalf of another. The check asks "who is asking?" when the question that matters is "with what authority?", and once a request has passed through a third party, the answer is gone. - The list puts policy inside the mechanism. Changing who may do what means editing the component's state or config, and a party can't pass a slice of its access on to someone else without asking whoever keeps the list. - Some identity has to come in from outside: a Discord user id, a login. ## Therefore **Don't check who's asking. Hand each party a capability narrowed to what it may do, and let the component serve whoever holds one.** - The component offers its wide capability, and ways to narrow it: `narrow(pattern)`, `pathjoin`, `withinHost` (see [pola](../pola/SKILL.md)). - The party that creates it narrows and hands out. "Who may do X" is now "who was handed X". - An outside identity becomes a capability once, at the edge, by a narrowing done by the party that holds the wide capability: `all.narrow(from(userId))`. Components inside never see the list. - To take access back, hand out a revocable forwarder (a caretaker) and revoke it, rather than deleting a list entry. ## Resulting context There's no check to forget or get wrong, and a party can't use authority it wasn't handed. "Who can do X?" is answered by who holds a reference to X, which a [wiring-diagram](../wiring-diagram/SKILL.md) shows. A holder can share its access, or a narrower slice of it, without asking anyone. Revocation has to be designed in, as caretakers, rather than coming free with a list. Auditing means tracing references, not reading one table. ## Sources - [ACLs don't](https://papers.agoric.com/papers/acls-dont/full-text/): Tyler Close, HP Labs, 2009 (HPL-2009-20). The ACL model can't make correct access decisions for interactions among more than two principals, because the information they need isn't kept across message sends; CSRF and clickjacking are instances of this. - [The Confused Deputy](http://cap-lore.com/CapTheory/ConfusedDeputy.html): Norm Hardy, 1988. A compiler with authority to write its billing file is tricked into overwriting it by a user who names that file as the output.