Skip to content

Commit

Permalink
nixos: Add service hardening
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Stephens <adam@valkor.net>
  • Loading branch information
zhaofengli and adamcstephens committed Oct 14, 2024
1 parent 4e0b470 commit ead2fc5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions nixos/atticd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,18 @@ in
Restart = "on-failure";
RestartSec = 10;

CapabilityBoundingSet = [ "" ];
DeviceAllow = "";
DevicePolicy = "closed";
LockPersonality = true;
MemoryDenyWriteExecute = true;
NoNewPrivileges = true;
PrivateDevices = true;
PrivateTmp = true;
PrivateUsers = true;
ProcSubset = "pid";
ProtectClock = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectHostname = true;
ProtectKernelLogs = true;
Expand All @@ -228,6 +240,7 @@ in
isDefaultStateDirectory = path == "/var/lib/atticd" || lib.hasPrefix "/var/lib/atticd/" path;
in
lib.optionals (cfg.settings.storage.type or "" == "local" && !isDefaultStateDirectory) [ path ];
RemoveIPC = true;
RestrictAddressFamilies = [
"AF_INET"
"AF_INET6"
Expand All @@ -236,6 +249,13 @@ in
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
SystemCallFilter = [
"@system-service"
"~@resources"
"~@privileged"
];
UMask = "0077";
};
};

Expand Down

0 comments on commit ead2fc5

Please sign in to comment.