Progmasoft Git

progmaweb

The site and account service of Progmasoft: a Next.js frontend and an ASP.NET Core API.

Clonegit clone https://git.progmasoft.com/progmaweb

Harden the systemd units of the API and the web frontend

systemd-analyze security rated both services 7.2 MEDIUM. They now
carry the restrictions the Tala website API already runs with: no
capabilities (empty bounding and ambient sets), private /dev, no
access to the clock, hostname, kernel logs, modules, tunables or
control groups, only AF_UNIX/AF_INET/AF_INET6 sockets, no new
namespaces, no realtime scheduling, IPC removed on stop, and a 0077
umask. MemoryDenyWriteExecute stays off, since CoreCLR and V8 JIT
need writable executable mappings.

Deployed and verified on the server: systemd-analyze verify is clean,
both services restarted and rate 3.0 OK, the API health endpoint and
the frontend answer 200 on loopback, and progmasoft.com,
account.progmasoft.com and viget.progmasoft.com answer 200.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Commit
11d91cba681e48afe0fcec6640d07b9100301f86
Author
Leitwolf11 ·
Parents
46e526f91e80

Files · Download .tar.gz

Changes

 ops/systemd/progmaweb-api.service | 11 +++++++++++
 ops/systemd/progmaweb-web.service | 11 +++++++++++
 2 files changed, 22 insertions(+)

diff --git a/ops/systemd/progmaweb-api.service b/ops/systemd/progmaweb-api.service
index daab684..e2ff8e7 100644
--- a/ops/systemd/progmaweb-api.service
+++ b/ops/systemd/progmaweb-api.service
@@ -24,13 +24,24 @@ TimeoutStopSec=30s
 
 # The API has no writable application files. Its state is in PostgreSQL, reached through the local Unix socket; the
 # connection string is in the environment file above.
+UMask=0077
+AmbientCapabilities=
+CapabilityBoundingSet=
 NoNewPrivileges=true
+PrivateDevices=true
 PrivateTmp=true
+ProtectClock=true
 ProtectHome=true
+ProtectHostname=true
 ProtectSystem=strict
+ProtectKernelLogs=true
 ProtectKernelTunables=true
 ProtectKernelModules=true
 ProtectControlGroups=true
+RemoveIPC=true
+RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
+RestrictNamespaces=true
+RestrictRealtime=true
 RestrictSUIDSGID=true
 LockPersonality=true
 # MemoryDenyWriteExecute is intentionally omitted: CoreCLR's JIT requires managed executable mappings at runtime.
diff --git a/ops/systemd/progmaweb-web.service b/ops/systemd/progmaweb-web.service
index acf4690..47698bd 100644
--- a/ops/systemd/progmaweb-web.service
+++ b/ops/systemd/progmaweb-web.service
@@ -26,13 +26,24 @@ TimeoutStopSec=30s
 SuccessExitStatus=143
 
 # Standalone Next.js only reads immutable release files and opens its loopback listener.
+UMask=0077
+AmbientCapabilities=
+CapabilityBoundingSet=
 NoNewPrivileges=true
+PrivateDevices=true
 PrivateTmp=true
+ProtectClock=true
 ProtectHome=true
+ProtectHostname=true
 ProtectSystem=strict
+ProtectKernelLogs=true
 ProtectKernelTunables=true
 ProtectKernelModules=true
 ProtectControlGroups=true
+RemoveIPC=true
+RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
+RestrictNamespaces=true
+RestrictRealtime=true
 RestrictSUIDSGID=true
 LockPersonality=true
 SystemCallArchitectures=native