-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add IP Addresses to Synapse log files #12014
Comments
Synapse includes IP addresses and other data in the |
This is not good enough because:
|
You can additionally configure your fail2ban to block IPs with |
Yes @dklimpel - if 403 is raised on auth failure only then this should work. But it is still something that should go thru synapse log. I want to have separate rule for synapse instead of modifying the webserver rule. |
My thought would be security and request blocking as early as possible. It would probably make more sense to document all relevant log entries.
This is related to: |
We're uncomfortable making it so that we change this particular line or make it log IP addresses for all lines by default. We would accept a patch for passing in the IP address as a optional field so that admins can configure their logging to include the IP address. |
another option might be to make use of a structured log format (see #8683) |
In fact, do we already support this? https://github.com/matrix-org/synapse/blob/develop/synapse/logging/context.py#L605 In which case adding |
How can I do it? I've tried with %(ip_address)s, and it didn't work (caused python error). |
Oh, hmm, probably because not every log line has an IP address associated with it. If you're using py3.10 then I think you can use the new formatters:
precise:
(): logging.Formatter
fmt: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(ip_address)s - %(message)s'
defaults:
ip_address: "n/a" Otherwise you could create a custom formatter class that handles On the Synapse side: not sure if we should give defaults to the extra params? |
Oh wow, @erikjohnston, you solved the problem! 👍 |
I think we can go ahead and close it since we came to a solution. 👍 |
I've just noticed that although it DOES solve the problem, other events cause python errors. So I need to look further on this :( |
@clokep is it possible to re-open this case, as the previous solution is faulty? :/ This "feature" is a must. |
@SPiRiT369 I think it'd be best if you can open a new issue, containing
|
Logging clients IP Addresses is essential for security.
I use fail2ban to automatically block IP Addresses when I detect clients trying to bruteforce my server (e.g. guess mail server passwords).
With Synapse I can't do that because the log file records do not include source IP Address. For example:
2022-02-16 19:33:23,003 - synapse.handlers.auth - 1387 - WARNING - POST-4233 - Failed password login for user <user>
I think that it will be very useful (and also essential) to include IP addresses in the log file, at least in security-related events such as registrations and authentication failures.
Hiding IP Addresses from Synapse logs does not improve privacy, as the address is visible in the webserver's logs and also stored in the database. So I don't see any benefit of hiding it.
I am aware that ratelimiting is an option, but it's a different solution.
The text was updated successfully, but these errors were encountered: