Skip to main content
ContentHigh PriorityPro

Open Redirect Detection

Updated November 2026·SecScanner Team

Open redirects allow attackers to craft URLs on your domain that redirect users to malicious external sites.

Results in 1–3 minutes · Free · No signup required

Why It Matters

Attackers abuse open redirects for phishing by crafting convincing URLs on your trusted domain that redirect to fake login pages. This bypasses URL reputation filters and user vigilance.

How We Check

We test common redirect parameters (url, redirect, next, goto, etc.) with an external canary URL to detect if the server follows the redirect without validation.

Good vs Bad Values

Good and bad values for Open Redirect Detection
ValueVerdictWhy
?next=/dashboard (relative path, validated)GoodOnly same-site paths are accepted; anything else falls back to a default page.
Exact-match allow-list of hosts (app.example.com, www.example.com)GoodSafe for the rare case where cross-host redirects are needed.
?next=https://evil.example redirects thereBadThe textbook open redirect. Phishing links look like they belong to your domain.
?next=//evil.exampleBadProtocol-relative URLs pass naive checks for “starts with /” but leave the site.
?next=/\evil.exampleBadBrowsers treat a backslash like a slash, so this also resolves to evil.example.
?next=https://example.com.evil.exampleBadBeats startsWith/contains checks. Compare the parsed hostname exactly.
?next=javascript:… accepted as a redirect targetBadCan turn an open redirect into script execution in some clients.
Warning page asking the user to confirm leaving the siteWeakReduces abuse but still lends your domain's reputation to the link. Prefer an allow-list.

How to Fix

Validate all redirect URLs server-side against an allowlist of permitted domains. Use relative paths for internal redirects. Never use user input directly in redirect targets without validation.

Next.js / Node — resolve the target against your own origin and reject anything that ends up elsewhere:

const SITE = "https://example.com";

export function safeRedirect(target: string | null, fallback = "/"): string {
  if (!target) return fallback;
  try {
    const url = new URL(target, SITE);
    return url.origin === SITE ? url.pathname + url.search : fallback;
  } catch {
    return fallback;
  }
}

Nginx — never write return 302 $arg_next; unchecked. Gate it with a map that accepts only local paths or listed hosts:

map $arg_next $next_ok {
  default 0;
  "~^/[a-zA-Z0-9]" 1;
  "~^https://(app|www)\.example\.com(/|$)" 1;
}
location = /go {
  if ($next_ok = 0) { return 400; }
  return 302 $arg_next;
}

Apache: avoid RewriteRule or Redirect targets built from %{QUERY_STRING}; send visitors to fixed locations or a short list of named destinations. Cloudflare: Redirect Rules use static targets, so they are safe as long as the target is not taken from the request.

Test it by replacing the redirect parameter with an external address and reading the Location header. Try the encoded and protocol-relative variants from the table above as well:

curl -sI 'https://example.com/login?next=https://evil.example' | grep -i '^location'
curl -sI 'https://example.com/login?next=//evil.example' | grep -i '^location'

Common Mistakes

  • Validating with `startsWith("/")` alone, which allows `//evil.example`. Parse the URL and compare origins instead.
  • Checking the URL before decoding it. Double-encoded values such as `%2F%2Fevil.example` can pass the check and be decoded later.
  • Protecting the login redirect but not logout, SSO callback, language-switch and tracking-link endpoints, which often take the same parameter.
  • Treating the issue as harmless because it needs a click. Open redirects are routinely chained into OAuth token theft and phishing that bypasses URL filters.

Frequently Asked Questions

What is Open Redirect Detection?

Open redirects allow attackers to craft URLs on your domain that redirect users to malicious external sites.

Why does Open Redirect Detection matter for website security?

Attackers abuse open redirects for phishing by crafting convincing URLs on your trusted domain that redirect to fake login pages. This bypasses URL reputation filters and user vigilance.

How do I fix Open Redirect Detection issues?

Validate all redirect URLs server-side against an allowlist of permitted domains. Use relative paths for internal redirects. Never use user input directly in redirect targets without validation.

Related Security Checks

Check Your Website Now

Run a free security scan to check for Open Redirect Detection issues and 61 other security checks.

Scan Your Website Free