matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.8k stars 2.13k forks source link

Document Synapse Server Hardening Best Practices #5141

Open brainscar opened 5 years ago

brainscar commented 5 years ago

Hi,

I was wondering what the best practices are for hardening a Synapse server?

For example, I noticed Synapse listens on http://127.0.0.1:8008

Does it make sense to get a local certificate to change it to https://127.0.0.1:8008 ?

I hope we can share ideas.

Thank you.

brainscar commented 5 years ago

I can write a wiki article if everyone helps with ideas.

yang202 commented 5 years ago

想知道怎么查看已经安装的synapse的版本 还有就是怎么版本控制

Willt125 commented 5 years ago

I second this request; it will make version management a bit easier, since we won't have to guess how out-of-date our rooms are.

On Thu, May 23, 2019 at 9:15 PM yang202 notifications@github.com wrote:

想知道怎么查看已经安装的synapse的版本 还有就是怎么版本控制

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/matrix-org/synapse/issues/5141?email_source=notifications&email_token=ACBYGLK7336VZOWHPA7LT2LPW46S3A5CNFSM4HK4GBO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWD4QYA#issuecomment-495437920, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBYGLK7HYQX7YOQKUPD3STPW46S3ANCNFSM4HK4GBOQ .

KnightWhoSaysNeeeowWumPing commented 2 years ago

It's been a while but since I still can't find any good source on hardening a synapse server to this day, I want to share my personal thoughts on securing a matrix/synapse instance - Maybe it's of use to anyone...

DISCLAIMER: This is no guideline or professional advice of any kind! Just some random internet-guy's ideas

General hardening

Hardening the nginx configuration

I'm running synapse on nginx basis, so these are some measures I successfully applied to my nginx configuration:

Resources

There are a lot more nginx specific security settings covered in these resources, e.g.

But since I'm not that much into synapse, I don't know which HTTP methods synapse uses and how to set good resource values to still support sharing images and videos on the matrix homeserver.

Maybe there's someone out there who is willing to experiment and maybe even wants to help writing a community guide for hardening synapse.

H-Shay commented 2 years ago

Thanks for adding this! I wonder if you would be willing to open a PR against our docs with this information?

richvdh commented 2 years ago

The intended action here was for someone on the Synapse team to write something here, possibly based on the contributions in #11758.

I think we could easily create a "Security best practices" list on https://matrix-org.github.io/synapse/latest, containing a list of bullet points like:

It doesn't need to be perfect - just a placeholder that we can extend over time would be a great start.

(I don't think we should include general server-hardening best practices like locking down SSH access and using a firewall - we're not here to teach people server administration)