From bc422e2f617cdc8eaa954c06cf98dae98f7b5cb6 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Sun, 5 Nov 2023 20:54:09 +0000 Subject: [PATCH] nixos/unbound: tighten sandboxing for unbound --- nixos/modules/services/networking/unbound.nix | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/networking/unbound.nix b/nixos/modules/services/networking/unbound.nix index abd1630a442a..b6579af10a79 100644 --- a/nixos/modules/services/networking/unbound.nix +++ b/nixos/modules/services/networking/unbound.nix @@ -249,6 +249,10 @@ in { "CAP_NET_BIND_SERVICE" "CAP_NET_RAW" # needed if ip-transparent is set to true ]; + CapabilityBoundingSet = [ + "CAP_NET_BIND_SERVICE" + "CAP_NET_RAW" + ]; User = cfg.user; Group = cfg.group; @@ -261,15 +265,19 @@ in { ProtectControlGroups = true; ProtectKernelModules = true; ProtectSystem = "strict"; + ProtectClock = true; + ProtectHostname = true; + ProtectProc = "invisible"; + ProcSubset = "pid"; + ProtectKernelLogs = true; + ProtectKernelTunables = true; RuntimeDirectory = "unbound"; ConfigurationDirectory = "unbound"; StateDirectory = "unbound"; RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_NETLINK" "AF_UNIX" ]; RestrictRealtime = true; SystemCallArchitectures = "native"; - SystemCallFilter = [ - "~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @resources @privileged" - ]; + SystemCallFilter = [ "@system-service" ]; RestrictNamespaces = true; LockPersonality = true; RestrictSUIDSGID = true;