Tighten the systemd sandboxes and cap gitv-web's memory
Browse filesAll four services now hide other processes, can't touch the clock, hostname or kernel logs, can't create namespaces or writable-executable memory, and are limited to the system calls ordinary services use; gitv-web is also denied privileged calls and gets memory and task limits. systemd-analyze security scores fall from 4.4-5.0 to 1.4-2.2. ReadOnlyPaths= went: ProtectSystem=strict already covers it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Author
- Um9i vulgarmessiah@gmail.com
- Date
- 22 Nov 2026, 16:19
- Commit
- 7becb1ab34ce
- Parent
- a50b863
4 files changed +51−1
| @@ -19,5 +19,16 @@ ProtectKernelTunables=yes | ||
| ProtectKernelModules=yes | ||
| ProtectControlGroups=yes | ||
| RestrictSUIDSGID=yes | ||
| ProtectProc=invisible | ||
| ProtectClock=yes | ||
| ProtectKernelLogs=yes | ||
| ProtectHostname=yes | ||
| LockPersonality=yes | ||
| MemoryDenyWriteExecute=yes | ||
| RestrictNamespaces=yes | ||
| RestrictRealtime=yes | ||
| SystemCallArchitectures=native | ||
| SystemCallFilter=@system-service | ||
| SystemCallErrorNumber=EPERM | ||
| # Read every repository and private folder, and keep owners and modes in the copies. | ||
| CapabilityBoundingSet=CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_CHOWN CAP_FOWNER | ||
| @@ -15,4 +15,15 @@ ProtectKernelTunables=yes | ||
| ProtectKernelModules=yes | ||
| ProtectControlGroups=yes | ||
| RestrictSUIDSGID=yes | ||
| ProtectProc=invisible | ||
| ProtectClock=yes | ||
| ProtectKernelLogs=yes | ||
| ProtectHostname=yes | ||
| LockPersonality=yes | ||
| MemoryDenyWriteExecute=yes | ||
| RestrictNamespaces=yes | ||
| RestrictRealtime=yes | ||
| SystemCallArchitectures=native | ||
| SystemCallFilter=@system-service | ||
| SystemCallErrorNumber=EPERM | ||
| CapabilityBoundingSet=CAP_DAC_OVERRIDE | ||
| @@ -19,4 +19,15 @@ ProtectKernelTunables=yes | ||
| ProtectKernelModules=yes | ||
| ProtectControlGroups=yes | ||
| RestrictSUIDSGID=yes | ||
| ProtectProc=invisible | ||
| ProtectClock=yes | ||
| ProtectKernelLogs=yes | ||
| ProtectHostname=yes | ||
| LockPersonality=yes | ||
| MemoryDenyWriteExecute=yes | ||
| RestrictNamespaces=yes | ||
| RestrictRealtime=yes | ||
| SystemCallArchitectures=native | ||
| SystemCallFilter=@system-service | ||
| SystemCallErrorNumber=EPERM | ||
| CapabilityBoundingSet=CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_CHOWN CAP_FOWNER | ||
| @@ -13,7 +13,6 @@ StateDirectoryMode=0700 | ||
| UMask=0077 | ||
| NoNewPrivileges=yes | ||
| ProtectSystem=strict | ||
| ReadOnlyPaths=/srv/gitv/repos | ||
| ProtectHome=yes | ||
| PrivateTmp=yes | ||
| PrivateDevices=yes | ||
| @@ -23,6 +22,24 @@ ProtectControlGroups=yes | ||
| RestrictSUIDSGID=yes | ||
| CapabilityBoundingSet= | ||
| RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 | ||
| ProtectProc=invisible | ||
| ProtectClock=yes | ||
| ProtectKernelLogs=yes | ||
| ProtectHostname=yes | ||
| LockPersonality=yes | ||
| MemoryDenyWriteExecute=yes | ||
| RestrictNamespaces=yes | ||
| RestrictRealtime=yes | ||
| SystemCallArchitectures=native | ||
| SystemCallFilter=@system-service | ||
| SystemCallErrorNumber=EPERM | ||
| # No chown, setuid or the like: the browser and the git it runs only read. | ||
| SystemCallFilter=~@privileged | ||
| # Renders, transfers and the git commands they run share these. Raise MemoryMax on a large | ||
| # droplet serving big clones: git pack-objects does its work inside this limit. | ||
| MemoryHigh=768M | ||
| MemoryMax=1G | ||
| TasksMax=512 | ||
| [Install] | ||
| WantedBy=multi-user.target | ||