Capability Based Security
The brilliant thing about capability-based security is that it turns classic object-oriented programming patterns into security patterns.<p>Access control is implemented by encapsulating private members behind a restricted public interface.<p>Polymorphism allows you to add wrappers around an object implementing arbitrary security policies. E.g. want to revoke access to this object after some time? Add a wrapper where the methods forward to the real object until revoked, and then throw exceptions instead.<p>What&#x27;s interesting is that these are patterns we are doing anyway, in real code, not for the purpose of security but for the purpose of correctness and maintainability. Because we were doing these things anyway, our programming languages provide really good tools for making them work naturally, and we already know how to think about them.<p>On the other hand, the competing model -- access control lists (ACLs), and other types of externally-specified policy -- are not things we were doing anyway. They&#x27;re external concepts bolted into the system awkwardly. Because of this, they tend to be painful to maintain, which in turn means people often don&#x27;t bother.<p>One of the clearest examples of how ACLs go against the grain: An ACL is a list of entities who are allowed to access a resource. These are effectively pointers pointing in the <i>opposite direction</i> of all other pointers in the system: ACLs point <i>from</i> the callee <i>to</i> the caller. This creates all kinds of problem. Just try to imagine how, in a programming language, you would specify the allowed callers of your object.<p>This translates to UX, too: Say you are using Google Docs, and you want to &quot;share&quot; access to a document with Alice. Traditionally this is seen (by the implementers -- I was once on the Google Docs sharing team) as a two-step process:<p>1. Grant access: Add Alice to the access control list.<p>2. Notify: Send Alice an e-mail notifying her that she should open the document.<p>Part 2 is obviously necessary and natural. You intuitively know you must tell Alice about your document.<p>Part 1 may sound obvious to any techie, but it&#x27;s not at all: Users regularly forget this step, and we build all kinds of UI to try to recover from this. And even if it were obvious, it&#x27;s problematic. What if Alice doesn&#x27;t have a Google account? What if she does, but I don&#x27;t know the email address tied to that account, because it&#x27;s not her usual address?<p>What we really want to do is eliminate part 1 and have only part 2: Abstractly, when you notify Alice of the document, that notification should itself <i>contain</i> the permission to access the document. Then I don&#x27;t need to know Alice&#x27;s Google account ID, I just need to know how to send her a message containing the permissions. (This is analogous to sending a pointer in code -- receiving the pointer grants the recipient the ability to access the pointed-to object.)<p>This is the essence of capability-based security at the UX level: Deriving access control from actions you were already doing. The user rarely needs to be confronted with a security action, yet the right people end up getting access.<p>Some will argue that such implicit security is inherently dangerous because it&#x27;s hard to audit and control. I argue that &quot;explicit&quot; security is dangerous because it&#x27;s hard for users to understand and use correctly -- inevitably, many will simply turn the security off.<p>But there&#x27;s a compromise: If the underlying system deeply understands capabilities and knows when they are being passed, it can maintain an &quot;access control list&quot; on the side, automatically populating it based on the observed movement of capabilities. This pseudo-ACL can allow the user to audit who has access to their document and revoke people who shouldn&#x27;t be there. It also offers a place to hook in policies: if the system observes a capability movement that is contrary to some explicit policy (say, &quot;documents shall not be shared outside the organization&quot;), then it can revoke that capability.<p>This is the model we&#x27;re implementing in Sandstorm:<p><a href="https:&#x2F;&#x2F;sandstorm.io" rel="nofollow">https:&#x2F;&#x2F;sandstorm.io</a><p><a href="https:&#x2F;&#x2F;docs.sandstorm.io&#x2F;en&#x2F;latest&#x2F;developing&#x2F;security-practices&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.sandstorm.io&#x2F;en&#x2F;latest&#x2F;developing&#x2F;security-prac...</a><p>And Cap&#x27;n Proto RPC implement capabilities at the network level:<p><a href="https:&#x2F;&#x2F;capnproto.org&#x2F;rpc.html" rel="nofollow">https:&#x2F;&#x2F;capnproto.org&#x2F;rpc.html</a><p>(I am the lead developer of both Sandstorm and Cap&#x27;n Proto.)<p>Other good reading:<p><a href="http:&#x2F;&#x2F;srl.cs.jhu.edu&#x2F;pubs&#x2F;SRL2003-02.pdf" rel="nofollow">http:&#x2F;&#x2F;srl.cs.jhu.edu&#x2F;pubs&#x2F;SRL2003-02.pdf</a> - Capability Myths Demolished, an academic paper.<p><a href="http:&#x2F;&#x2F;joeduffyblog.com&#x2F;2015&#x2F;11&#x2F;10&#x2F;objects-as-secure-capabilities&#x2F;" rel="nofollow">http:&#x2F;&#x2F;joeduffyblog.com&#x2F;2015&#x2F;11&#x2F;10&#x2F;objects-as-secure-capabil...</a> - About Microsoft&#x27;s Midori research OS, which was also based on this model.