Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Open redirect on your site: how to find and fix it

OPS-176Medium impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

An open redirect happens when your site takes a destination from the URL (for example ?redirect=, ?next=, ?url=, ?return_to=) and sends the visitor there without checking it. The link starts on your domain, but the visitor ends up somewhere else.

It is common in login pages, logout flows, tracking links, language switchers and "thank you" pages. Developers add it for convenience: send the user back to where they were. The mistake is trusting whatever address arrives.

Example of an abusable linktext
https://yoursite.com/login?next=https://evil.example/fake-login

Why it costs you leads or sales

Phishers love open redirects. The link shows your real domain, so people and email filters trust it. A customer who clicks may land on a fake login page and blame your brand.

There is an ad risk too. Ad platforms review the final destination of a click path. If a redirect on your domain can lead to harmful or unrelated sites, ads that use it can be disapproved or your domain can be flagged. Policies vary, so check the current rules of each platform.

How an open redirect is abused
  1. Attacker crafts linkYour domain plus ?next=evil site
  2. Victim clicksSees your trusted domain
  3. Your site redirectsNo check on the destination
  4. Fake pageSteals logins or card details
  5. Your brandTrust and reputation damaged

The trusted link is the only step that looks safe to the victim.

How to check if your site has it

Test for an open redirect
  1. List redirect parameters

    Look for URLs with parameters like redirect, redirect_to, next, url, return, returnUrl, continue, dest or goto. Check login, logout, checkout and tracking links.

  2. Swap in an outside address

    Replace the value with a site you do not own but is harmless, such as https://example.com. Open the link in a private window.

  3. Watch where you land

    If you end up on example.com, the redirect is open. Also try //example.com and https:%2F%2Fexample.com, because filters often miss these forms.

  4. Check headers from the command line

    Use curl to see the Location header without following it.

Check the Location headerbash
curl -sI "https://yoursite.com/login?next=https://example.com" | grep -i '^location'

How to fix it

The rule is the same everywhere: never redirect to a raw value from the URL. Accept only relative paths on your own site, or match the host against a short allowlist.

Fix by platform
  1. Use wp_safe_redirect

    In custom code, replace wp_redirect() with wp_safe_redirect(), which only allows hosts on your site. Add extra hosts with the allowed_redirect_hosts filter.

  2. Update plugins and themes

    Open redirects often come from plugins. Update them, and remove ones that are abandoned.

Allowlist check in PHPphp
<?php
$target = $_GET['next'] ?? '/';
$allowed_hosts = ['yoursite.com', 'www.yoursite.com'];
$parts = parse_url($target);

$is_relative = isset($target[0]) && $target[0] === '/' && substr($target, 0, 2) !== '//' && substr($target, 0, 2) !== '/\\';
$is_allowed = isset($parts['host']) && in_array($parts['host'], $allowed_hosts, true);

if (!$is_relative && !$is_allowed) {
    $target = '/';
}
header('Location: ' . $target, true, 302);
exit;
Same idea for client-side redirectsjavascript
const params = new URLSearchParams(window.location.search);
const next = params.get('next') || '/';
const url = new URL(next, window.location.origin);
if (url.origin === window.location.origin) {
  window.location.assign(url.pathname + url.search);
} else {
  window.location.assign('/');
}
Redirect handling

Open

  • Any ?next= value is accepted
  • Link shows your trusted domain
  • Can lead to any outside site

Restricted

  • Only relative paths or allowlisted hosts
  • Unknown targets go to the home page
  • Phishing links on your domain stop working

How to confirm it's fixed

Confirm the fix
  • Repeat the test with https://example.com as the parameter and confirm you land on your own site
  • Try //example.com, /\example.com and URL-encoded versions
  • Check the Location header with curl
  • Confirm normal flows still work: login, logout and checkout return users to the right page
  • Test every parameter name you listed, not just one

How to prevent it happening again

Prevention habits
  • Add a code review rule: no redirect uses a raw request value
  • Keep CMS core, themes and plugins updated
  • Run a vulnerability scan after each major release
  • Use a single shared redirect helper so the allowlist lives in one place
  • Remove unused redirect endpoints and old tracking links

How FunnelGuard handles this

This issue is outside what FunnelGuard checks. FunnelGuard runs your real customer journeys, such as lead forms and checkouts, and checks the steps, tracking hits and test leads. It does not scan for security flaws like open redirects.

The right tool is a web vulnerability scanner (DAST) or a penetration test, which probes URL parameters with crafted destinations. Many website firewalls and security plugins also include checks. Use one of these alongside funnel monitoring.

Questions people ask

What is an open redirect vulnerability?

It is a link on your site that sends visitors to any address given in the URL, without checking it. Attackers use it so a malicious link appears to start on your trusted domain.

Why is an open redirect dangerous if it only redirects?

The link looks legitimate, so people and email filters trust it. Victims can land on fake login or payment pages and blame your brand. It can also be chained with other attacks.

How do I test my site for an open redirect?

Find URLs with parameters like next, redirect or url. Replace the value with https://example.com and see whether you end up there. Also check the Location header with curl and try //example.com.

How do I fix an open redirect?

Do not redirect to raw input. Allow only relative paths starting with a single slash, or compare the parsed host to an allowlist you control. Send everything else to your home page.

Can an open redirect get my Google Ads disapproved?

It can contribute. Ad platforms review where a click path ends, and a redirect that can lead to harmful sites may trigger a flag. Policies change, so check each platform's current rules and fix the redirect.

Is wp_redirect in WordPress an open redirect?

wp_redirect() sends to any URL you give it, so passing it unchecked input creates one. wp_safe_redirect() limits targets to your own host and any you allow with the allowed_redirect_hosts filter.

Does FunnelGuard detect open redirects?

No. FunnelGuard monitors funnel journeys, tracking and lead delivery, not security flaws. Use a vulnerability scanner or a penetration test for open redirects.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.