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

Only do rc_login ratelimiting on succesful login. #6335

Merged
merged 5 commits into from
Nov 20, 2019

Conversation

erikjohnston
Copy link
Member

@erikjohnston erikjohnston commented Nov 5, 2019

We were doing this in a number of places which meant that some login code paths incremented the counter multiple times.

It was also applying ratelimiting to UIA endpoints, which was probably not intentional.

In particular, some custom auth modules were calling check_user_exists, which incremented the counters, meaning that people would fail to login sometimes.

A side effect of this is that we don't ratelimit the SSO path (as that was obscurely relying on check_user_exists being ratelimited??) until after we've successfully authed with the SSO provider, and rely on the remote SSO provider to do its own ratelimiting. We do still ratelimit when the client then logs in with the provider token via /login.

This also applies a separate rate limit to failed UIA auth attempts, to protect someone attempting to extract a password from a logged in session.

Note: no failed rate limiting is applied by token style logins as they're not associated with any user ID.

@erikjohnston erikjohnston force-pushed the erikj/rc_login_cleanups branch 2 times, most recently from 3e49197 to 17f6269 Compare November 6, 2019 11:04
We were doing this in a number of places which meant that some login
code paths incremented the counter multiple times.

It was also applying ratelimiting to UIA endpoints, which was probably
not intentional.

In particular, some custom auth modules were calling
`check_user_exists`, which incremented the counters, meaning that people
would fail to login sometimes.
@erikjohnston erikjohnston force-pushed the erikj/rc_login_cleanups branch from 17f6269 to 4fc53bf Compare November 6, 2019 11:09
@erikjohnston erikjohnston marked this pull request as ready for review November 6, 2019 11:14
@erikjohnston erikjohnston requested a review from a team November 6, 2019 11:14
Copy link
Contributor

@babolivier babolivier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm otherwise

synapse/rest/client/v1/login.py Outdated Show resolved Hide resolved
Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny nits

synapse/handlers/auth.py Outdated Show resolved Hide resolved
synapse/handlers/auth.py Outdated Show resolved Hide resolved
Co-Authored-By: Andrew Morgan <[email protected]>
Co-Authored-By: Brendan Abolivier <[email protected]>
@babolivier babolivier merged commit 83446a1 into develop Nov 20, 2019
@babolivier babolivier deleted the erikj/rc_login_cleanups branch January 9, 2020 15:45
@babolivier babolivier restored the erikj/rc_login_cleanups branch January 9, 2020 15:45
@erikjohnston erikjohnston deleted the erikj/rc_login_cleanups branch January 9, 2020 15:47
babolivier pushed a commit that referenced this pull request Sep 1, 2021
* commit '83446a18f':
  Lint
  Apply suggestions from code review
  Newsfile
  Add failed auth ratelimiting to UIA
  Only do `rc_login` ratelimiting on succesful login.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants