Open redirect: when your own link sends visitors somewhere else

An open redirect is a page or endpoint that takes a destination from the request and sends the visitor there without checking it. The link starts on your real domain, so it looks safe to the person clicking and to many filters, and it ends on a site the attacker chose. The open redirect vulnerability is rarely dangerous alone. It matters because other attacks borrow your name.

Section Web attacks Updated Weakness CWE-601

Quick facts

Weakness
CWE-601: URL redirection to untrusted site (“open redirect”)
OWASP Top 10
A10 in 2010 and 2013 as “Unvalidated Redirects and Forwards”; CWE-601 is mapped to A01 Broken Access Control in 2021 and 2025 (A01:2025 page)
Typical input
A query parameter or form field that holds a destination, such as url or returnUrl in the OWASP examples
Typical severity
Rated Low on its own by PortSwigger; the harm comes from what it is combined with
Does a WAF stop it?
Partly. A request carrying an off-site address in a redirect parameter can be recorded; whether that address is legitimate is a decision for your application

Definitions follow CWE-601, which describes the weakness as an application that accepts a user-controlled link to an external site and uses it in a redirect. This page sits beside SSRF and CSRF, which are easy to mix up with it and are different attacks.

How an open redirect works

A redirect is an ordinary HTTP response: a 3xx status and a Location header naming where the browser should go next. RFC 9110, section 10.2.2 defines the header and section 15.4 the status codes. Sites use redirects constantly, most often to bring a visitor back to the page they wanted after signing in. Redirects with a fixed target are safe, as the OWASP cheat sheet notes, because nobody can change where they point. OAuth makes the flaw worse when redirect URIs are matched loosely; see OAuth security.

  1. The destination travels in the request. A login page remembers where the visitor was going by carrying the address in a parameter.
  2. The application trusts it. It copies the value into the Location header, or into a script that sets the browser's location, with no check on where it points.
  3. The attacker builds the link. It uses your domain and your path, with their address in the parameter.
  4. The visitor clicks and lands elsewhere. The address bar showed your domain a moment earlier, and often a valid certificate too.

The same flaw exists on the client. A script that reads a destination from the URL and assigns it to the page location behaves identically. RFC 9700 gives this case its own heading, “Client as Open Redirector”, in its section on open redirection.

One server-side detail from the cheat sheet: in its PHP example, code after the header() call keeps running unless you stop it, so a visitor who ignores the redirect can still reach the rest of the page. Send the redirect, then end the request.

Redirects and forwards

A redirect tells the browser to make a new request. A forward is internal: the server hands the request to another resource without the browser knowing. The cheat sheet treats both in one document because both take a destination from untrusted input.

The forward case is the quieter one. If a parameter selects the internal target, a crafted value can reach a function that the visitor was never meant to see, and the cheat sheet says the application must check that the user is authorised for the target, that the function is permitted, and that the request is appropriate. This is why OWASP files the weakness near broken access control in recent editions: an unchecked destination is a missing authorisation decision.

Why attackers want one

Phishing is the main reason. The OWASP cheat sheet points out that the server name in the modified link is identical to the original site, so a link that begins with your domain passes the glance test that people, and some mail filters, apply. PortSwigger's description makes the same point: many users will not notice the second hop, which lends credibility to the phishing page. The attacker never has to compromise your site. They borrow its reputation for one click.

A second use is getting past checks that look only at the first host. Any control that approves a link because its domain is trusted will approve everything that domain forwards to. The SSRF page describes the server-side version, where an allowed host that redirects inward defeats a host list.

The third is chaining, covered in the next section. On its own the flaw is often a Low finding, and PortSwigger rates it that way. Treat that as a ranking of the single bug and not as a licence to leave it: the same parameter becomes more serious when a sign-in flow sits behind it.

It is also worth separating this from clickjacking. There the victim stays on your real page, wrapped in someone else's frame. Here the victim leaves your page, and your domain served only as the signpost.

Open redirects and OAuth

OAuth sign-in sends the browser away to an authorisation server and back to a redirect URI that the client registered. If that registered address, or anything under it, is an open redirector, the return trip can be steered. RFC 9700, the OAuth 2.0 security best current practice, says that clients and authorisation servers must not expose URLs that forward the browser to arbitrary addresses taken from a query parameter, and that open redirectors can enable exfiltration of authorisation codes and access tokens.

Section 4.1.2 of the same document describes how the pieces combine: a registered redirect pattern, plus an open redirector on the client, lets the token travel on to the attacker's address. It notes that this defeats even narrow redirect-URI patterns, though not strict URL matching. The countermeasure in section 4.1.3 is exact string comparison of redirect URIs, together with a ban on open redirectors on the hosts that serve them.

That is the reason a “harmless” return-to parameter on a login page deserves more care than the same parameter on a marketing page.

How to prevent open redirects

The cheat sheet's advice, in the order it gives it, with the CWE-601 mitigations alongside:

  1. Avoid user-controlled redirects. If a fixed target works, hard-code it.
  2. Do not accept a full URL. Map a short name or ID to a destination on the server, and reject anything not in the map. CWE-601 calls this enforcement by conversion. Watch for enumeration of the IDs.
  3. For return-to-page behaviour, allow local paths only. The cheat sheet recommends framework helpers that refuse non-local destinations. A check that a value merely starts with a slash is not enough on its own, so use the helper or a parser.
  4. For genuine external destinations, use an allow-list of parsed components. Compare scheme, canonical host and port with a maintained URL parser that matches browser behaviour, reject embedded credentials, and avoid raw prefix or suffix matching, which the cheat sheet says can be bypassed.
  5. Show a confirmation page. An interstitial that names the destination and asks the visitor to continue. CWE-601 adds that it should not introduce cross-site scripting itself.
  6. Compare OAuth redirect URIs exactly. RFC 9700 requires exact string matching, with one stated exception for port numbers on localhost addresses used by native apps.
  7. Authorise forwards. Check the user may reach the target before forwarding.

PortSwigger offers a plain order of preference as well: remove the feature, then use a server-side allow-list and pass an index, then accept only relative paths, and only as a last resort require that an absolute URL begins with your exact domain.

Where a WAF helps and where it does not

A WAF sees requests. For this weakness that is useful in one narrow way and blind in several others.

What it can see: a parameter that exists to carry a destination, holding an absolute address that points off your site. Parameters named redirect, url or next are the usual candidates, though names are chosen by each application. A filter can record such requests, and the log shows which of your pages are being used as stepping stones and from where. CWE-601 itself lists an application firewall among its mitigations, rating the effectiveness as moderate and describing it as a stopgap for code you cannot yet change.

What it cannot see: whether the address is legitimate. Your own checkout may send people to a payment provider on purpose; a filter does not know your list of partners. Nor does it see what your code does with the value afterwards. A destination kept in the part of a URL after the # is never sent to the server at all, because, as RFC 3986, section 3.5 puts it, the fragment is dereferenced solely by the user agent. A client-side redirect driven by that fragment is invisible to any request filter. The same holds when the destination arrives in a cookie, or when it was stored earlier and used later.

Blocking has its own cost. Legitimate sign-in flows pass return addresses constantly, so refusing every off-site value would break real customers. That is why the sensible order is to start in monitor mode, read the activity log, and sort real flows from abuse before refusing anything. The false positives page covers that sorting, and staged rollout covers the order of steps.

Which requests a given rule category flags depends on what is enabled, so confirm in the log rather than assume. Whatever the log shows, the fix for the vulnerability itself is in the application: the allow-list, the local-path helper, the exact match.

Finding open redirects in your own code

Start from the list of places that redirect. Sign-in and sign-out return addresses, language switchers, link trackers, single sign-on callbacks, and any /go or /out style endpoint are the usual ones. Search the code for assignments to the Location header and to the browser's location, and note which of them read from the request.

For each, supply an address on a server you control and see whether the response sends you there. Then check how the value is validated. If the check is a string comparison on a prefix or suffix, a parser would reject what it lets through, as the cheat sheet warns. Repeat for every hop in a chain, since a safe first redirect that feeds an unsafe second one is still open.

Questions

What is an open redirect?

An open redirect is a weakness in which an application sends the visitor to a destination taken from the request without checking it. The link begins on the real site and ends wherever the attacker chose. It is catalogued as CWE-601.

Is an open redirect vulnerability serious?

On its own it is usually rated low, because the attacker needs a victim to click and does not gain access to your systems. It becomes more serious when it is used for phishing under your domain or chained with an OAuth sign-in flow, where RFC 9700 says open redirectors can enable exfiltration of authorisation codes and access tokens.

How do you prevent open redirects?

Avoid user-controlled destinations where you can. Otherwise map short IDs to destinations on the server, accept only local paths for return-to-page behaviour, compare parsed scheme, host and port against an allow-list for external targets, and show a confirmation page that names the destination.

Can a WAF block open redirects?

Partly. A WAF can record requests that carry an off-site address in a redirect-style parameter, and monitor mode shows them without refusing anything. It cannot know which destinations your application legitimately uses, and it does not see redirects driven by the URL fragment. The fix belongs in the application.

Is an open redirect the same as SSRF?

No. An open redirect sends the visitor's browser to another site. SSRF makes your own server fetch an address the attacker chose. The two can meet when a server follows a redirect from an allowed host to an internal address.