Skip to content

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

Merged
mitchellhenke merged 1 commit intomainfrom
mitchellhenke/new-phone-who-throttled-dis
Apr 19, 2022
Merged

Rate limit phone confirmation attempts (LG-5492)#6216
mitchellhenke merged 1 commit intomainfrom
mitchellhenke/new-phone-who-throttled-dis

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.

2 participants