vibe-audit.lab

guides · 2026-11-14

Open Redirects: How Your Real Domain Becomes Someone Else's Phishing Link

Published 2026-11-14 · Reviewed 2026-11-14 · By the Ingenious AI team

The short answer

An open redirect — login?next=https://evil.example — weaponises your domain's reputation: the victim checks the link, sees your real domain, clicks, and lands on a phishing page after your site vouches for the jump. Only ever redirect to relative paths on your own origin, or to a short allow-list of destinations, and validate the value on the server every time.

Check your own app free: paste your code or enter your site URL on the Vibe-Code Audit homepage — the free scan checks for exposed secrets, injection flaws, XSS patterns, missing headers and exposed .env/.git paths, with a copy-paste fix for every finding. No credit card.

Why attackers value your boring redirect

Phishing lives and dies on the hover-check: users are trained to inspect the domain before clicking. A link beginning https://your-real-app.com/login?next=... passes that check — the domain is genuinely yours. One click later your server itself sends the victim to the clone, and some email gateways and reputation systems even score the link by its first hop, which is you. OAuth and SSO flows raise the stakes: a tampered redirect_uri in a login flow can deliver authorization codes or tokens to the attacker's site, turning a 'minor' redirect bug into account takeover. Vibe-Code Audit flags both server redirects built from request data and client-side window.location assignments from parameters — the two shapes generated code produces when implementing 'return the user to where they were'.

The legitimate feature underneath

Post-login return URLs are good UX: a user bounced to login from a deep link should land back on that page. The bug is not the feature; it is accepting absolute URLs. The safe contract: next must be a path beginning with a single '/', resolved against your own origin — reject values starting with '//' (protocol-relative URLs escape to another host), backslash variants that browsers normalise into '//', and anything with a scheme. That one rule covers 95% of real products, because legitimate returns are virtually always inside your own app.

The remaining 5% — federated logout, payment return flows, partner hand-offs — get a named allow-list of exact destinations in server configuration, matched on the full origin (and ideally the full URL), never on substrings or suffixes: evil-example.com and example.com.evil.com must both fail a check for example.com.

Client-side cousins

Single-page apps reinvent the bug in JavaScript: reading ?next from location.search and assigning window.location, or router pushes to unvalidated values. Same rules apply client-side, with server validation as backstop wherever a backend is involved. Also examine link-preview unfurlers, 'continue to external site' interstitials and short-link features if your product has them — each is a redirector by design and inherits the same allow-list discipline.

Testing and monitoring

Probe every redirect parameter you can find — next, return, redirect, url, continue — with https://example.org, //example.org and /\example.org against staging. All must land inside your app or be rejected. In production logs, watch for redirect parameters containing 'http' in referrer-driven traffic spikes: a sudden cluster usually means a phishing kit has adopted your link, and the right response is the fix deployed, plus a note to your users if the campaign is visible.

The allow-list mistakes that reopen the hole

Three validation shortcuts recur in code review. Checking that the target starts with your domain fails against yourdomain.com.evil.com and against URLs where your domain appears as a path on a hostile host. Checking that it does not contain 'http' fails against protocol-relative //evil.com and against backslash forms browsers normalise into the same thing. Parsing the URL but comparing hosts loosely — suffix matching, case tricks, userinfo confusion like https://[email protected] — fails against the URL grammar's darker corners. The relative-path rule avoids the entire grammar fight: a value that must begin with exactly one forward slash and contain no scheme, no backslash and no second leading slash is either inside your app or rejected. Reserve full URL parsing for the short server-side allow-list of external destinations, where each entry is an exact string you configured — not a pattern a request can negotiate with.

Worked example: MeadowMetrics, an analytics SaaS

MeadowMetrics (fictional), with about 900 trial users, discovered its login next parameter in a phishing email a customer forwarded: the link used MeadowMetrics' real domain and redirected to a pixel-perfect login clone that harvested credentials. A scan had flagged the server redirect pattern months earlier as MEDIUM, where it sat in a backlog. The fix took one deploy: relative-path-only validation with '//' and backslash rejection, plus an allow-list containing exactly one partner destination. A sweep of five other redirect parameters found two more instances, both in OAuth-adjacent flows. The company emailed users about the campaign and forced password resets for the 14 accounts that had logged in through the clone.

Five actions to take today

  1. Find every redirect influenced by input: next, return, redirect_uri, url, continue — in server handlers and client-side location assignments.
  2. Enforce relative-path-only redirects for in-app returns: must start with a single '/', never '//', a scheme or a backslash escape.
  3. Put genuinely external destinations in a server-side allow-list matched on exact origins.
  4. Probe staging with absolute, protocol-relative and backslash variants on every parameter; all must stay on your domain or fail.
  5. Watch production logs for redirect parameters containing external URLs — a spike means a phishing kit found you first.

What is Open redirect?

a flaw where an application redirects to a URL taken from user input without validation. The application's trusted domain becomes the visible first hop in phishing links, and the redirect itself can also be abused to bypass allow-lists in other systems.

Sources

Frequently asked questions

Isn't an open redirect 'just' a low-severity issue?

Alone, it is a phishing enabler rated medium by most scanners. In OAuth flows it can leak codes and tokens, escalating to account takeover. Severity depends on which flow carries the parameter — audit the auth-adjacent ones first.

Can I validate with a simple check that the URL contains my domain?

No — substring checks pass example.com.evil.com and evil.com/example.com. Parse the URL and compare the host exactly, or restrict to relative paths.

My payment provider needs an external return URL. How?

That destination belongs in the server-side allow-list as an exact URL configured by you — not as a value the client supplies at request time.

Do SPA routers protect me automatically?

No. Router guards navigate to whatever value they are handed; if it comes from the query string unvalidated, the bug is present in client form. Validate before navigating, same rules.

Related guides

Browse the full library on the guides index, run the checks in the launch audit, or compare plans on pricing.


Informational explainer, not a security guarantee. Scan your code free before every deploy.

← all guides

← Back