1<?xml version="1.0" encoding="UTF-8"?>
2<protocol name="security_context_v1">
3 <copyright>
4 Copyright © 2021 Simon Ser
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice (including the next
14 paragraph) shall be included in all copies or substantial portions of the
15 Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 DEALINGS IN THE SOFTWARE.
24 </copyright>
25
26 <interface name="wp_security_context_manager_v1" version="1">
27 <description summary="client security context manager">
28 This interface allows a client to register a new Wayland connection to
29 the compositor and attach a security context to it.
30
31 This is intended to be used by sandboxes. Sandbox engines attach a
32 security context to all connections coming from inside the sandbox. The
33 compositor can then restrict the features that the sandboxed connections
34 can use.
35
36 Compositors should forbid nesting multiple security contexts by not
37 exposing wp_security_context_manager_v1 global to clients with a security
38 context attached, or by sending the nested protocol error. Nested
39 security contexts are dangerous because they can potentially allow
40 privilege escalation of a sandboxed client.
41
42 Warning! The protocol described in this file is currently in the testing
43 phase. Backward compatible changes may be added together with the
44 corresponding interface version bump. Backward incompatible changes can
45 only be done by creating a new major version of the extension.
46 </description>
47
48 <enum name="error">
49 <entry name="invalid_listen_fd" value="1"
50 summary="listening socket FD is invalid"/>
51 <entry name="nested" value="2"
52 summary="nested security contexts are forbidden"/>
53 </enum>
54
55 <request name="destroy" type="destructor">
56 <description summary="destroy the manager object">
57 Destroy the manager. This doesn't destroy objects created with the
58 manager.
59 </description>
60 </request>
61
62 <request name="create_listener">
63 <description summary="create a new security context">
64 Creates a new security context with a socket listening FD.
65
66 The compositor will accept new client connections on listen_fd.
67 listen_fd must be ready to accept new connections when this request is
68 sent by the client. In other words, the client must call bind(2) and
69 listen(2) before sending the FD.
70
71 close_fd is a FD that will signal hangup when the compositor should stop
72 accepting new connections on listen_fd.
73
74 The compositor must continue to accept connections on listen_fd when
75 the Wayland client which created the security context disconnects.
76
77 After sending this request, closing listen_fd and close_fd remains the
78 only valid operation on them.
79 </description>
80 <arg name="id" type="new_id" interface="wp_security_context_v1"/>
81 <arg name="listen_fd" type="fd" summary="listening socket FD"/>
82 <arg name="close_fd" type="fd" summary="FD signaling when done"/>
83 </request>
84 </interface>
85
86 <interface name="wp_security_context_v1" version="1">
87 <description summary="client security context">
88 The security context allows a client to register a new client and attach
89 security context metadata to the connections.
90
91 When both are set, the combination of the application ID and the sandbox
92 engine must uniquely identify an application. The same application ID
93 will be used across instances (e.g. if the application is restarted, or
94 if the application is started multiple times).
95
96 When both are set, the combination of the instance ID and the sandbox
97 engine must uniquely identify a running instance of an application.
98 </description>
99
100 <enum name="error">
101 <entry name="already_used" value="1"
102 summary="security context has already been committed"/>
103 <entry name="already_set" value="2"
104 summary="metadata has already been set"/>
105 <entry name="invalid_metadata" value="3"
106 summary="metadata is invalid"/>
107 </enum>
108
109 <request name="destroy" type="destructor">
110 <description summary="destroy the security context object">
111 Destroy the security context object.
112 </description>
113 </request>
114
115 <request name="set_sandbox_engine">
116 <description summary="set the sandbox engine">
117 Attach a unique sandbox engine name to the security context. The name
118 should follow the reverse-DNS style (e.g. "org.flatpak").
119
120 A list of well-known engines is maintained at:
121 https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/staging/security-context/engines.md
122
123 It is a protocol error to call this request twice. The already_set
124 error is sent in this case.
125 </description>
126 <arg name="name" type="string" summary="the sandbox engine name"/>
127 </request>
128
129 <request name="set_app_id">
130 <description summary="set the application ID">
131 Attach an application ID to the security context.
132
133 The application ID is an opaque, sandbox-specific identifier for an
134 application. See the well-known engines document for more details:
135 https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/staging/security-context/engines.md
136
137 The compositor may use the application ID to group clients belonging to
138 the same security context application.
139
140 Whether this request is optional or not depends on the sandbox engine used.
141
142 It is a protocol error to call this request twice. The already_set
143 error is sent in this case.
144 </description>
145 <arg name="app_id" type="string" summary="the application ID"/>
146 </request>
147
148 <request name="set_instance_id">
149 <description summary="set the instance ID">
150 Attach an instance ID to the security context.
151
152 The instance ID is an opaque, sandbox-specific identifier for a running
153 instance of an application. See the well-known engines document for
154 more details:
155 https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/staging/security-context/engines.md
156
157 Whether this request is optional or not depends on the sandbox engine used.
158
159 It is a protocol error to call this request twice. The already_set
160 error is sent in this case.
161 </description>
162 <arg name="instance_id" type="string" summary="the instance ID"/>
163 </request>
164
165 <request name="commit">
166 <description summary="register the security context">
167 Atomically register the new client and attach the security context
168 metadata.
169
170 If the provided metadata is inconsistent or does not match with out of
171 band metadata (see
172 https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/staging/security-context/engines.md),
173 the invalid_metadata error may be sent eventually.
174
175 It's a protocol error to send any request other than "destroy" after
176 this request. In this case, the already_used error is sent.
177 </description>
178 </request>
179 </interface>
180</protocol>