From 353a8b58e6b12daf2977870743a6dd85ee080448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Baylac-Jacqu=C3=A9?= Date: Sun, 26 Apr 2020 15:18:49 +0200 Subject: [PATCH] nixos/prosody: leverage systemd sandbox features to harden service We are leveraging the systemd sandboxing features to prevent the service accessing locations it shouldn't do. Most notably, we are here preventing the prosody service from accessing /home and providing it with a private /dev and /tmp. Please consult man systemd.exec for further informations. --- nixos/modules/services/networking/prosody.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nixos/modules/services/networking/prosody.nix b/nixos/modules/services/networking/prosody.nix index 8058172cb08..83e397e50fa 100644 --- a/nixos/modules/services/networking/prosody.nix +++ b/nixos/modules/services/networking/prosody.nix @@ -856,6 +856,19 @@ in PIDFile = "/run/prosody/prosody.pid"; ExecStart = "${cfg.package}/bin/prosodyctl start"; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; + + MemoryDenyWriteExecute = true; + PrivateDevices = true; + PrivateMounts = true; + PrivateTmp = true; + ProtectControlGroups = true; + ProtectHome = true; + ProtectHostname = true; + ProtectKernelModules = true; + ProtectKernelTunables = true; + RestrictNamespaces = true; + RestrictRealtime = true; + RestrictSUIDSGID = true; }; };