xref: /freebsd/share/man/man4/capsicum.4 (revision 924226fba12cc9a228c73b956e1b7fa24c60b055)
1.\"
2.\" Copyright (c) 2011, 2013 Robert N. M. Watson
3.\" Copyright (c) 2011 Jonathan Anderson
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.\" $FreeBSD$
28.\"
29.Dd April 19, 2022
30.Dt CAPSICUM 4
31.Os
32.Sh NAME
33.Nm Capsicum
34.Nd lightweight OS capability and sandbox framework
35.Sh SYNOPSIS
36.Cd "options CAPABILITY_MODE"
37.Cd "options CAPABILITIES"
38.Sh DESCRIPTION
39.Nm
40is a lightweight OS capability and sandbox framework implementing a hybrid
41capability system model.
42Capabilities are unforgeable tokens of authority that can be delegated and must
43be presented to perform an action.
44.Nm
45makes file descriptors into capabilities.
46.Pp
47.Nm
48can be used for application and library compartmentalisation, the
49decomposition of larger bodies of software into isolated (sandboxed)
50components in order to implement security policies and limit the impact of
51software vulnerabilities.
52.Pp
53.Nm
54provides two core kernel primitives:
55.Bl -tag -width indent
56.It capability mode
57A process mode, entered by invoking
58.Xr cap_enter 2 ,
59in which access to global OS namespaces (such as the file system and PID
60namespaces) is restricted; only explicitly delegated rights, referenced by
61memory mappings or file descriptors, may be used.
62Once set, the flag is inherited by future children processes, and may not be
63cleared.
64.It capabilities
65Limit operations that can be called on file descriptors.
66For example, a file descriptor returned by
67.Xr open 2
68may be refined using
69.Xr cap_rights_limit 2
70so that only
71.Xr read 2
72and
73.Xr write 2
74can be called, but not
75.Xr fchmod 2 .
76The complete list of the capability rights can be found in the
77.Xr rights 4
78manual page.
79.El
80.Pp
81In some cases,
82.Nm
83requires use of alternatives to traditional POSIX APIs in order to name
84objects using capabilities rather than global namespaces:
85.Bl -tag -width indent
86.It process descriptors
87File descriptors representing processes, allowing parent processes to manage
88child processes without requiring access to the PID namespace; described in
89greater detail in
90.Xr procdesc 4 .
91.It anonymous shared memory
92An extension to the POSIX shared memory API to support anonymous swap objects
93associated with file descriptors; described in greater detail in
94.Xr shm_open 2 .
95.El
96.Pp
97In some cases,
98.Nm
99limits the valid values of some parameters to traditional APIs in order to
100restrict access to global namespaces:
101.Bl -tag -width indent
102.It process IDs
103Processes can only act upon their own process ID with syscalls such as
104.Xr cpuset_setaffinity 2 .
105.El
106.Sh SEE ALSO
107.Xr cap_enter 2 ,
108.Xr cap_fcntls_limit 2 ,
109.Xr cap_getmode 2 ,
110.Xr cap_ioctls_limit 2 ,
111.Xr cap_rights_limit 2 ,
112.Xr fchmod 2 ,
113.Xr open 2 ,
114.Xr pdfork 2 ,
115.Xr pdgetpid 2 ,
116.Xr pdkill 2 ,
117.Xr pdwait4 2 ,
118.Xr read 2 ,
119.Xr shm_open 2 ,
120.Xr write 2 ,
121.Xr cap_rights_get 3 ,
122.Xr libcasper 3 ,
123.Xr procdesc 4
124.Sh HISTORY
125.Nm
126first appeared in
127.Fx 9.0 ,
128and was developed at the University of Cambridge.
129.Sh AUTHORS
130.Nm
131was developed by
132.An -nosplit
133.An Robert Watson Aq Mt rwatson@FreeBSD.org
134and
135.An Jonathan Anderson Aq Mt jonathan@FreeBSD.org
136at the University of Cambridge, and
137.An Ben Laurie Aq Mt benl@FreeBSD.org
138and
139.An Kris Kennaway Aq Mt kris@FreeBSD.org
140at Google, Inc., and
141.An Pawel Jakub Dawidek Aq Mt pawel@dawidek.net .
142