This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Savyasachee Jha savya.jha@hawkradius.com
- Loading branch information
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add hardened systemd files as proposed in [#9760](https://github.com/matrix-org/synapse/issues/9760) and added them to `contrib/`. Change the docs to reflect the presence of these files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
[Service] | ||
# The following directives give the synapse service R/W access to: | ||
# - /run/matrix-synapse | ||
# - /var/lib/matrix-synapse | ||
# - /var/log/matrix-synapse | ||
|
||
RuntimeDirectory=matrix-synapse | ||
StateDirectory=matrix-synapse | ||
LogsDirectory=matrix-synapse | ||
|
||
###################### | ||
## Security Sandbox ## | ||
###################### | ||
|
||
# Make sure that the service has its own unshared tmpfs at /tmp and that it | ||
# cannot see or change any real devices | ||
PrivateTmp=true | ||
PrivateDevices=true | ||
|
||
# We give no capabilities to a service by default | ||
CapabilityBoundingSet= | ||
AmbientCapabilities= | ||
|
||
# Protect the following from modification: | ||
# - The entire filesystem | ||
# - sysctl settings and loaded kernel modules | ||
# - No modifications allowed to Control Groups | ||
# - Hostname | ||
# - System Clock | ||
ProtectSystem=strict | ||
ProtectKernelTunables=true | ||
ProtectKernelModules=true | ||
ProtectControlGroups=true | ||
ProtectClock=true | ||
ProtectHostname=true | ||
|
||
# Prevent access to the following: | ||
# - /home directory | ||
# - Kernel logs | ||
ProtectHome=tmpfs | ||
ProtectKernelLogs=true | ||
|
||
# Make sure that the process can only see PIDs and process details of itself, | ||
# and the second option disables seeing details of things like system load and | ||
# I/O etc | ||
ProtectProc=invisible | ||
ProcSubset=pid | ||
|
||
# While not needed, we set these options explicitly | ||
# - This process has been given access to the host network | ||
# - It can also communicate with any IP Address | ||
PrivateNetwork=false | ||
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX | ||
IPAddressAllow=any | ||
|
||
# Restrict system calls to a sane bunch | ||
SystemCallArchitectures=native | ||
SystemCallFilter=@system-service | ||
SystemCallFilter=~@privileged @resources @obsolete | ||
|
||
# Misc restrictions | ||
# - Since the process is a python process it needs to be able to write and | ||
# execute memory regions, so we set MemoryDenyWriteExecute to false | ||
RestrictSUIDSGID=true | ||
RemoveIPC=true | ||
NoNewPrivileges=true | ||
RestrictRealtime=true | ||
RestrictNamespaces=true | ||
LockPersonality=true | ||
PrivateUsers=true | ||
MemoryDenyWriteExecute=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters