diff --git a/CHANGELOG.md b/CHANGELOG.md index 06c48f6e..0dcd64bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - daemon: Stop retrying a transport after 5 consecutive failures before user interaction; other transports keep running. - daemon: Show the UI through the backend that xdg-desktop-portal selects, passed in the new `ui_backend` option - daemon: Treat Debian's Firefox ESR (app ID `firefox-esr`) as a privileged client, like the other Firefox builds +- build: Harden the systemd user services with seccomp-based sandboxing (system call filter, address family and namespace restrictions, no new privileges) (#21) - daemon: Build the list of devices offered to the user from libwebauthn's `available_transports()`, the same source discovery uses (#32) - daemon: Allow clients to cancel requests through xdg-desktop-portal. - ui: Pass the caller's activation token to the compositor when showing the dialog, so it can take focus when the requesting window is in the background (#152) diff --git a/systemd/xyz.iinuwa.credentialsd.Credentials.service.in b/systemd/xyz.iinuwa.credentialsd.Credentials.service.in index 3c17b221..acaa638d 100644 --- a/systemd/xyz.iinuwa.credentialsd.Credentials.service.in +++ b/systemd/xyz.iinuwa.credentialsd.Credentials.service.in @@ -5,3 +5,27 @@ Description=Service for creating and storing user credentials Type=dbus BusName=xyz.iinuwa.credentialsd.Credentials ExecStart=@DAEMON_EXECUTABLE@ + +# Hardening +# +# credentialsd decides whether a caller is trusted partly by comparing its own +# mount namespace with the caller's. Options that give the service a private +# mount namespace (ProtectSystem=, ProtectHome=, PrivateTmp=, PrivateDevices=, +# ProtectKernelTunables=, ...) would make it reject xdg-desktop-portal, so only +# options enforced through seccomp and no_new_privs are used. They also work in +# the user service manager without user namespaces. +NoNewPrivileges=yes +LockPersonality=yes +MemoryDenyWriteExecute=yes +RestrictRealtime=yes +RestrictSUIDSGID=yes +RestrictNamespaces=yes +SystemCallArchitectures=native +SystemCallFilter=@system-service +# memfd_secret: the hybrid QR code secret are passed over D-Bus in memfd_secret file descriptors. +SystemCallFilter=memfd_secret +SystemCallErrorNumber=EPERM +# AF_UNIX: D-Bus (including BlueZ) and pcscd. AF_NETLINK: udev device +# monitoring. AF_INET/AF_INET6: the hybrid tunnel to the phone's relay server. +RestrictAddressFamilies=AF_UNIX AF_NETLINK AF_INET AF_INET6 +UMask=0077 diff --git a/systemd/xyz.iinuwa.credentialsd.UiControl.service.in b/systemd/xyz.iinuwa.credentialsd.UiControl.service.in index 813d61aa..1f5f07a4 100644 --- a/systemd/xyz.iinuwa.credentialsd.UiControl.service.in +++ b/systemd/xyz.iinuwa.credentialsd.UiControl.service.in @@ -5,3 +5,24 @@ Description=Internal helper service for credentialsd Type=dbus BusName=xyz.iinuwa.credentialsd.UiControl ExecStart=@UI_EXECUTABLE@ + +# Hardening +# +# Like the daemon, no options that need a private mount namespace: the UI calls +# other portals (e.g. Settings for the colour scheme), and xdg-desktop-portal +# identifies its callers through /proc//root. MemoryDenyWriteExecute= is left out because GTK's GL +# renderer may run on a JIT-compiling driver such as llvmpipe. +NoNewPrivileges=yes +LockPersonality=yes +RestrictRealtime=yes +RestrictSUIDSGID=yes +RestrictNamespaces=yes +SystemCallArchitectures=native +SystemCallFilter=@system-service +# memfd_secret: PINs are passed over D-Bus in memfd_secret file descriptors. +SystemCallFilter=memfd_secret +SystemCallErrorNumber=EPERM +# AF_UNIX: D-Bus and the Wayland/X11 display. AF_NETLINK: GLib's network +# monitor. +RestrictAddressFamilies=AF_UNIX AF_NETLINK +UMask=0077