Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rate limit phone confirmation attempts (LG-5492) #6216

Merged
merged 1 commit into from
Apr 19, 2022

Conversation

mitchellhenke
Copy link
Contributor

@mitchellhenke mitchellhenke commented Apr 18, 2022

This PR adds a per-account rate limit for sending new phone number confirmation OTPs to augment the existing per-phone-number rate limits.

@mitchellhenke mitchellhenke force-pushed the mitchellhenke/new-phone-who-throttled-dis branch 4 times, most recently from 0ec002b to 931a048 Compare April 18, 2022 16:43
changelog: Feature, Account Management, Rate limit phone confirmation attempts
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/new-phone-who-throttled-dis branch from 931a048 to 449b758 Compare April 18, 2022 16:56
@mitchellhenke mitchellhenke marked this pull request as ready for review April 18, 2022 18:23
Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +202 to +206
@phone_confirmation_throttle ||= Throttle.for(
user: current_user,
throttle_type: :phone_confirmation,
)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to check my understanding:

  • this limits attempts by the same logged-in user for any phone
  • our rack-attack should limit attempts by IP address to submit this form

So we shouldn't need to worry about different users spamming different phones because the other rule covers it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, exactly. The OtpRateLimiter will still ensure a specific phone number is not receiving excessive OTPs, and rack-attack places IP rate limits around the routes where OTPs are sent.

@mitchellhenke mitchellhenke changed the title Rate limit phone confirmation attempts Rate limit phone confirmation attempts (LG-5492) Apr 18, 2022
@mitchellhenke mitchellhenke merged commit a682e95 into main Apr 19, 2022
@mitchellhenke mitchellhenke deleted the mitchellhenke/new-phone-who-throttled-dis branch April 19, 2022 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants