2016-12-02 15:05:43 +00:00
|
|
|
/////
|
|
|
|
vim:set ts=4 sw=4 tw=82 noet:
|
|
|
|
/////
|
|
|
|
sway-security (7)
|
|
|
|
=================
|
|
|
|
|
|
|
|
Name
|
|
|
|
----
|
|
|
|
sway-security - Guidelines for securing your sway install
|
|
|
|
|
|
|
|
Security Overview
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
**Sway is NOT secure**. We are working on it but do not trust that we have it all
|
|
|
|
figured out yet. The following man page is provisional.
|
|
|
|
|
|
|
|
Securing sway requires careful configuration of your environment, the sort that's
|
2017-10-14 19:39:53 +00:00
|
|
|
usually best suited to a distribution maintainer who wants to ship a secure sway
|
|
|
|
environment in their distribution. Sway provides a number of means of securing it but
|
2016-12-02 15:05:43 +00:00
|
|
|
you must make a few changes external to sway first.
|
|
|
|
|
2017-02-19 07:36:36 +00:00
|
|
|
Configuration of security features is limited to files in the security directory
|
|
|
|
(this is likely /etc/sway/security.d/*, but depends on your installation prefix).
|
2017-03-16 15:12:22 +00:00
|
|
|
Files in this directory must be owned by root:root and chmod 644 or 444. The default
|
2017-02-19 07:36:36 +00:00
|
|
|
security configuration is installed to /etc/sway/security.d/00-defaults, and
|
|
|
|
should not be modified - it will be updated with the latest recommended security
|
|
|
|
defaults between releases. To override the defaults, you should add more files to
|
|
|
|
this directory.
|
2016-12-02 15:05:43 +00:00
|
|
|
|
|
|
|
Environment security
|
|
|
|
--------------------
|
|
|
|
|
2016-12-02 15:29:50 +00:00
|
|
|
LD_PRELOAD is a mechanism designed to ruin the security of your system. There are
|
2017-10-14 19:39:53 +00:00
|
|
|
a number of strategies for dealing with this, but they all suck a little. In order
|
2016-12-02 15:29:50 +00:00
|
|
|
of most practical to least practical:
|
2016-12-02 15:05:43 +00:00
|
|
|
|
|
|
|
1. Only run important programs via exec. Sway's exec command will ensure that
|
|
|
|
LD_PRELOAD is unset when running programs.
|
|
|
|
|
|
|
|
2. Remove LD_PRELOAD support from your dynamic loader (requires patching libc).
|
|
|
|
This may break programs that rely on LD_PRELOAD for legitimate functionality,
|
|
|
|
but this is the most effective solution.
|
|
|
|
|
|
|
|
3. Use static linking for important programs. Of course statically linked programs
|
2016-12-02 15:29:50 +00:00
|
|
|
are unaffected by the dynamic linking security dumpster fire.
|
2016-12-02 15:05:43 +00:00
|
|
|
|
|
|
|
Note that should you choose method 1, you MUST ensure that sway itself isn't
|
|
|
|
compromised by LD_PRELOAD. It probably isn't, but you can be sure by setting
|
|
|
|
/usr/bin/sway to a+s (setuid), which will instruct the dynamic linker not to
|
|
|
|
permit LD_PRELOAD for it (and will also run it as root, which sway will shortly
|
|
|
|
drop). You could also statically link sway itself.
|
|
|
|
|
2017-10-14 19:39:53 +00:00
|
|
|
Note that LD_LIBRARY_PATH has all of these problems, and the same solutions.
|
2016-12-02 15:23:30 +00:00
|
|
|
|
2016-12-02 15:05:43 +00:00
|
|
|
Read your log
|
|
|
|
-------------
|
|
|
|
|
|
|
|
Sway does sanity checks and prints big red warnings to stderr if they fail. Read
|
|
|
|
them.
|
|
|
|
|
|
|
|
Feature policies
|
|
|
|
----------------
|
|
|
|
|
|
|
|
Certain sway features are security sensitive and may be configured with security
|
|
|
|
policies. These features are:
|
|
|
|
|
|
|
|
**background**::
|
|
|
|
Permission for a program to become the background.
|
|
|
|
|
|
|
|
**fullscreen**::
|
|
|
|
Permission to become fullscreen. Note that users can always make a window
|
|
|
|
fullscreen themselves with the fullscreen command.
|
|
|
|
|
2016-12-02 23:08:15 +00:00
|
|
|
**ipc**::
|
|
|
|
Permission to connect to sway's IPC socket.
|
|
|
|
|
2016-12-02 15:05:43 +00:00
|
|
|
**keyboard**::
|
2016-12-02 15:17:53 +00:00
|
|
|
Permission to receive keyboard events (only while they are focused).
|
2016-12-02 15:05:43 +00:00
|
|
|
|
|
|
|
**lock**::
|
|
|
|
Permission for a program to act as a screen locker. This involves becoming
|
2016-12-02 15:34:17 +00:00
|
|
|
fullscreen (on all outputs) and receiving _all_ keyboard and mouse input for
|
|
|
|
the duration of the process.
|
2016-12-02 15:05:43 +00:00
|
|
|
|
|
|
|
**mouse**::
|
2016-12-02 15:17:53 +00:00
|
|
|
Permission to receive mouse events (only while the mouse is over them).
|
2016-12-02 15:05:43 +00:00
|
|
|
|
|
|
|
**panel**::
|
|
|
|
Permission for a program to stick its windows to the sides of the screen.
|
|
|
|
|
|
|
|
**screenshot**::
|
|
|
|
Permission to take screenshots or record the screen.
|
|
|
|
|
2016-12-04 14:49:13 +00:00
|
|
|
By default, no permissions are granted (though saner defaults are provided in
|
2017-10-14 19:39:53 +00:00
|
|
|
/etc/sway/config.d/security). You can use the following configuration options to control
|
2016-12-04 14:49:13 +00:00
|
|
|
a program's access:
|
2016-12-02 15:05:43 +00:00
|
|
|
|
|
|
|
**permit** <executable> <features...>::
|
2017-10-14 19:39:53 +00:00
|
|
|
Permits <executable> to use <features> (each feature separated by a space).
|
2016-12-02 15:32:08 +00:00
|
|
|
<executable> may be * to affect the default policy, or the full path to the
|
|
|
|
executable file.
|
2016-12-02 15:05:43 +00:00
|
|
|
|
|
|
|
**reject** <executable> <features...>::
|
2017-10-14 19:39:53 +00:00
|
|
|
Disallows <executable> from using <features> (each feature separated by a space).
|
2016-12-02 15:32:08 +00:00
|
|
|
<executable> may be * to affect the default policy, or the full path to the
|
|
|
|
executable file.
|
2016-12-02 15:05:43 +00:00
|
|
|
|
|
|
|
Note that policy enforcement requires procfs to be mounted at /proc and the sway
|
|
|
|
process to be able to access _/proc/[pid]/exe_ (see **procfs(5)** for details on
|
|
|
|
this access - setcap cap_sys_ptrace=eip /usr/bin/sway should do the trick). If
|
|
|
|
sway is unable to read _/proc/[pid]/exe_, it will apply the default policy.
|
|
|
|
|
2016-12-02 15:13:06 +00:00
|
|
|
To work correctly, sway's own programs require the following permissions:
|
|
|
|
|
|
|
|
- swaybg: background
|
|
|
|
- swaylock: lock, keyboard
|
2016-12-03 17:38:42 +00:00
|
|
|
- swaybar: panel, mouse, ipc
|
|
|
|
- swaygrab: screenshot, ipc
|
|
|
|
|
|
|
|
When you first declare a policy for an executable, it will inherit the default
|
|
|
|
policy. Further changes to the default policy will not retroactively affect which
|
|
|
|
permissions an earlier policy inherits. You must explicitly reject any features
|
|
|
|
from the default policy that you do not want an executable to receive permission
|
|
|
|
for.
|
2016-12-02 15:13:06 +00:00
|
|
|
|
2016-12-02 15:05:43 +00:00
|
|
|
Command policies
|
|
|
|
----------------
|
|
|
|
|
|
|
|
You can also control the context from which a command may execute. The different
|
|
|
|
contexts you can control are:
|
|
|
|
|
|
|
|
**config**::
|
|
|
|
Can be run from your config file.
|
|
|
|
|
|
|
|
**binding**::
|
|
|
|
Can be run from bindsym or bindcode commands.
|
|
|
|
|
|
|
|
**ipc**::
|
|
|
|
Can be run by IPC clients.
|
|
|
|
|
|
|
|
**criteria**::
|
|
|
|
Can be run when evaluating window criteria.
|
|
|
|
|
2016-12-03 17:38:42 +00:00
|
|
|
**all**::
|
|
|
|
Shorthand for granting permission in all contexts.
|
|
|
|
|
2016-12-02 15:05:43 +00:00
|
|
|
By default a command is allowed to execute in any context. To configure this, open
|
|
|
|
a commands block and fill it with policies:
|
|
|
|
|
|
|
|
commands {
|
|
|
|
<name> <contexts...>
|
|
|
|
...
|
|
|
|
}
|
|
|
|
|
|
|
|
For example, you could do this to limit the use of the focus command to just
|
2017-10-14 19:39:53 +00:00
|
|
|
binding and criteria:
|
2016-12-02 15:05:43 +00:00
|
|
|
|
|
|
|
commands {
|
|
|
|
focus binding criteria
|
|
|
|
}
|
|
|
|
|
2016-12-03 17:38:42 +00:00
|
|
|
Setting a command policy overwrites any previous policy that was in place.
|
|
|
|
|
2016-12-02 15:05:43 +00:00
|
|
|
IPC policies
|
|
|
|
------------
|
|
|
|
|
2017-02-19 07:36:36 +00:00
|
|
|
Disabling IPC access via swaymsg is encouraged if you intend to secure the IPC
|
|
|
|
socket, because any program that can execute swaymsg could circumvent its own
|
|
|
|
security policy by simply invoking swaymsg.
|
2016-12-02 15:05:43 +00:00
|
|
|
|
2017-02-19 07:36:36 +00:00
|
|
|
You can configure which features of IPC are available for particular clients:
|
2016-12-02 15:05:43 +00:00
|
|
|
|
2017-02-19 07:36:36 +00:00
|
|
|
ipc <executable> {
|
2016-12-02 15:05:43 +00:00
|
|
|
...
|
|
|
|
}
|
|
|
|
|
2017-02-19 07:36:36 +00:00
|
|
|
You may use * for <executable> to configure the default policy for all clients.
|
|
|
|
Configuring IPC policies for specific executables is not supported on FreeBSD, and
|
|
|
|
the default policy will be applied to all IPC connections.
|
|
|
|
|
2016-12-02 15:05:43 +00:00
|
|
|
The following commands are available within this block:
|
|
|
|
|
|
|
|
**bar-config** <enabled|disabled>::
|
|
|
|
Controls GET_BAR_CONFIG (required for swaybar to work at all).
|
|
|
|
|
|
|
|
**command** <enabled|disabled>::
|
|
|
|
Controls executing sway commands via IPC.
|
|
|
|
|
|
|
|
**inputs** <enabled|disabled>::
|
|
|
|
Controls GET_INPUTS (input device information).
|
|
|
|
|
|
|
|
**marks** <enabled|disabled>::
|
|
|
|
Controls GET_MARKS.
|
|
|
|
|
|
|
|
**outputs** <enabled|disabled>::
|
|
|
|
Controls GET_OUTPUTS.
|
|
|
|
|
|
|
|
**tree** <enabled|disabled>::
|
|
|
|
Controls GET_TREE.
|
|
|
|
|
|
|
|
**workspaces** <enabled|disabled>::
|
|
|
|
Controls GET_WORKSPACES.
|
|
|
|
|
|
|
|
You can also control which IPC events can be raised with an events block:
|
|
|
|
|
2017-02-19 07:36:36 +00:00
|
|
|
ipc <executable> {
|
2016-12-02 15:05:43 +00:00
|
|
|
events {
|
|
|
|
...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-14 19:39:53 +00:00
|
|
|
The following commands are valid within an IPC events block:
|
2016-12-02 15:05:43 +00:00
|
|
|
|
|
|
|
**binding** <enabled|disabled>::
|
|
|
|
Controls keybinding notifications (disabled by default).
|
|
|
|
|
|
|
|
**input** <enabled|disabled>::
|
|
|
|
Controls input device hotplugging notifications.
|
|
|
|
|
|
|
|
**mode** <enabled|disabled>::
|
|
|
|
Controls output hotplugging notifications.
|
|
|
|
|
|
|
|
**output** <enabled|disabled>::
|
|
|
|
Controls output hotplugging notifications.
|
|
|
|
|
|
|
|
**window** <enabled|disabled>::
|
|
|
|
Controls window event notifications.
|
|
|
|
|
|
|
|
**workspace** <enabled|disabled>::
|
|
|
|
Controls workspace notifications.
|
|
|
|
|
2017-02-19 07:36:36 +00:00
|
|
|
In each of these blocks, you may use * (as in "* enabled" or "* disabled") to
|
|
|
|
control access to every feature at once.
|
2016-12-02 15:05:43 +00:00
|
|
|
|
|
|
|
Authors
|
|
|
|
-------
|
|
|
|
Maintained by Drew DeVault <sir@cmpwn.com>, who is assisted by other open
|
|
|
|
source contributors. For more information about sway development, see
|
2017-10-06 03:13:42 +00:00
|
|
|
<https://github.com/swaywm/sway>.
|