Repository navigation
Conversation
/magiclink, /otp, /recover and /resend sent emails and SMS to banned users even though the token can never be redeemed, since /verify and the token grants reject banned users. Skip the send and return the same empty 200 as for an unknown user, so the ban status isn't revealed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
/magiclink,/otp(email and SMS),/recoverand/resendnever check whether the user is banned. They send the email or SMS as usual, even though the token in it can never be used:/verifyand the token grants reject banned users withuser_banned.So a banned user can still request magic links, OTPs and recovery emails, and so can anyone who knows their email or phone number, using the public anon key. Each request costs email quota or SMS spend and affects sender reputation. The person receiving it gets a link that fails.
What is the new behavior?
When the user is banned, these handlers skip the send and return an empty
200. That is the same response/recoverand/resendalready give for an unknown email, so the response doesn't reveal that the account is banned.The check runs right after the user lookup, before any other side effects. No flow state, token or audit log entry is created, and an unconfirmed user's password is not cleared.
Additional context
TestOtpBannedUser(magic link via/otpand/magiclink, SMS OTP via/otp),TestRecover_BannedUserandTestResendBannedUser(signup and email change). Each asserts that no token or*_sent_attimestamp is written while the user is banned, and that sending works again once the ban has expired.200, even where a non-banned user would get429from the per-user max frequency check. Someone who already knows the email could tell the two apart by sending two requests in a row. Happy to apply the frequency check before the ban check if you'd rather avoid that./signupfor an existing unconfirmed user still resends the confirmation email. Banned accounts are normally confirmed, so I left it out to keep this PR small. Happy to add it.