Compare commits

...

20 Commits

Author SHA1 Message Date
Andrew Morgan
44848d6b77 Fix changelog number 2021-05-18 17:42:09 +01:00
Andrew Morgan
c891774a0e Apply suggestions from code review 2021-05-18 17:39:39 +01:00
Savyasachee Jha
a36d1ec5ae Removed duplicate file for hardening systemd workers and updated the docs as requested in code review 2021-05-18 16:14:49 +05:30
Savyasachee Jha
ad8e2cc36c Update changelog.d/9802.doc with a link to the actual issue
Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
2021-05-18 16:10:56 +05:30
Savyasachee Jha
585ae3884c Apply suggestions from code review by anoadragon453
Mostly a few grammatical changes to better fit the language expected

Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
2021-05-18 16:10:05 +05:30
Savyasachee Jha
12d130738f Made changes as requested in PR discussion and added a mention of hardening in the docs 2021-04-18 15:59:36 +05:30
Savyasachee Jha
e2cd6b54f7 Revert "Added some hardening measures to systemd unit files for managing the matrix-synapse service"
This reverts commit 0d754ef4cf.
2021-04-18 15:56:16 +05:30
Savyasachee Jha
8832e048bc Revert "Added changelog"
This reverts commit 5be9e61c1e.
2021-04-18 15:56:15 +05:30
Savyasachee Jha
83d2f62263 Revert "Changed the changelog extension to correct one"
This reverts commit 1de1225767.
2021-04-18 15:56:14 +05:30
Savyasachee Jha
2978ae1b16 Revert "Added change to debian changelog"
This reverts commit f70c7aa89a.
2021-04-18 15:56:12 +05:30
Savyasachee Jha
df647d64c3 Revert "Added full stop to the end of changelog line"
This reverts commit bfc08191a6.
2021-04-18 15:56:11 +05:30
Savyasachee Jha
6783198b5f Revert "Renamed changelog file to correct pull request number"
This reverts commit 2a3b35885f.
2021-04-18 15:56:06 +05:30
Savyasachee Jha
006576fc1c Revert "Update debian/matrix-synapse.service to match ordering in documentation"
This reverts all the commits made to harden service files till now.
2021-04-18 15:55:21 +05:30
Savyasachee Jha
84fad5ecf9 Update debian/matrix-synapse.service to match ordering in documentation
Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
2021-04-14 19:14:32 +05:30
Savyasachee Jha
2a3b35885f Renamed changelog file to correct pull request number 2021-04-13 21:29:16 +05:30
Savyasachee Jha
bfc08191a6 Added full stop to the end of changelog line 2021-04-13 21:25:22 +05:30
Savyasachee Jha
f70c7aa89a Added change to debian changelog 2021-04-13 21:21:57 +05:30
Savyasachee Jha
1de1225767 Changed the changelog extension to correct one 2021-04-13 21:11:51 +05:30
Savyasachee Jha
5be9e61c1e Added changelog 2021-04-13 19:47:05 +05:30
Savyasachee Jha
0d754ef4cf Added some hardening measures to systemd unit files for managing the matrix-synapse service 2021-04-13 19:39:43 +05:30
3 changed files with 102 additions and 0 deletions

1
changelog.d/9803.doc Normal file
View File

@@ -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.

View File

@@ -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

View File

@@ -65,3 +65,33 @@ systemctl restart matrix-synapse-worker@federation_reader.service
systemctl enable matrix-synapse-worker@federation_writer.service
systemctl restart matrix-synapse.target
```
## Hardening
**Optional:** If further hardening is desired, the file
`override-hardened.conf` may be copied from
`contrib/systemd/override-hardened.conf` in this repository to the location
`/etc/systemd/system/matrix-synapse.service.d/override-hardened.conf` (the
directory may have to be created). It enables certain sandboxing features in
systemd to further secure the synapse service. You may read the comments to
understand what the override file is doing. The same file will need to be copied
to
`/etc/systemd/system/matrix-synapse-worker@.service.d/override-hardened-worker.conf`
(this directory may also have to be created) in order to apply the same
hardening options to any worker processes.
Once these files have been copied to their appropriate locations, simply reload
systemd's manager config files and restart all Synapse services to apply the hardening options. They will automatically
be applied at every restart as long as the override files are present at the
specified locations.
```sh
systemctl daemon-reload
# Restart services
systemctl restart matrix-synapse.target
```
In order to see their effect, you may run `systemd-analyze security
matrix-synapse.service` before and after applying the hardening options to see
the changes being applied at a glance.