What is an open redirect?
An open redirect is a flaw where your site sends visitors to a web address taken from the request, such as a next or redirect parameter, without checking it. Attackers use your trusted domain in a link so the victim lands on a malicious site that looks legitimate.
How it works
Login pages often accept a parameter that says where to go after sign-in. If the code redirects to whatever value it receives, an attacker can send a link that begins with your real domain and ends on a lookalike login page. The link looks safe in an e-mail and passes spam filters, and the victim enters their password on the fake page. Open redirects can also help chain other bugs, such as bypassing an allow-list in an OAuth flow.
// Vulnerable
app.get("/login/done", (req, res) => res.redirect(req.query.next));
// Safer: only local paths
const next = String(req.query.next ?? "/");
res.redirect(/^/(?![/\])/.test(next) ? next : "/");How to tell if your site is affected
- A URL such as /login?next=https://example.org sends you to example.org after the action.
- Your front-end code assigns a query parameter to location.href or window.location.
- Redirects accept protocol-relative values like //example.org or tricky forms such as /\example.org.
- You check only that the target "contains" or "starts with" your domain. A host such as yourdomain.com.evil.example passes such checks.
How to fix it
Prefer fixed destinations or an ID that maps to a known page, instead of a free URL.
If you accept a URL, parse it and compare the host to an allow-list. Accept only same-site relative paths that begin with a single slash.
Reject values starting with //, a backslash or a scheme such as javascript:.
In Next.js check the value before calling redirect() or router.push(); the library does not validate it for you.
For OAuth and SSO, register exact redirect URIs at the provider and do not use wildcards.
How ScanAnt checks for it
The free quick scan reads your public JavaScript for code that sends the browser to an address taken from the URL. The deep scan, for verified owners, tests redirect-looking GET parameters with a harmless marker address and reports whether the response points to it. No forms are submitted and no real logins are used.
Questions
Is an open redirect a real vulnerability?
It is usually rated low to medium on its own, but it makes phishing much more convincing and is often a link in a larger attack, so it is worth fixing.
How is it different from SSRF?
An open redirect sends a visitor's browser elsewhere. SSRF makes your server send requests to a place the attacker picks.
Is redirecting to a relative path always safe?
Mostly, but a value like //evil.example looks relative and is not. Check that it starts with one slash and not two.
Do search engines flag open redirects?
Spam campaigns that abuse them can damage your domain's reputation, which affects e-mail delivery and browser warnings.
Related terms
SSRF
An attacker makes your server fetch an address they pick.
Read →XSS
Untrusted text runs as script in your visitors' browsers.
Read →OWASP Top 10
The ranked list of the most critical web application risks.
Read →Check your own site
Known CVEs, injection probes, open redirects and exposed files, in plain language.
Open the matching check →
See if your site is affected
Free for any public site, no signup. Need the verified or deep scan? Choose the level on the scan page.
Choose a scan level →