···
# apparently needs proc for workers management
144
-
] ++ (if ! cfg.settings.blockDailyCheck then [
145
-
# allow DNS & TLS if telemetry is explicitly enabled
146
-
"-/etc/resolv.conf"
149
-
"/etc/ssl/certs/ca-certificates.crt"
"CRYPTPAD_CONFIG=${cryptpadConfigFile}"
ExecStart = lib.getExe cfg.package;
StateDirectory = "cryptpad";
WorkingDirectory = "%S/cryptpad";
154
+
# security way too many numerous options, from the systemd-analyze security output
155
+
# at end of test: block everything except
156
+
# - SystemCallFiters=@resources is required for node
157
+
# - MemoryDenyWriteExecute for node JIT
158
+
# - RestrictAddressFamilies=~AF_(INET|INET6) / PrivateNetwork to bind to sockets
159
+
# - IPAddressDeny likewise allow localhost if binding to localhost or any otherwise
160
+
# - PrivateUsers somehow service doesn't start with that
161
+
# - DeviceAllow (char-rtc r added by ProtectClock)
162
+
AmbientCapabilities = "";
163
+
CapabilityBoundingSet = "";
165
+
LockPersonality = true;
166
+
NoNewPrivileges = true;
167
+
PrivateDevices = true;
169
+
ProcSubset = "pid";
170
+
ProtectClock = true;
171
+
ProtectControlGroups = true;
172
+
ProtectHome = true;
173
+
ProtectHostname = true;
174
+
ProtectKernelLogs = true;
175
+
ProtectKernelModules = true;
176
+
ProtectKernelTunables = true;
177
+
ProtectProc = "invisible";
178
+
ProtectSystem = "strict";
180
+
RestrictAddressFamilies = [
184
+
RestrictNamespaces = true;
185
+
RestrictRealtime = true;
186
+
RestrictSUIDSGID = true;
187
+
RuntimeDirectoryMode = "700";
188
+
SocketBindAllow = [
189
+
"tcp:${builtins.toString cfg.settings.httpPort}"
190
+
"tcp:${builtins.toString cfg.settings.websocketPort}"
192
+
SocketBindDeny = [ "any" ];
193
+
StateDirectoryMode = "0700";
194
+
SystemCallArchitectures = "native";
195
+
SystemCallFilter = [
···
215
+
# block external network access if not phoning home and
216
+
# binding to localhost (default)
219
+
cfg.settings.blockDailyCheck
220
+
&& (builtins.elem cfg.settings.httpAddress [
226
+
systemd.services.cryptpad = {
228
+
IPAddressAllow = [ "localhost" ];
229
+
IPAddressDeny = [ "any" ];
234
+
# .. conversely allow DNS & TLS if telemetry is explicitly enabled
235
+
(mkIf (!cfg.settings.blockDailyCheck) {
236
+
systemd.services.cryptpad = {
238
+
BindReadOnlyPaths = [
239
+
"-/etc/resolv.conf"
242
+
"/etc/ssl/certs/ca-certificates.crt"
(mkIf cfg.configureNginx {