From 0e6ec4bc378b126e0b2ca888ec01680393cc72b3 Mon Sep 17 00:00:00 2001 From: Dan Lock Date: Tue, 17 Feb 2026 16:20:11 +0000 Subject: [PATCH] nixos/sonarr: harden systemd services --- .../modules/services/misc/servarr/sonarr.nix | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/nixos/modules/services/misc/servarr/sonarr.nix b/nixos/modules/services/misc/servarr/sonarr.nix index 94c7c21a4281..283eac6b3d3b 100644 --- a/nixos/modules/services/misc/servarr/sonarr.nix +++ b/nixos/modules/services/misc/servarr/sonarr.nix @@ -86,6 +86,40 @@ in "-data=${cfg.dataDir}" ]; Restart = "on-failure"; + + # Hardening + CapabilityBoundingSet = ""; + NoNewPrivileges = true; + ProtectHome = true; + ProtectClock = true; + ProtectKernelLogs = true; + PrivateTmp = true; + PrivateDevices = true; + PrivateUsers = true; + ProtectKernelTunables = true; + ProtectKernelModules = true; + ProtectControlGroups = true; + RestrictSUIDSGID = true; + RemoveIPC = true; + UMask = "0022"; + ProtectHostname = true; + ProtectProc = "invisible"; + RestrictAddressFamilies = [ + "AF_INET" + "AF_INET6" + "AF_UNIX" + ]; + RestrictNamespaces = true; + RestrictRealtime = true; + LockPersonality = true; + SystemCallArchitectures = "native"; + SystemCallFilter = [ + "@system-service" + "~@privileged" + "~@debug" + "~@mount" + "@chown" + ]; } // lib.optionalAttrs (cfg.dataDir == "/var/lib/sonarr/.config/NzbDrone") { StateDirectory = "sonarr";