fix(console): validate continue param in /auth/authorize to prevent open redirect (CWE-601)#26507
Open
sebastiondev wants to merge 1 commit intoanomalyco:devfrom
Open
fix(console): validate continue param in /auth/authorize to prevent open redirect (CWE-601)#26507sebastiondev wants to merge 1 commit intoanomalyco:devfrom
sebastiondev wants to merge 1 commit intoanomalyco:devfrom
Conversation
Closed
6 tasks
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.
Issue for this PR
Closes #26506
(Tracking issue intentionally describes the change at a high level only — exploit details are kept out of the public issue per responsible-disclosure practice. Happy to redirect through a GitHub Security Advisory if maintainers prefer.)
Type of change
What does this PR do?
Re-submission of #26373, which was auto-closed by the
pr-standardsbot for not having a linked issue. Issue #26506 now provides that link without disclosing exploit details publicly.The console's
/auth/authorizeroute concatenates the user-suppliedcontinuequery parameter directly into the OAuth callback URL without validation. After the OAuth round-trip, the callback handler derives a redirect target from the callback path, which means a craftedcontinuevalue can redirect the user to an attacker-controlled origin once authentication completes.Affected file:
packages/console/app/src/routes/auth/authorize.tsData flow:
/auth/authorize?continue=readscontinuefrom the query string.callbackUrl = new URL("./callback" + cont, request.url)and passes it toAuthClient.authorize(...)as the OAuthredirect_uri.[...callback]computesnext = url.pathname.replace("/auth/callback","")and callsredirect(route(locale, next)).route()returnsnextverbatim for paths it doesn't specifically rewrite, so anextof//evil.com/xis passed through.Location: //evil.com/xresponse ashttps://evil.com/x— the user is redirected off-site.The fix adds a
safeContinue()validator at the entry point that only accepts values which:/(relative path, not protocol-relative),//,\, or/\(protocol-relative / backslash variants that some browsers normalize),.., backslashes, or CR/LF/TAB characters.Anything else is replaced with an empty string, which produces the safe default callback URL
/auth/callback. The change is 18 lines, scoped to the single vulnerable file, and preserves the legitimate behavior ofcontinuefor in-app post-login navigation.How did you verify your code works?
Walked the validator against each attack class and the legitimate inputs by hand:
""""/workspace/abc/workspace/abc//evil.com/x""/\evil.com""\\evil.com""/foo/../../bar""https://evil.com""/)""The rest of the auth flow is untouched, so existing OAuth behavior for valid relative
continuevalues is preserved.Screenshots / recordings
N/A — no UI change.
Checklist