Conversation
|
commit: |
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.
Problem
Per RFC 6749 §4.1.2.1, when an authorization request includes a
stateparameter and the server redirects back with an error, the redirect MUST echo thestateso the client can correlate the response (CSRF protection).In
authorize.ts, Phase 2 assignsstateonly afterRequestAuthorizationParamsSchema.safeParsesucceeds:So any parameter failing schema validation (e.g. missing
code_challenge, unsupportedcode_challenge_method) produces an error redirect that silently drops the client'sstate. Reported in #2773.Fix
Recover
statefrom the raw request params (only when it is a string) before throwing on parse failure, so error redirects carry it as required. Successful-path behavior is unchanged.Tests
Two regression tests (GET and POST): valid
client_id/redirect_uri+state+ a param that failsRequestAuthorizationParamsSchema→ expect302Location containing botherror=invalid_requestandstate. Both fail onv1.xbefore the fix.test/server/auth/handlers/authorize.test.ts: 29/29 passnpm test, e2e excluded): 1649/1649 pass — the 2 unhandled stdio-serialization errors are pre-existing on a pristinev1.xcheckout (verified via stash, unrelated to this change)npm run typecheck, eslint and prettier all cleanCloses #2773