Repository navigation
fix(auth): close post-login open redirect (TT-017) - #699
Merged
Merged
Conversation
Centralize post-login redirect validation in auth-href so protocol-relative, backslash, control-character, and absolute external next values fall back to /dashboard/overview. Preserve query strings via postLoginRedirectParts in middleware so legitimate next paths no longer 404. Co-authored-by: Sanja Malovic <[email protected]>
Co-authored-by: Sanja Malovic <[email protected]>
unjica
marked this pull request as ready for review
September 26, 2026 08:44
This was referenced Sep 26, 2026
Merged
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.
Summary
Fixes TT-017 (P2): unsafe
nextvalues on/login(and legacysignIn=1flows) could navigate or 307-redirect to external / protocol-relative hosts. Also fixes legitimatenextvalues with query strings being stuffed intopathnameand 404ing.Changes
normalizePostLoginRedirectPathinapps/dashboard/lib/auth-href.ts: percent-decode, reject//,\, controls (tab/CR/LF), absolute URLs; resolve against a fixed origin; fall back viaresolvePostLoginPathto/dashboard/overview.postLoginRedirectPartssplits path + search so middleware redirects preserve e.g./dashboard/errors?range=7d.crossAuthHrefuse the same helper (LoginPageFormalready usedresolvePostLoginPath).[Unreleased]Security note.How to test
pnpm lintpnpm test(includeslib/auth-href.test.ts)pnpm buildnext→/dashboard/overviewGET /login?next=<unsafe>→ Location/dashboard/overviewnext=/dashboard/errors?range=7dpreserved exactlysignIn=1&next=sanitizes unsafe valuesCode review (Bugbot)
/review-bugbotin Cursor (optional while the gate is paused)Checklist
pnpm test)pnpm lint)pnpm build)[Unreleased]Security / privacy
Closes open redirect on post-login
next(TT-017). No deploy until green. TT-012 / unrelated QA findings not included.