From b07cd5fbf6acf350cbb83abe82ef52c36090c020 Mon Sep 17 00:00:00 2001 From: Alf Helge Jakobsen Date: Sat, 9 Nov 2024 22:22:09 +0100 Subject: [PATCH] systemd hardening for pvv-nettsiden-gallery-update.service (!90) #133 Reviewed-on: https://git.pvv.ntnu.no/Drift/pvv-nixos-config/pulls/90 Reviewed-by: Oystein Kristoffer Tveit Co-authored-by: Alf Helge Jakobsen Co-committed-by: Alf Helge Jakobsen --- .../services/website/fetch-gallery.nix | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/hosts/bekkalokk/services/website/fetch-gallery.nix b/hosts/bekkalokk/services/website/fetch-gallery.nix index fba76a9..a96d70e 100644 --- a/hosts/bekkalokk/services/website/fetch-gallery.nix +++ b/hosts/bekkalokk/services/website/fetch-gallery.nix @@ -62,6 +62,33 @@ in { WorkingDirectory = galleryDir; User = config.services.pvv-nettsiden.user; Group = config.services.pvv-nettsiden.group; + + AmbientCapabilities = [ "" ]; + CapabilityBoundingSet = [ "" ]; + DeviceAllow = [ "" ]; + LockPersonality = true; + MemoryDenyWriteExecute = true; + NoNewPrivileges = true; # disable for third party rotate scripts + PrivateDevices = true; + PrivateNetwork = true; # disable for mail delivery + PrivateTmp = true; + ProtectClock = true; + ProtectControlGroups = true; + ProtectHome = true; # disable for userdir logs + ProtectHostname = true; + ProtectKernelLogs = true; + ProtectKernelModules = true; + ProtectKernelTunables = true; + ProtectProc = "invisible"; + ProtectSystem = "full"; + RestrictNamespaces = true; + RestrictRealtime = true; + RestrictSUIDSGID = true; # disable for creating setgid directories + SocketBindDeny = [ "any" ]; + SystemCallArchitectures = "native"; + SystemCallFilter = [ + "@system-service" + ]; }; }; }