-
Notifications
You must be signed in to change notification settings - Fork 3
Fix/otp attempts verification #1466
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
base: develop
Are you sure you want to change the base?
Conversation
…default client IP to 'unknown' in UsersService
|
bugbot run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Bugbot reviewed your changes and found no bugs!
src/routes/v2/auth.js
Outdated
| }) | ||
| const email = rawEmail.toLowerCase() | ||
| const userInfo = (await this.authService.verifyOtp({ email, otp })).value | ||
| const userIp = isSecure ? req.get("cf-connecting-ip") : req.ip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this line is making an assumption about Cloudflare's existence which we know may not necessarily be true. Noting this down as a nit for us to follow up as a separate fix as part of the Cloudflare post-mortem action items.
FYI will extract this out into a common function and add a comment there for follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted in 9f90a78.
| // Return silently to avoid revealing whether an OTP exists | ||
| // This maintains security by not leaking information about existing OTPs | ||
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: I don't think we are able to directly return here because it is possible that the user is requesting for the OTP to be resent if the email did not reach their inbox. Instead we should be able to resend the email with the same OTP.
Problem
Solution
Breaking Changes
attemptstoattemptsByIpcolumnFeatures:
Improvements:
Bug Fixes:
Before & After Screenshots
BEFORE:
AFTER:
Tests
Deploy Notes
New environment variables:
env var: env var detailsfetch_ssm_parameters.sh)New scripts:
script: script detailsNew dependencies:
dependency: dependency detailsNew dev dependencies:
dependency: dependency detailsNote
Adds per-IP OTP attempt limits backed by a new JSONB column and plumbs client IP through routes/services; also prevents issuing a new OTP while a valid one exists.
otps.attempts_by_ip(JSONB, default{}) via migration and expose asOtp.attemptsByIp.UsersService.verifyOtpusingattemptsByIp; maintain legacyattemptsonly for monitoring.auth.maxNumOtpAttempts; use"unknown"bucket when IP is missing.sendEmailOtpif a non-expired OTP already exists.attemptsandattemptsByIpon OTP issuance (sendEmailOtp,sendSmsOtp).cf-connecting-ipwhen secure, elsereq.ip) inv2/auth.verifyandv2/authenticated/usersOTP verify endpoints.clientIpthroughAuthService.verifyOtp,UsersService.verifyEmailOtp, andverifyMobileOtp.Written by Cursor Bugbot for commit b8c5c1b. This will update automatically on new commits. Configure here.