portfolio-page/backend/deploy/audit-webhook.service

51 lines
1.8 KiB
Desktop File

[Unit]
Description=Deploy webhook for the audit endpoint (git push -> auto pull + restart)
Documentation=https://git.sascha-bach.de/saschabach/portfolio-page
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=auditapi
Group=auditapi
WorkingDirectory=/opt/audit-endpoint/backend/webhook
ExecStart=/usr/bin/node server.js
Restart=always
RestartSec=5
# --- Hardening -------------------------------------------------------------
# Unlike audit-endpoint.service, this one genuinely needs to write to the
# checkout (git reset --hard, npm install), hence ReadWritePaths below -
# everything else stays as locked down as the main service.
#
# NoNewPrivileges is deliberately NOT set here, unlike audit-endpoint.service:
# it flips the kernel's PR_SET_NO_NEW_PRIVS flag, which makes setuid bits
# (including /usr/bin/sudo's) inert for this process and everything it execs.
# deploy.sh's whole reason for running as this user is to call
# `sudo systemctl restart audit-endpoint` - a privilege escalation that is
# exactly what that flag exists to prevent. The two are fundamentally
# incompatible, not a configuration mistake to work around.
# The actual containment for that escalation is the narrow sudoers rule
# (audit-deploy-sudoers): exactly two "systemctl restart <unit>" commands,
# nothing else, regardless of this flag.
PrivateTmp=true
PrivateDevices=true
ProtectSystem=strict
ReadWritePaths=/opt/audit-endpoint
ProtectHome=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
ProtectHostname=true
ProtectClock=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
RestrictNamespaces=true
RestrictRealtime=true
RestrictSUIDSGID=true
LockPersonality=true
SystemCallArchitectures=native
MemoryDenyWriteExecute=false
[Install]
WantedBy=multi-user.target