Skip to content

Commit 983e696

Browse files
authored
[feature/security] Add systemd sandboxing options to harden security (#440)
1 parent 8cc70a1 commit 983e696

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

example/gotosocial.service

+33
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,39 @@ Restart=on-failure
1717
ExecStart=/gotosocial/gotosocial --config-path config.yaml server start
1818
WorkingDirectory=/gotosocial
1919

20+
StandardOutput=append:/var/log/gotosocial/gotosocial.log
21+
StandardError=inherit
22+
23+
24+
# Sandboxing options to harden security
25+
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
26+
NoNewPrivileges=yes
27+
PrivateTmp=yes
28+
PrivateDevices=yes
29+
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
30+
RestrictNamespaces=yes
31+
RestrictRealtime=yes
32+
DevicePolicy=closed
33+
ProtectSystem=full
34+
ProtectControlGroups=yes
35+
ProtectKernelModules=yes
36+
ProtectKernelTunables=yes
37+
LockPersonality=yes
38+
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
39+
40+
# Denying access to capabilities that should not be relevant
41+
# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
42+
CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
43+
CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
44+
CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
45+
CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
46+
CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
47+
CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
48+
CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
49+
CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
50+
CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
51+
52+
2053
[Install]
2154
WantedBy=default.target
2255

0 commit comments

Comments
 (0)