module.nix: add some systemd hardening
All checks were successful
Build and test / check (push) Successful in 1m11s
Build and test / build (push) Successful in 1m34s
Build and test / test (push) Successful in 2m28s
Build and test / docs (push) Successful in 3m26s

This commit is contained in:
2026-01-31 13:43:15 +09:00
parent 178c7314a4
commit def4eec2d5

View File

@@ -53,7 +53,60 @@ in {
Restart = "on-failure";
DynamicUser = true;
# TODO: hardening
# NOTE: roowho2 might at some point need to read from home directories
# to get user settings, so let's keep these disabled for now.
# PrivateUsers = true;
# ProtectHome = true;
AmbientCapabilities = "";
CapabilityBoundingSet = "";
DeviceAllow = "";
DevicePolicy = "closed";
LockPersonality = true;
MemoryDenyWriteExecute = true;
NoNewPrivileges = true;
PrivateDevices = true;
# NOTE: all ipc traffic is served through the socket activation fds or provided by systemd
PrivateIPC = true;
PrivateMounts = true;
PrivateTmp = true;
ProcSubset = "pid";
ProtectClock = true;
ProtectControlGroups = "strict";
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
RemoveIPC = true;
RestrictAddressFamilies = [
"AF_INET"
"AF_INET6"
"AF_UNIX"
"AF_NETLINK"
];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SocketBindDeny = "any";
SystemCallArchitectures = "native";
SystemCallFilter = [
"@system-service"
"~@privileged"
"~@resources"
];
RuntimeDirectory = "roowho2/root-mnt";
RuntimeDirectoryMode = "0700";
RootDirectory = "/run/roowho2/root-mnt";
BindReadOnlyPaths = [
builtins.storeDir
"/etc"
# NOTE: need logind socket for utmp entries
"/run/systemd"
];
UMask = "0077";
};
};