# Object-capability model

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Object-capability_model
> Markdown URL: https://mediated.wiki/source/Object-capability_model.md
> Source: https://en.wikipedia.org/wiki/Object-capability_model
> Source revision: 1310378429
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|Computer security model}}
{{Multiple issues|
{{Primary sources|date=December 2013}}
{{More citations needed|date=December 2013}}
}}

The '''object-capability model''' is a [computer security model](/source/computer_security_model). A [capability](/source/Capability-based_security) describes a transferable right to perform one (or more) operations on a given [object](/source/Object_(computer_science)). It can be obtained by the following combination:
:* An unforgeable reference (in the sense of object references or protected pointers) that can be sent in messages.
:* A message that specifies the operation to be performed.

The security model relies on not being able to forge references. 
:* Objects can interact only by sending messages on references.
:* A reference can be obtained by:
::# Initial conditions: In the initial state of the computational world being described, object A may already have a reference to object B.
::# Parenthood: If A creates B, at that moment A obtains the only reference to the newly created B.
::# Endowment: If A creates B, B is born with that subset of A's references with which A chose to endow it.
::# Introduction: If A has references to both B and C, A can send to B a message containing a reference to C. B can retain that reference for subsequent use.

In the object-capability model, ''all'' computation is performed following the above rules.

Advantages that motivate [object-oriented programming](/source/Object_(computer_science)), such as encapsulation or [information hiding](/source/information_hiding), [modular programming](/source/modular_programming) (modularity), and [separation of concerns](/source/separation_of_concerns), correspond to security goals such as [least privilege](/source/principle_of_least_privilege) and [privilege separation](/source/privilege_separation) in capability-based programming.<ref name=thesis>
{{cite report |last1=Miller |first1=Mark Samuel |author1-link=Mark S. Miller |date=May 2006 |title=Robust Composition: Towards a Unified Approach to Access Control and Concurrency Control |url=http://erights.org/talks/thesis/ |work=erights.org |location=Baltimore, Maryland |access-date=28 July 2013}}</ref><ref>
{{Cite report |last1=Miller |first1=Mark S. |author1-link=Mark S. Miller |last2=Yee |first2=Ka-Ping |last3=Shapiro |first3=Jonathan S. |year=2003 |url=https://srl.cs.jhu.edu/pubs/SRL2003-02.pdf |title=Capability Myths Demolished |version=Technical Report SRL2003-02 |publisher=Systems Research Lab, Johns Hopkins University}}</ref>

The object-capability model was first proposed by [Jack Dennis](/source/Jack_Dennis) and Earl C. Van Horn in 1966.<ref>[https://srl.cs.jhu.edu/pubs/SRL2003-03.pdf] citing: J.B. Dennis, E.C. Van Horn. “Programming Semantics for Multiprogrammed Computations.” Communications of the ACM, 9(3):143–155, March 1966.</ref>

==Loopholes in object-oriented programming languages==
{{original research section|date=October 2016}}
Some object-based programming languages (e.g., [JavaScript](/source/JavaScript) ([criticism](/source/Criticism_of_JavaScript)), [Java](/source/Java_(programming_language)), and [C#](/source/C_Sharp_(programming_language))) provide ways to access resources in ways other than according to the rules above, including the following:
:*Direct [assignment](/source/Assignment_(computer_science)) to the [instance variable](/source/instance_variable)s of an object in Java and C#.
:*Direct [reflective programming](/source/reflective_programming) (reflection) inspection of the meta-data of an object in Java and C#.
:*The pervasive ability to import primitive modules, e.g., java.io.File that enable external effects.

Such use of ''undeniable authority'' violates the conditions of the object-capability model. [Caja](/source/Caja_(programming_language)) and [Joe-E](/source/Joe-E) are variants of JavaScript and Java, respectively, that impose restrictions to eliminate these loopholes.

==Advantages of object capabilities==
Computer scientist E. Dean Tribble stated that in [smart contract](/source/smart_contract)s, identity-based access control did not support well dynamically changing permissions, compared to the object-capability model. He analogized the ocap model with giving a [valet](/source/valet_parking) the key to a car, without giving the right to car ownership.<ref name="chorus-one">{{cite web |last1=Lutsch |first1=Felix |title=Agoric Q&A with Dean Tribble |url=https://blog.chorus.one/agoric-qa-transcript/ |website=Chorus One |language=en |date=26 August 2019}}</ref>

The structural properties of object capability systems favor modularity in code design and ensure reliable encapsulation in code implementation.

These structural properties facilitate the analysis of some security properties of an object-capability program or [operating system](/source/operating_system). Some of these, specifically information flow properties, can be analyzed at the level of object references and connectivity, independent of any knowledge or analysis of the code that determines the behavior of the objects. As a consequence, these security properties can be established and maintained in the presence of new objects that contain unknown and possibly malicious code.

These structural properties stem from the two rules governing access to existing objects:

:1) An object ''A'' can send a message to ''B'' only if object ''A'' holds a reference to ''B''. 
:2) An object ''A'' can obtain a reference to ''C'' only if object ''A'' receives a message containing a reference to ''C''.

As a consequence of these two rules, an object can obtain a reference to another object only through a preexisting chain of references. In short, "Only connectivity begets connectivity."

==Glossary of related terms==
;object-capability system
: A computational system that implements principles described in this article.
;object
: An object has local state and behavior. An object in this sense is both a ''subject'' and an ''object'' in the sense used in the access control literature. 
;reference
: An unforgeable communications channel (protected pointer, opaque address) that unambiguously designates one object, and provides permission to send messages to that object. 
;message
: What is sent on a reference. Depending on the system, messages may or may not be first-class objects.
;request
: An operation in which a message is sent on a reference. When the message is received, the receiver will have access to any references included in the message.
;attenuation
: A common [design pattern](/source/design_pattern) in object-capability systems: given one reference of an object, create another reference for a proxy object with certain security restrictions, such as only permitting read-only access or allowing revocation. The proxy object performs security checks on messages that it receives and passes on any that are allowed. ''Deep attenuation'' refers to the case where the same attenuation is applied transitively to any objects obtained via the original attenuated object, typically by use of a ''membrane''.

==Implementations==
Almost all historical systems that have been described as ''capability systems'' can be modeled as object-capability systems. However, some uses of the term ''capability'' are inconsistent with the model, such as [POSIX](/source/POSIX) ''capabilities''.

[KeyKOS](/source/KeyKOS), [EROS](/source/EROS_(microkernel)), [Integrity (operating system)](/source/Integrity_(operating_system)),{{dubious|date=October 2016}} CapROS, Coyotos, [seL4](/source/seL4), [OKL4](/source/OKL4) and [Fiasco.OC](/source/Fiasco_(L4_clone)) are secure operating systems that implement the object-capability model.

==Languages that implement object capabilities==
* Act 1 (1981)<ref>
{{Cite report |last1=Lieberman |first1=Henry |title=A Preview of Act 1 (MIT AI memo 625) |date=June 1981 |publisher=MIT}}</ref><ref>
{{Cite report |last1=Lieberman |first1=Henry |title=Thinking About Lots of Things at Once without Getting Confused: Parallelism in Act 1 (MIT AI memo 626) |date=June 1981 |publisher=MIT}}</ref>
*Eden (1985)
*[Emerald](/source/Emerald_(programming_language)) (1987)
*Trusty Scheme (1992)
*W7 (1995)
*[Joule](/source/Joule_(programming_language)) (1996)
*Original-E (1997)
*[https://www.info.ucl.ac.be/~pvr/oze.pdf Oz-E] (2005)
*[Joe-E](/source/Joe-E) (2005)
*[https://web.archive.org/web/20070515041003/http://caperl.links.org/ CaPerl] (2006)
*[http://wiki.erights.org/wiki/Emily Emily] (2006)
*[Caja](/source/Caja_(programming_language)) (2007–2021)
*[https://www.monte-language.org/ Monte] (2008–present)
*[https://www.ponylang.org/ Pony] (2014–present)<ref name="chorus-one"/>
*[Wyvern](/source/Wyvern_(programming_language)) (2012–present)
*[Newspeak](/source/Newspeak_(programming_language)) (2007–present)
*[Hack](/source/Hack_(programming_language)) (2021-present)
*[https://rchain-community.github.io/ Rholang] (2018-present)

==See also==
*[Capability-based security](/source/Capability-based_security)
*[Capability-based addressing](/source/Capability-based_addressing)
*[Actor model](/source/Actor_model)

==References==
{{Reflist}}

{{Object-capability security}}

{{DEFAULTSORT:Object-Capability Model}}
Category:Computer security models

---
Adapted from the Wikipedia article [Object-capability model](https://en.wikipedia.org/wiki/Object-capability_model) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Object-capability_model?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
