Skip to content

Commit cc1334d

Browse files
baocinclaude
andcommitted
Add comprehensive systemd security hardening
- PrivateDevices: Private /dev with minimal devices - ProtectKernelTunables/Modules/Logs: Prevent kernel tampering - ProtectControlGroups/Clock: Protect system resources - ProtectProc/ProcSubset: Hide other processes - RestrictRealtime: No realtime scheduling - RestrictSUIDSGID: Prevent SUID/SGID files - LockPersonality: Prevent execution domain changes - RestrictAddressFamilies: Only allow TCP/IP + Unix sockets - SystemCallArchitectures: Native architecture only These restrictions significantly reduce attack surface while maintaining full application functionality. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ce0ff6e commit cc1334d

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

deploy/install.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,19 @@ ProtectHome=true
139139
ReadWritePaths=/var/lib/gitvet
140140
ReadOnlyPaths=/etc/letsencrypt
141141
PrivateTmp=true
142+
PrivateDevices=true
143+
ProtectKernelTunables=true
144+
ProtectKernelModules=true
145+
ProtectKernelLogs=true
146+
ProtectControlGroups=true
147+
ProtectClock=true
148+
ProtectProc=invisible
149+
ProcSubset=pid
150+
RestrictRealtime=true
151+
RestrictSUIDSGID=true
152+
LockPersonality=true
153+
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
154+
SystemCallArchitectures=native
142155
143156
[Install]
144157
WantedBy=multi-user.target

deploy/update.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,27 @@ Environment="SEMGREP_SEND_METRICS=off"
205205
ExecStart=/opt/gitvet/gitvet-server -listen :80 -tls-listen :443 -tls-cert /etc/letsencrypt/live/git.vet/fullchain.pem -tls-key /etc/letsencrypt/live/git.vet/privkey.pem -ssh-listen :22 -enable-ssh=true -db /var/lib/gitvet/data/gitvet.db -cache-dir /var/lib/gitvet/cache -opengrep SCANNER_PATH_PLACEHOLDER
206206
Restart=always
207207
RestartSec=5
208+
209+
# Security hardening
208210
NoNewPrivileges=true
209211
ProtectSystem=strict
210212
ProtectHome=true
211213
ReadWritePaths=/var/lib/gitvet
212214
ReadOnlyPaths=/etc/letsencrypt
213215
PrivateTmp=true
216+
PrivateDevices=true
217+
ProtectKernelTunables=true
218+
ProtectKernelModules=true
219+
ProtectKernelLogs=true
220+
ProtectControlGroups=true
221+
ProtectClock=true
222+
ProtectProc=invisible
223+
ProcSubset=pid
224+
RestrictRealtime=true
225+
RestrictSUIDSGID=true
226+
LockPersonality=true
227+
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
228+
SystemCallArchitectures=native
214229
215230
[Install]
216231
WantedBy=multi-user.target

0 commit comments

Comments
 (0)