Skip to content

fix(auth): close post-login open redirect (TT-017) - #699

Merged
cursor[bot] merged 2 commits into
developfrom
cursor/fix-open-redirect-tt017-f4fb
Sep 26, 2026
Merged

cursor[bot] merged 2 commits into
developfrom
cursor/fix-open-redirect-tt017-f4fb

Conversation

@unjica

@unjica unjica commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes TT-017 (P2): unsafe next values on /login (and legacy signIn=1 flows) could navigate or 307-redirect to external / protocol-relative hosts. Also fixes legitimate next values with query strings being stuffed into pathname and 404ing.

Changes

  • Canonical normalizePostLoginRedirectPath in apps/dashboard/lib/auth-href.ts: percent-decode, reject //, \, controls (tab/CR/LF), absolute URLs; resolve against a fixed origin; fall back via resolvePostLoginPath to /dashboard/overview.
  • postLoginRedirectParts splits path + search so middleware redirects preserve e.g. /dashboard/errors?range=7d.
  • Middleware + crossAuthHref use the same helper (LoginPageForm already used resolvePostLoginPath).
  • Regression tests for the QA vectors and the valid query-string case.
  • CHANGELOG [Unreleased] Security note.

How to test

  • pnpm lint
  • pnpm test (includes lib/auth-href.test.ts)
  • pnpm build
  • Signed-out login with unsafe next → /dashboard/overview
  • Signed-in GET /login?next=<unsafe> → Location /dashboard/overview
  • next=/dashboard/errors?range=7d preserved exactly
  • Legacy signIn=1&next= sanitizes unsafe values

Code review (Bugbot)

Paused: GitHub bugbot-review is currently a no-op. /review-bugbot is optional.

  • For notification, alert, billing, ingest, or auth changes: considered running /review-bugbot in Cursor (optional while the gate is paused)
  • If Bugbot comments appear anyway: addressed or replied

Checklist

  • Tests pass (pnpm test)
  • Lint passes (pnpm lint)
  • Build succeeds (pnpm build)
  • CHANGELOG.md updated under [Unreleased]
  • No breaking changes

Security / privacy

Closes open redirect on post-login next (TT-017). No deploy until green. TT-012 / unrelated QA findings not included.

Open in Web Open in Cursor 

cursoragent and others added 2 commits September 26, 2026 08:36
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]>
@unjica
unjica marked this pull request as ready for review September 26, 2026 08:44
@cursor
cursor Bot merged commit 25e65ea into develop Sep 26, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants