Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 4ed08ff

Browse files
authored
Tighten the default rate limit of creating new devices. (#15135)
1 parent 6def779 commit 4ed08ff

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

changelog.d/15135.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Tighten the login ratelimit defaults.

docs/usage/configuration/config_documentation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,11 +1518,11 @@ rc_registration_token_validity:
15181518

15191519
This option specifies several limits for login:
15201520
* `address` ratelimits login requests based on the client's IP
1521-
address. Defaults to `per_second: 0.17`, `burst_count: 3`.
1521+
address. Defaults to `per_second: 0.003`, `burst_count: 5`.
15221522

15231523
* `account` ratelimits login requests based on the account the
1524-
client is attempting to log into. Defaults to `per_second: 0.17`,
1525-
`burst_count: 3`.
1524+
client is attempting to log into. Defaults to `per_second: 0.03`,
1525+
`burst_count: 5`.
15261526

15271527
* `failed_attempts` ratelimits login requests based on the account the
15281528
client is attempting to log into, based on the amount of failed login

synapse/config/ratelimiting.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,18 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
8787
defaults={"per_second": 0.1, "burst_count": 5},
8888
)
8989

90+
# It is reasonable to login with a bunch of devices at once (i.e. when
91+
# setting up an account), but it is *not* valid to continually be
92+
# logging into new devices.
9093
rc_login_config = config.get("rc_login", {})
91-
self.rc_login_address = RatelimitSettings(rc_login_config.get("address", {}))
92-
self.rc_login_account = RatelimitSettings(rc_login_config.get("account", {}))
94+
self.rc_login_address = RatelimitSettings(
95+
rc_login_config.get("address", {}),
96+
defaults={"per_second": 0.003, "burst_count": 5},
97+
)
98+
self.rc_login_account = RatelimitSettings(
99+
rc_login_config.get("account", {}),
100+
defaults={"per_second": 0.003, "burst_count": 5},
101+
)
93102
self.rc_login_failed_attempts = RatelimitSettings(
94103
rc_login_config.get("failed_attempts", {})
95104
)

0 commit comments

Comments
 (0)