nixos/jackett: add Systemd sandboxing configuration

Apply security sandboxing via Systemd service configuration:
- All unnecessary privileges are dropped.
- The only writable directories are /tmp and the home of the jackett user.
- Only can execute installed applications from the Nix store.
- Network access is not restricted as the setup can vary across users. So it should be configured in the firewall.
This commit is contained in:
Géza Búza
2023-01-17 14:57:28 +01:00
parent 94897428db
commit b3c825d1ef
+49
View File
@@ -60,6 +60,55 @@ in
Group = cfg.group;
ExecStart = "${cfg.package}/bin/Jackett --NoUpdates --DataFolder '${cfg.dataDir}'";
Restart = "on-failure";
# Sandboxing
CapabilityBoundingSet = [
"CAP_NET_BIND_SERVICE"
];
ExecPaths = [
"${builtins.storeDir}"
];
LockPersonality = true;
NoExecPaths = [
"/"
];
NoNewPrivileges = true;
PrivateDevices = true;
PrivateMounts = true;
PrivateTmp = true;
PrivateUsers = true;
ProtectClock = true;
ProtectControlGroups = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
ProtectSystem = "strict";
ReadWritePaths = [
"${config.users.users.${cfg.user}.home}"
];
RemoveIPC = true;
RestrictAddressFamilies = [
"AF_INET"
"AF_INET6"
];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
SystemCallFilter = [
"@system-service"
"~@clock"
"~@cpu-emulation"
"~@debug"
"~@obsolete"
"~@reboot"
"~@module"
"~@mount"
"~@swap"
];
UMask = "0077";
};
};