aboutsummaryrefslogtreecommitdiffstats
path: root/sway/sway-security.7.txt
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2016-12-02 10:05:43 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2016-12-02 10:05:43 -0500
commit3dbeb9c35cd3cd71b318370b776bdaa00436a356 (patch)
tree9dc5d18e412e8666425f74b5b43e28b2f5271812 /sway/sway-security.7.txt
parentUnset LD_PRELOAD on startup (before dropping root) (diff)
downloadsway-3dbeb9c35cd3cd71b318370b776bdaa00436a356.tar.gz
sway-3dbeb9c35cd3cd71b318370b776bdaa00436a356.tar.zst
sway-3dbeb9c35cd3cd71b318370b776bdaa00436a356.zip
Add sway-security(7)
Diffstat (limited to 'sway/sway-security.7.txt')
-rw-r--r--sway/sway-security.7.txt229
1 files changed, 229 insertions, 0 deletions
diff --git a/sway/sway-security.7.txt b/sway/sway-security.7.txt
new file mode 100644
index 00000000..f3d4a229
--- /dev/null
+++ b/sway/sway-security.7.txt
@@ -0,0 +1,229 @@
1/////
2vim:set ts=4 sw=4 tw=82 noet:
3/////
4sway-security (7)
5=================
6
7Name
8----
9sway-security - Guidelines for securing your sway install
10
11Security Overview
12-----------------
13
14**Sway is NOT secure**. We are working on it but do not trust that we have it all
15figured out yet. The following man page is provisional.
16
17Securing sway requires careful configuration of your environment, the sort that's
18usually best suited to a distro maintainer who wants to ship a secure sway
19environment in their distro. Sway provides a number of means of securing it but
20you must make a few changes external to sway first.
21
22Configuration security
23----------------------
24
25Many of Sway's security features are configurable. It's important that a possibly
26untrusted program is not able to edit this. Security rules are kept in
27_/etc/sway/config.d/security_ (usually), which should only be writable by root.
28However, configuration of security rules is not limited to this file - any config
29file that sway loads (including i.e. _~/.config/sway/config_) should not be editable
30by the user you intend to run programs as. One simple strategy is to use
31/etc/sway/config instead of a config file in your home directory, but that doesn't
32work well for multi-user systems. A more robust strategy is to run untrusted
33programs as another user, or in a sandbox. Configuring this is up to you.
34
35Note that _/etc/sway/config.d/*_ must be included explicitly from your config file.
36This is done by default in /etc/sway/config but you must check your own config if
37you choose to place it in other locations.
38
39Environment security
40--------------------
41
42LD_PRELOAD is a mechanism designed by GNU for the purpose of ruining the security
43of your system. One of the many ways LD_PRELOAD kills security is by making
44Wayland keyloggers possible.
45
46There are a number of strategies for dealing with this but they all suck a little.
47In order of most practical to least practical:
48
491. Only run important programs via exec. Sway's exec command will ensure that
50 LD_PRELOAD is unset when running programs.
51
522. Remove LD_PRELOAD support from your dynamic loader (requires patching libc).
53 This may break programs that rely on LD_PRELOAD for legitimate functionality,
54 but this is the most effective solution.
55
563. Use static linking for important programs. Of course statically linked programs
57 are unaffected by the security dumpster fire that is dynamic linking.
58
59Note that should you choose method 1, you MUST ensure that sway itself isn't
60compromised by LD_PRELOAD. It probably isn't, but you can be sure by setting
61/usr/bin/sway to a+s (setuid), which will instruct the dynamic linker not to
62permit LD_PRELOAD for it (and will also run it as root, which sway will shortly
63drop). You could also statically link sway itself.
64
65Read your log
66-------------
67
68Sway does sanity checks and prints big red warnings to stderr if they fail. Read
69them.
70
71Feature policies
72----------------
73
74Certain sway features are security sensitive and may be configured with security
75policies. These features are:
76
77**background**::
78 Permission for a program to become the background.
79
80**fullscreen**::
81 Permission to become fullscreen. Note that users can always make a window
82 fullscreen themselves with the fullscreen command.
83
84**keyboard**::
85 Permission to receive keyboard events.
86
87**lock**::
88 Permission for a program to act as a screen locker. This involves becoming
89 fullscreen (on all outputs) and accepting all keyboard and mouse input for the
90 duration of the process.
91
92**mouse**::
93 Permission to receive mouse events.
94
95**panel**::
96 Permission for a program to stick its windows to the sides of the screen.
97
98**screenshot**::
99 Permission to take screenshots or record the screen.
100
101By default, all programs are granted **fullscreen**, **keyboard**, and **mouse**
102permissions. You can use the following config commands to control a program's
103access:
104
105**permit** <executable> <features...>::
106 Permits <executable> to use <features> (each feature seperated by a space).
107 <executable> may be * to affect the default policy.
108
109**reject** <executable> <features...>::
110 Disallows <executable> from using <features> (each feature seperated by a space).
111 <executable> may be * to affect the default policy.
112
113Note that policy enforcement requires procfs to be mounted at /proc and the sway
114process to be able to access _/proc/[pid]/exe_ (see **procfs(5)** for details on
115this access - setcap cap_sys_ptrace=eip /usr/bin/sway should do the trick). If
116sway is unable to read _/proc/[pid]/exe_, it will apply the default policy.
117
118Command policies
119----------------
120
121You can also control the context from which a command may execute. The different
122contexts you can control are:
123
124**config**::
125 Can be run from your config file.
126
127**binding**::
128 Can be run from bindsym or bindcode commands.
129
130**ipc**::
131 Can be run by IPC clients.
132
133**criteria**::
134 Can be run when evaluating window criteria.
135
136By default a command is allowed to execute in any context. To configure this, open
137a commands block and fill it with policies:
138
139 commands {
140 <name> <contexts...>
141 ...
142 }
143
144For example, you could do this to limit the use of the focus command to just
145binding and critiera:
146
147 commands {
148 focus binding criteria
149 }
150
151IPC policies
152------------
153
154By default all programs can connect to IPC for backwards compatability with i3.
155However, you can whitelist IPC access like so:
156
157 reject * ipc
158 permit /usr/bin/swaybar ipc
159 permit /usr/bin/swaygrab ipc
160 # etc
161
162Note that it's suggested you do not enable swaymsg to access IPC if you intend to
163secure your IPC socket, because any program could just run swaymsg itself instead
164of connecting to IPC directly.
165
166You can also configure which features of IPC are available with an IPC block:
167
168 ipc {
169 ...
170 }
171
172The following commands are available within this block:
173
174**bar-config** <enabled|disabled>::
175 Controls GET_BAR_CONFIG (required for swaybar to work at all).
176
177**command** <enabled|disabled>::
178 Controls executing sway commands via IPC.
179
180**inputs** <enabled|disabled>::
181 Controls GET_INPUTS (input device information).
182
183**marks** <enabled|disabled>::
184 Controls GET_MARKS.
185
186**outputs** <enabled|disabled>::
187 Controls GET_OUTPUTS.
188
189**tree** <enabled|disabled>::
190 Controls GET_TREE.
191
192**workspaces** <enabled|disabled>::
193 Controls GET_WORKSPACES.
194
195You can also control which IPC events can be raised with an events block:
196
197 ipc {
198 events {
199 ...
200 }
201 }
202
203The following commands are vaild within an ipc events block:
204
205**binding** <enabled|disabled>::
206 Controls keybinding notifications (disabled by default).
207
208**input** <enabled|disabled>::
209 Controls input device hotplugging notifications.
210
211**mode** <enabled|disabled>::
212 Controls output hotplugging notifications.
213
214**output** <enabled|disabled>::
215 Controls output hotplugging notifications.
216
217**window** <enabled|disabled>::
218 Controls window event notifications.
219
220**workspace** <enabled|disabled>::
221 Controls workspace notifications.
222
223Disabling some of these may cause swaybar to behave incorrectly.
224
225Authors
226-------
227Maintained by Drew DeVault <sir@cmpwn.com>, who is assisted by other open
228source contributors. For more information about sway development, see
229<https://github.com/SirCmpwn/sway>.