Open Redirect
A page that forwards visitors to whatever address a URL parameter names, letting attackers borrow a trusted domain to launch phishing or steal sign-in tokens, and the narrow ways to fix it.
An open redirect is a page that sends visitors on to any address supplied in the request, without checking where. A site might have a link like /login?next=/settings so that after signing in, the user lands back where they started. If the code honors any value of next, an attacker can write a link to the real site that ends somewhere else entirely.
On its own an open redirect harms nothing on the server, which is why it is often dismissed. Its danger is that it lends the trusted site's reputation to whoever controls the destination:
- Phishing. A link that begins with a bank's real domain passes the habit of checking the address, survives email filters that judge links by domain, and then bounces the victim to a fake login page.
- Stealing sign-in tokens. Sign-in protocols return codes or tokens to a registered address. If a provider checks only that the return address is on the right domain, and that domain contains an open redirect, the token can be forwarded on to the attacker; see OAuth and Single Sign-On. Several real account-takeover bugs have been chained this way.
- Script injection. If the redirect target can be a javascript: address rather than a web address, following it runs the attacker's code in the site's context; see Cross-Site Scripting.
- Reaching internal services. A server that fetches URLs and follows redirects can be bounced from an allowed address to a forbidden one; see Server-Side Request Forgery.
The redirect is usually an HTTP 302 or 303 response naming the destination; see HTTP Status Code.
Fixes, from most to least robust:
- Don't take a destination at all. Store the return location on the server, or accept only an ID that maps to a fixed list of pages.
- Allow only relative paths on the same site, checked carefully.
- Use an allow-list of exact permitted hosts.
- Show an interstitial ("you are leaving this site") for unavoidable outbound links.
Checking is harder than it looks. Validators that test whether a value "starts with a slash" are fooled by //evil.example, which browsers treat as a different host, or by a backslash that browsers silently convert to a slash. Others check that the destination "contains" the right domain and accept example.com.evil.example. The safest checks parse the value with the same URL parser the browser will use and compare the resulting host exactly.
"Unvalidated redirects and forwards" appeared on the influential OWASP Top Ten list of web risks in 2010 and 2013. Bug bounty programs still argue over severity: many rate an open redirect alone as low, but pay well when it is chained into one of the attacks above.
See also4
Canonical URL
The one preferred address for a page that's reachable at many, declared so search engines and other tools treat the copies as a single page, a hint introduced by the major search engines together in 2009.
Data & Content10 connections
Internationalized Domain Name
Domain names written in non-Latin scripts and accented letters, made to work in an ASCII-only DNS by encoding them as xn-- strings, and the browser rules that decide when to show the real characters and when to show the code to block lookalike attacks.
Web Platform10 connections
Referrer Policy
The rules for when a browser tells a site which page a visitor came from, a header misspelled in the 1990s that leaked private addresses for decades until browsers began trimming it by default.
Web Platform12 connections
Deep Linking
Linking straight to a specific page or item rather than a site's front door, once fought over in court and now a feature that apps and web apps must work to support.
Web Platform10 connections
Linked from13
- Content Security PolicyWeb Platform
An HTTP header that tells the browser which sources of script, style, and other content a page is allowed to load.
- Cross-Site Request ForgeryWeb Platform
Tricking a logged-in user's browser into sending a state-changing request to another site, which works because the browser attaches that site's cookies automatically.
- Cross-Site ScriptingWeb Platform
Injecting attacker-controlled script into a page that a victim's browser then executes with the victim's own privileges.
- Deep LinkingWeb Platform
Linking straight to a specific page or item rather than a site's front door, once fought over in court and now a feature that apps and web apps must work to support.
- HTTP Status CodeWeb Platform
The three-digit number at the start of every HTTP response that tells the client, caches, crawlers and monitoring what happened, grouped into five classes by the first digit.
- Internationalized Domain NameWeb Platform
Domain names written in non-Latin scripts and accented letters, made to work in an ASCII-only DNS by encoding them as xn-- strings, and the browser rules that decide when to show the real characters and when to show the code to block lookalike attacks.
- OAuthWeb Platform
A protocol for granting one application limited access to a user's data on another, without handing over the user's password.
- PhishingWeb Platform
Tricking people into handing over passwords, money, or access with messages and websites that impersonate someone they trust, the most common way attackers get in, and why technical defenses beat training.
- Referrer PolicyWeb Platform
The rules for when a browser tells a site which page a visitor came from, a header misspelled in the 1990s that leaked private addresses for decades until browsers began trimming it by default.
- Same-Origin PolicyWeb Platform
The browser rule isolating documents by scheme, host, and port, and the mechanisms for relaxing it.
- Server-Side Request ForgeryWeb Platform
Tricking a server into making requests on an attacker's behalf, reaching internal services and cloud credential endpoints that the attacker could never reach directly, behind some of the largest cloud breaches.
- Single Sign-OnWeb Platform
Signing in once with a central identity provider and being trusted by many separate applications, through signed assertions passed by browser redirects, which concentrates both convenience and risk in one place.
- Threat ModelingTesting & Verification
A structured way of asking what could go wrong with a system's security before an attacker answers it, by drawing where data flows, marking where trust changes, and walking each crossing through a list of threats.