Skip to content

Commit ddef00d

Browse files
nixos/zipline: improve systemd hardening (#387119)
2 parents 1289c91 + ef19fcf commit ddef00d

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

nixos/modules/services/web-apps/zipline.nix

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ in
107107
ExecStart = lib.getExe cfg.package;
108108

109109
# Hardening
110+
AmbientCapabilities = "";
110111
CapabilityBoundingSet = [ "" ];
111-
DeviceAllow = [ "" ];
112+
DevicePolicy = "closed";
112113
LockPersonality = true;
114+
NoNewPrivileges = true;
113115
PrivateDevices = true;
114116
PrivateTmp = true;
115117
PrivateUsers = true;
@@ -123,15 +125,18 @@ in
123125
ProtectKernelTunables = true;
124126
ProtectProc = "invisible";
125127
ProtectSystem = "strict";
126-
RestrictAddressFamilies = [
127-
"AF_INET"
128-
"AF_INET6"
129-
"AF_UNIX"
130-
];
128+
RemoveIPC = true;
129+
RestrictAddressFamilies = [ "AF_INET AF_INET6 AF_UNIX AF_NETLINK" ];
131130
RestrictNamespaces = true;
132131
RestrictRealtime = true;
133132
RestrictSUIDSGID = true;
134133
SystemCallArchitectures = "native";
134+
SystemCallFilter = [
135+
"@system-service"
136+
"~@privileged"
137+
"~@resources"
138+
];
139+
UMask = "0077";
135140
};
136141
};
137142
};

nixos/tests/zipline.nix

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{ lib, ... }:
2+
23
{
34
name = "zipline";
45
meta.maintainers = with lib.maintainers; [ defelo ];
@@ -20,6 +21,18 @@
2021
networking.hosts."127.0.0.1" = [ "zipline.local" ];
2122
};
2223

24+
interactive.nodes.machine = {
25+
services.zipline.settings.CORE_HOSTNAME = lib.mkForce "0.0.0.0";
26+
networking.firewall.allowedTCPPorts = [ 8000 ];
27+
virtualisation.forwardPorts = [
28+
{
29+
from = "host";
30+
host.port = 8000;
31+
guest.port = 8000;
32+
}
33+
];
34+
};
35+
2336
testScript = ''
2437
import json
2538
import re

0 commit comments

Comments
 (0)