Skip to content

Fix: prevent open redirect via returnTo in auth flow#22

Merged
ralyodio merged 1 commit into
profullstack:masterfrom
FuturMix:fix/auth-callback-open-redirect
Jun 15, 2026
Merged

Fix: prevent open redirect via returnTo in auth flow#22
ralyodio merged 1 commit into
profullstack:masterfrom
FuturMix:fix/auth-callback-open-redirect

Conversation

@FuturMix

Copy link
Copy Markdown
Contributor

Summary

Fixes #21

The returnTo parameter accepts arbitrary URLs, allowing an attacker to redirect users to external sites after OAuth login.

Changes

  • apps/web/app/api/auth/coinpay/route.ts: Validate returnTo at auth initiation
  • apps/web/app/api/auth/callback/route.ts: Validate returnTo at callback (defense-in-depth)

Both checks ensure returnTo starts with / and is not a protocol-relative URL (//).

Test plan

  • Login with returnTo=/dashboard — redirects to /dashboard after auth
  • Login with returnTo=https://evil.com — redirects to / instead
  • Login with returnTo=//evil.com — redirects to / instead
  • Login with no returnTo — redirects to / (default)

🤖 Generated with Claude Code

The returnTo parameter from the query string is stored in a cookie and
used as the redirect target after OAuth callback. An attacker can set
returnTo to an absolute URL (e.g. https://evil.com) to redirect users
to a malicious site after login.

Validate returnTo in both the auth initiation and callback routes to
ensure it starts with / and is not a protocol-relative URL (//).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ralyodio ralyodio merged commit 12b0e31 into profullstack:master Jun 15, 2026
5 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.

Bug: Open redirect via returnTo in OAuth auth flow

2 participants