about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2024-12-29 21:41:42 +0100
committerMel <einebeere@gmail.com>2024-12-29 21:41:42 +0100
commit533d0cd2043f08b02bb0248b5aebc7bc60d6b15a (patch)
treea232e3bf2252e9a46e570a25f08646767e2ef611
parent171074bb59beae6cfa45de66ea1bd26ee35a7ed7 (diff)
downloadspecimen-533d0cd2043f08b02bb0248b5aebc7bc60d6b15a.tar.zst
specimen-533d0cd2043f08b02bb0248b5aebc7bc60d6b15a.zip
Add overkill hardening to specimen systemd service step-2
Signed-off-by: Mel <einebeere@gmail.com>
-rw-r--r--application/module.nix30
1 files changed, 30 insertions, 0 deletions
diff --git a/application/module.nix b/application/module.nix
index 7ec368d..78ac546 100644
--- a/application/module.nix
+++ b/application/module.nix
@@ -66,6 +66,36 @@ in
         Type = "exec";
         Restart = "always";
         ExecStart = "${cfg.package}/bin/specimen -address ${cfg.listenAddress} -port ${toString cfg.port} -name ${cfg.namePath}";
+
+        # a gigantic amount of hardening!!
+        # realistically this much wouldn't be necessary.
+        # mostly here to show off ;3
+        # for documentation, see: https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html
+        LockPersonality = true;
+        CapabilityBoundingSet = [ "" ];
+        DeviceAllow = [ "" ];
+        MemoryDenyWriteExecute = true;
+        NoNewPrivileges = true;
+        PrivateDevices = true;
+        PrivateTmp = true;
+        ProtectClock = true;
+        ProtectProc = "invisible";
+        ProtectControlGroups = true;
+        ProtectHome = true;
+        ProtectHostname = true;
+        ProtectKernelLogs = true;
+        ProtectKernelModules = true;
+        ProtectKernelTunables = true;
+        ProtectSystem = "strict";
+        RemoveIPC = true;
+        RestrictAddressFamilies = [
+          "AF_INET"
+          "AF_INET6"
+        ];
+        RestrictNamespaces = true;
+        RestrictRealtime = true;
+        RestrictSUIDSGID = true;
+        SystemCallArchitectures = "native";
       };
     };
   };