From b6fbd87328f8eabd82d65cc8f75dfb74341b0ace Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 28 Jul 2023 17:06:18 +0200 Subject: [PATCH] nixos/atuin: harden systemd unit --- nixos/modules/services/misc/atuin.nix | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/nixos/modules/services/misc/atuin.nix b/nixos/modules/services/misc/atuin.nix index 8b6821ab8927..57ff02df7d68 100644 --- a/nixos/modules/services/misc/atuin.nix +++ b/nixos/modules/services/misc/atuin.nix @@ -91,6 +91,42 @@ in RuntimeDirectory = "atuin"; RuntimeDirectoryMode = "0700"; DynamicUser = true; + + # Hardening + CapabilityBoundingSet = ""; + LockPersonality = true; + NoNewPrivileges = true; + MemoryDenyWriteExecute = true; + PrivateDevices = true; + PrivateMounts = true; + PrivateTmp = true; + PrivateUsers = true; + ProcSubset = "pid"; + ProtectClock = true; + ProtectControlGroups = true; + ProtectHome = true; + ProtectHostname = true; + ProtectKernelLogs = true; + ProtectKernelModules = true; + ProtectKernelTunables = true; + ProtectProc = "invisible"; + ProtectSystem = "full"; + RemoveIPC = true; + RestrictAddressFamilies = [ + "AF_INET" + "AF_INET6" + # Required for connecting to database sockets, + "AF_UNIX" + ]; + RestrictNamespaces = true; + RestrictRealtime = true; + RestrictSUIDSGID = true; + SystemCallArchitectures = "native"; + SystemCallFilter = [ + "@system-service" + "~@privileged" + ]; + UMask = "0077"; }; environment = {