Skip to content

Commit 9110e04

Browse files
committed
Improve security hardening of example systemd service unit
The current systemd-analyze security exposure score is now a mere 1.3 (tested on an up-to-date install of Ubuntu Server 20.04)
1 parent b32e2d0 commit 9110e04

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

ippls.service

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,42 @@ Description=gunicorn instance for ippls
88
After=network.target
99

1010
[Service]
11-
User=nobody
11+
#User=nobody
1212
WorkingDirectory=/opt/ippls/src
1313
Environment="PATH=/opt/ippls/ipplsvenv/bin"
1414
ExecStart=/opt/ippls/ipplsvenv/bin/gunicorn --workers 3 --bind 127.0.0.1:5000 wsgi:app
1515
ExecReload=/bin/kill -s HUP $MAINPID
1616
ExecStop=/bin/kill -s TERM $MAINPID
17+
18+
# Extra security hardening options
19+
20+
# Empty because ippls does not require any special capability. See capabilities(7) for more information.
21+
CapabilityBoundingSet=
22+
DynamicUser=true
23+
IPAddressAllow=127.0.0.0/8
24+
IPAddressDeny=any # the allow-list is evaluated before the deny list. Since the default is to allow, we need to deny everything.
25+
LockPersonality=true
26+
MemoryDenyWriteExecute=true
27+
NoNewPrivileges=true
28+
PrivateDevices=true
1729
PrivateTmp=true
30+
PrivateUsers=true
31+
ProtectClock=true
32+
ProtectControlGroups=true
33+
ProtectHome=true
34+
ProtectHostname=true
35+
ProtectKernelLogs=true
36+
ProtectKernelModules=true
37+
ProtectKernelTunables=true
38+
ProtectSystem=strict
39+
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
40+
RestrictNamespaces=true
41+
RestrictRealtime=true
42+
RestrictSUIDSGID=true
43+
SystemCallArchitectures=native
44+
SystemCallErrorNumber=EPERM
45+
SystemCallFilter=@system-service
46+
UMask=077
1847

1948
[Install]
2049
WantedBy=multi-user.target

0 commit comments

Comments
 (0)