Skip to content

Commit 8d3cc9c

Browse files
Alphixsimo5
authored andcommitted
[gssproxy] Harden systemd .service file
Most of the configuration options should be straightforward. The previous version of the .service file contained a comment that NoNewPrivileges=yes breaks the ability to open a socket under /var/lib/gssproxy. That does not appear to be correct because ProtectClock=yes was already set, which enables NoNewPrivileges. Furthermore, the comment for ProtectKernelTunables also appears to be incorrect, because it doesn't make all of /proc read-only (it's only /proc/sys/, /sys/, /proc/sysrq-trigger, /proc/latency_stats, /proc/acpi, /proc/timer_stats, /proc/fs and /proc/irq, see man systemd.exec(5)), so /proc/net/rpc/use-gss-proxy is still writeable. Perhaps it was a mixup with ProtectProc? With this applied, the "systemd-analyze security gssproxy" score goes from 8.4 (EXPOSED) to 1.7 (OK). Tested with nfs-kernel-server, some more testing in other scenarios might still be necessary. Also, note that this expects all RW data to be stored under /var/lib/gssproxy, /root, /home or /run/user. Signed-off-by: David Härdeman <david@hardeman.nu>
1 parent 92e8787 commit 8d3cc9c

File tree

1 file changed

+46
-17
lines changed

1 file changed

+46
-17
lines changed

systemd/gssproxy.service.in

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,59 @@ After=syslog.target network.target
55
Before=rpc-gssd.service
66

77
[Service]
8-
StateDirectory=gssproxy/clients gssproxy/rcache
8+
ConfigurationDirectory=gssproxy
9+
StateDirectory=gssproxy gssproxy/clients gssproxy/rcache
910
Environment=KRB5RCACHEDIR=/var/lib/gssproxy/rcache
1011
ExecStart=@sbindir@/gssproxy -i
1112
# This can be changed to notify-reload and ExecReload= can be removed once
1213
# systemd 253 is common enough
1314
Type=notify
1415
ExecReload=/bin/kill -HUP $MAINPID
1516

16-
ProtectSystem=full
17-
ProtectClock=true
18-
ProtectKernelLogs=true
19-
ProtectControlGroups=true
20-
RestrictRealtime=true
21-
# NoNewPrivileges: when true breaks the ability to open a socket
22-
# under /var/lib/gssproxy so no NoNewPrivileges
23-
# PrivateTmp: can't be used as it hides ccaches stored in /tmp
24-
# ProtectHome: blocks access to /home which may hold ccaches
25-
# ProtectHostname: blocks propagation of hostname on change
26-
# but in some cases, when using a keytab, we may want to see hostname
27-
# changes as the server will want to respond only for the system name
28-
# ProtectKernelTunables: blocks ability to write to proc.
29-
# on startup gssproxy needs to write in proc to let nfsd know it can
30-
# use the "new" gssproxy method instead of the old rpc stuff.
31-
17+
ProtectSystem=strict
18+
PrivateDevices=yes
19+
PrivateNetwork=yes
20+
PrivateIPC=yes
21+
# Blocks access to /home which may hold ccaches, also breaks euid mappings
22+
PrivateUsers=no
23+
# For now, read-writeable ccaches in /tmp, /root, /home and /run/user are
24+
# allowed, if you know that no such ccaches are used on your system, you might
25+
# want to override these defaults with a drop-in (see man systemd.unit(5))
26+
# like this (stored in e.g. /etc/systemd/system/gssproxy.d/override.conf):
27+
# [Service]
28+
# PrivateTmp=yes
29+
# ProtectHome=tmpfs
30+
# ReadWritePaths=
31+
PrivateTmp=no
32+
ProtectHome=no
33+
ReadWritePaths=/root /home /run/user
34+
# Blocks propagation of hostname on change but when using a keytab, we want to
35+
# see hostname changes as the server will want to respond only for that name
36+
ProtectHostname=no
37+
ProtectClock=yes
38+
# Does *not* block rw access to /proc/net/rpc/use-gss-proxy
39+
ProtectKernelTunables=yes
40+
# Blocks access to /proc/net/rpc/use-gss-proxy and executable name matching
41+
ProtectProc=default
42+
ProtectKernelModules=yes
43+
ProtectKernelLogs=yes
44+
ProtectControlGroups=yes
45+
RestrictAddressFamilies=AF_UNIX AF_LOCAL
46+
RestrictNamespaces=yes
47+
LockPersonality=yes
48+
MemoryDenyWriteExecute=yes
49+
RestrictRealtime=yes
50+
RestrictSUIDSGID=yes
51+
PrivateMounts=yes
52+
# Stricter version:
53+
# SystemCallFilter=@default @basic-io @file-system @io-event @network-io @signal @ipc @process madvise umask uname
54+
SystemCallFilter=@system-service
55+
SystemCallErrorNumber=EPERM
56+
SystemCallArchitectures=native
57+
NoNewPrivileges=yes
58+
CapabilityBoundingSet=CAP_DAC_OVERRIDE
59+
IPAddressDeny=any
60+
UMask=0177
3261

3362
[Install]
3463
WantedBy=multi-user.target

0 commit comments

Comments
 (0)