fix(express)!: serve OTP generate routes over POST#109
Merged
Conversation
Contributor
Author
|
SDK half: fells-code/seamless-auth-react#103. Both must land and publish together (see fells-code/seamless-auth-react#100 for the version-lockstep concern). |
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
Serve the four OTP generate routes over
POSTinstead ofGET, closing the same CSRF vector already fixed for/auth/magic-link.GET /auth/otp/generate-phone-otp->POSTGET /auth/otp/generate-email-otp->POSTGET /auth/otp/generate-login-phone-otp->POSTGET /auth/otp/generate-login-email-otp->POSTWhy
Each of these routes sends an SMS or email, so they are state changing. As a
GETwith no custom headers they were simple cross-site requests: an<img src>on any page could fire them, and because the session cookie defaults toSameSite=Nonein a secure deployment, the adapter treated them as authenticated. That let a hostile page trigger unbounded OTP messages to a signed-in user, which is a messaging-abuse and SMS toll-fraud vector.This mirrors the fix already applied to
GET /auth/magic-linkin the cookie-clearing-and-csrf change. Handler behavior is unchanged, only the browser-facing method. The upstream call to the auth server is stillGET, since that hop is server-to-server and not CSRF exposed.Coordinated release
BREAKING. Pairs with
@seamless-auth/reactPR (link once open), which switches these four client methods to POST. An older SDK issuing GET will get a 404, and an older adapter will 404 the new SDK, so the two must be released together. Same lockstep as the magic-link change.Tests
loginOtpRoutes.test.js: the existing proxy test now issues POST, with the upstream fetch assertion unchangedno longer exposes GET /magic-linktestFull express suite: 115 passed.
Checks
npm test(builds core + express, then jest): 115 passedtsc -p tsconfig.build.jsonclean