Glossary

What is open redirect: a flaw that forwards users from your trusted URL to another site

An open redirect lets a URL on your site forward visitors to any external site, so your trusted domain can be used to make phishing links look legitimate. How it works, and the main defense (allowlist redirect targets, never accept external URLs) — explained defensively, no attack steps.

Published 2026-06-10 Updated 2026-10-06 8 min read
On this page

An open redirect is when a URL that starts with your real domain sends visitors to a completely different site. Here's how it works and how to reliably prevent it (no attack steps).

Why it's dangerous

The core harm is borrowed trust in your domain.

How it's abusedWhat happens
Phishing through your domainLink starts with the real domain → users and filters trust it → off to a fake site
Auth-flow hijackTampering the redirect target in OAuth-style flows to grab a token/code
Amplifying other bugsCombined with SSRF or XSS to widen impact

Why it works

It appears in features like "return the user to where they were after login," where the return URL is trusted and forwarded as-is. The "start" of the URL the user sees is the real domain, so it's hard to doubt all the way through.

realdomain/login?next= (the start is trusted)
an external URL is planted in next=
↓ the site forwards without validating the target
the user lands on a fake site thinking they clicked the real one = phishing
The start is the real domain, so it's trusted. Forward an unchecked external URL from the parameter and attackers can use it for phishing.

Defense: don't accept external URLs

1

Allow only relative paths (most important)

Accept return targets like /dashboard — relative paths only — and reject full URLs (starting with http:// or //). Give no room for the user to specify a destination domain.

2

Match against an allowlist

If you need dynamic targets, permit only entries in a fixed set of known destinations (a map). Anything else falls back to a default page.

3

Don't rely on string checks

//evil, backslashes, @, and multi-encoding bypass naive filters. Change what you accept (relative + allowlist) instead of patching filters.

4

If you must go off-site, make it explicit

When external redirects are intended, show an interstitial ("You're leaving for an external site"). Don't forward silently.

This site's view: rated 'low' alone, but serious when combined with phishing

Open redirects are often rated low on their own, but because attackers can borrow the trust in your domain, they become serious when combined with phishing or auth hijacking. That's why a design-level fix (relative paths + allowlist) removes the cause efficiently. It mirrors SSRF (making the server connect anywhere): both share the defense principle of never letting the user decide the destination.

Open redirect vs SSRF vs phishing

An open redirect is less an attack in itself than a flaw that makes other attacks more convincing. Placing it next to related terms shows where it fits.

TermWhat happensWho fixes it
Open redirectA URL on the real site forwards the user's browser to an external siteDevelopers of the site with the redirect feature
SSRFNot the browser but the server sends a request to the destination it was givenDevelopers of the site with the URL-fetching feature
PhishingA fake site gets people to enter IDs, passwords or card detailsUsers, email receivers, and the organization being impersonated

When a phishing link can use a real domain, both users and email filters find it harder to spot. Removing open redirects keeps your domain from being used in scams.

Example: where it matters most, sign-in integrations (OAuth)

Open redirects matter most around sign-in integrations (OAuth). After authorization, the user is sent back to the registered redirect URI carrying an authorization code or token. If the site they return to has an open redirect, the code or token may be sent on to an external site.

That is why the OAuth 2.0 Security Best Current Practice (RFC 9700, January 2025) requires two things.

  • The authorization server compares redirect URIs with pre-registered ones by exact match
  • Neither clients nor authorization servers expose pages that forward to an arbitrary URL taken from a query parameter

Open redirects are classified as CWE-601. On their own they are rarely rated high severity, but next to a sign-in integration they become a serious problem.

How severe it is

On its own, an open redirect is usually rated medium. A commonly seen rating is CVSS 3.1 6.1.

  • The user has to open the link (UI:R)
  • The impact is sending users to another site; it does not let anyone read the site's data directly
  • Because the impact reaches beyond the redirecting site, it is scored as a scope change (S:C)

Don't put it off because of the number. Fix it first if it sits on the return path of a sign-in integration, or if it is already being used in phishing. To score your own case, use the CVSS calculator.

Safe helpers your framework already has

Framework features are less likely to miss a case than your own string checks. Two common examples:

FrameworkHelperWhat it does
Ruby on RailsDefault redirect_to behavior and url_fromBy default it blocks redirects to other hosts; sending users off-site requires an explicit allow_other_host: true. url_from returns the URL only if it is on the same host, otherwise nil
ASP.NET CoreLocalRedirect and Url.IsLocalUrlRedirects only to URLs within the same site, and throws an exception for an external URL

The Rails documentation warns that even with allow_other_host: true, passing a user-supplied parameter straight through is unsafe. When adding an off-site redirect feature, avoid that combination.

How to check your own site

1

Find parameters that take a destination

Search your code and URL list for parameters named like next, url, redirect, return_to, continue or callback, and check whether they are passed straight into a redirect.

2

Check how destinations are validated

See whether validation relies on prefix string matching or "does it start with http." Instead, split the URL into scheme, host and port with a URL parser and compare against an allowlist, or use the framework's safe helpers (such as LocalRedirect in ASP.NET Core).

3

Review your sign-in integration registrations

In your OAuth or SSO settings, check that registered redirect URIs contain no wildcards and no old URLs you no longer need.

4

Consider choosing destinations by ID

If you must redirect externally, accept a short ID rather than the URL itself, and look up the destination in a server-side table. OWASP recommends this approach.

5

Look for off-site redirects in your access logs

Search your access logs for requests where a destination parameter contains a host name other than your own. If you find any, check whether that redirect really sends people off-site, and treat it as a sign that someone may be circulating such links.

Sources (primary)

  • OWASP, "Unvalidated Redirects and Forwards Cheat Sheet" — cheatsheetseries.owasp.org (IDs mapped server-side, allowlist checks on parsed URLs, warning pages)
  • IETF RFC 9700, "Best Current Practice for OAuth 2.0 Security" (January 2025) — datatracker.ietf.org (exact matching of redirect URIs, no open redirectors)
  • Ruby on Rails API, "ActionController::Redirecting" — api.rubyonrails.org (default protection against redirects to other hosts, allow_other_host, url_from)
  • Microsoft, "Prevent open redirect attacks in ASP.NET Core" — learn.microsoft.com (LocalRedirect, IsLocalUrl, logging non-local URLs)
  • MITRE, "CWE-601: URL Redirection to Untrusted Site ('Open Redirect')" — cwe.mitre.org

Classification

CWE classifies the types of weakness behind vulnerabilities; MITRE ATT&CK classifies attacker techniques. Both are maintained by MITRE and widely used to label vulnerability reports and detection rules.

CWE™: Copyright © 2006–2026, The MITRE Corporation. CWE is a trademark of The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. Any copy you make for such purposes is authorized on the condition that you reproduce MITRE’s copyright designation and this license in any such copy. CWE Terms of Use

FAQ

QWhy is an open redirect a problem?
A

The URL's first domain is your real, trusted one (e.g. a login page), so users and mail filters click it confidently. But the site forwards them to any external site, so your real domain can be used to make phishing links look legitimate and to steal tokens in auth flows.

QWhat's the top defense?
A

Don't accept external URLs as redirect targets. For post-login return paths, allow only relative paths (/dashboard) and match against an allowlist (a fixed set of known destinations). If you truly must send users off-site, show an interstitial that tells them they're leaving.

QIs checking for http:// enough?
A

No. Schemeless forms (//evil.example), backslashes, encoding, and @-based confusing URLs all bypass naive checks. Rather than judging the string, design so you never accept an external URL at all (relative paths + allowlist).

QWhat is an open redirect, in simple terms?
A

You open a link to one site, and that site forwards you straight to whatever other site is written in the URL. It happens because the part that decides the destination (such as ?next=) can be freely changed from outside.

QHow should redirect URIs be set up for OAuth and sign-in integrations?
A

Match the redirect URI (where the user returns after authorization) against pre-registered values by exact match. The OAuth 2.0 Security Best Current Practice (RFC 9700, January 2025) requires exact string matching and says clients and authorization servers must not expose pages that forward the browser to arbitrary URLs (open redirectors). Avoid wildcard or prefix registrations.

QAs a user, how can I tell?
A

Look at the address bar after the page opens, not the domain at the start of the link. When asked for a password or card details, check that the domain in the address bar is the real one before typing. If in doubt, open the site from a bookmark or the official app rather than the email link.

QHow severe is an open redirect? What CVSS score does it get?
A

On its own it is usually rated medium, because the user has to open the link and the impact is limited to sending them to another site. A commonly seen rating is CVSS 3.1 6.1 (AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N). If it sits on the return path of a sign-in integration (OAuth), though, it can leak codes or tokens, and the real impact is much larger.

QWhat is the difference between a redirect and a forward?
A

A redirect is when the server tells the browser to go to another URL and the browser opens it itself. A forward is when the server hands the request to another handler internally, and the browser's URL does not change. OWASP covers both: with redirects the problem is sending users to external sites; with forwards it is getting past access control checks to admin functions that should not be reachable.

QA security assessment flagged an open redirect. What should I do first?
A

Don't just block the one parameter that was flagged. List every place that takes a destination in the same way. Then write one shared function that accepts relative paths only and route every redirect through it. Use an allowlist or a confirmation page only where an external redirect is truly needed.