nixos/zipline: improve systemd hardening (#387119)

Sandro ddef00d3 1289c914

Changed files
+24 -6
nixos
modules
services
web-apps
tests
+11 -6
nixos/modules/services/web-apps/zipline.nix
···
ExecStart = lib.getExe cfg.package;
# Hardening
CapabilityBoundingSet = [ "" ];
-
DeviceAllow = [ "" ];
LockPersonality = true;
PrivateDevices = true;
PrivateTmp = true;
PrivateUsers = true;
···
ProtectKernelTunables = true;
ProtectProc = "invisible";
ProtectSystem = "strict";
-
RestrictAddressFamilies = [
-
"AF_INET"
-
"AF_INET6"
-
"AF_UNIX"
-
];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
};
};
};
···
ExecStart = lib.getExe cfg.package;
# Hardening
+
AmbientCapabilities = "";
CapabilityBoundingSet = [ "" ];
+
DevicePolicy = "closed";
LockPersonality = true;
+
NoNewPrivileges = true;
PrivateDevices = true;
PrivateTmp = true;
PrivateUsers = true;
···
ProtectKernelTunables = true;
ProtectProc = "invisible";
ProtectSystem = "strict";
+
RemoveIPC = true;
+
RestrictAddressFamilies = [ "AF_INET AF_INET6 AF_UNIX AF_NETLINK" ];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
+
SystemCallFilter = [
+
"@system-service"
+
"~@privileged"
+
"~@resources"
+
];
+
UMask = "0077";
};
};
};
+13
nixos/tests/zipline.nix
···
{ lib, ... }:
{
name = "zipline";
meta.maintainers = with lib.maintainers; [ defelo ];
···
};
networking.hosts."127.0.0.1" = [ "zipline.local" ];
};
testScript = ''
···
{ lib, ... }:
+
{
name = "zipline";
meta.maintainers = with lib.maintainers; [ defelo ];
···
};
networking.hosts."127.0.0.1" = [ "zipline.local" ];
+
};
+
+
interactive.nodes.machine = {
+
services.zipline.settings.CORE_HOSTNAME = lib.mkForce "0.0.0.0";
+
networking.firewall.allowedTCPPorts = [ 8000 ];
+
virtualisation.forwardPorts = [
+
{
+
from = "host";
+
host.port = 8000;
+
guest.port = 8000;
+
}
+
];
};
testScript = ''