Open redirects: how a harmless rule turns into a phishing tool
A redirect rule with a placeholder saves a lot of upkeep. Put the placeholder in the wrong spot, though, and the visitor decides where it leads, under your domain. How to recognise the pattern, how to test your rules without risk, and why we had the problem in Linkjet ourselves.
Redirects with placeholders are handy. One rule catches a hundred old addresses, so you do not have to maintain a hundred rules. The price is a question people rarely ask when they set one up: what happens if someone deliberately shapes the part of the address that the placeholder picks up?
With most rules, nothing. If the placeholder sits in one particular position, though, the visitor gets to decide where your site sends them.
What an open redirect is
A redirect is a response from your server with a status code such as 301 or 302 and a Location line naming the new destination. The browser follows that line without asking. How 301 and 302 differ and when to use which is covered in our guide to 301 redirects in WordPress.
A redirect is called open when its destination can be steered from outside through the request. Then anyone can build a link that runs through your domain to any site they like. Security references treat this as a class of its own: MITRE lists it as CWE-601, OWASP under Unvalidated Redirects and Forwards.
For perspective: an open redirect is not a break-in. On its own it gets nobody into your database or your admin area. What gets abused is something else, namely your domain's good name.
The pattern: a placeholder in the wrong place
Take a rule with a regular expression: pattern go/(.+), target /$1. It is meant for tidying up, so /go/guide becomes /guide. That works.
Now someone requests /go//attacker.example, with two slashes. The pattern matches, $1 holds /attacker.example, and the target becomes //attacker.example. The slash from the template and the slash from the request end up side by side. To a browser, two slashes at the start of an address mean that a host name starts here. It keeps only the scheme of the current page and loads attacker.example.
Three positions in the target are risky:
- The placeholder comes first, possibly after one or two slashes:
$1,/$1,//$1. - The placeholder directly follows the scheme:
http:$1,https:/$1,https://$1. - The placeholder directly follows the host name, with no slash in between:
https://partner.example$1. With.attacker.exampleas the value this becomespartner.example.attacker.example, a subdomain the attacker controls.
A placeholder is harmless behind a fixed path segment such as /guide/$1 or behind a fixed host with a slash such as https://partner.example/$1. There the value can change the path at most, not the host. The domain-move line from our 301 guide, https://new-domain.com/$1, is of this kind.
The pattern is not tied to any particular tool. It appears wherever part of a request lands unchecked in a redirect target, in a plugin just as much as in a server configuration. Whether a specific rule is affected is something a test tells you, not the product name.
Why the browser sees a foreign host where you see a path
Browsers parse addresses according to the WHATWG URL Standard, which is more forgiving in several places than you would assume when writing a rule. We reproduced the cases with the URL parser in Node.js 24.18.0, which implements that standard. Each row starts from a page on www.example.com that responds with the given Location value:
| Location value | Browser ends up on | Why |
|---|---|---|
/guide/attacker.example | your own site | One slash: a path on the same host |
//attacker.example | attacker.example | Two slashes introduce a host name |
///attacker.example | attacker.example | Extra slashes are skipped |
/\attacker.example | attacker.example | For http and https a backslash counts as a slash |
/, tab, /attacker.example | attacker.example | Browsers strip tabs and line breaks before parsing |
http:attacker.example on an https page | attacker.example | If the scheme differs from the current page, everything after the colon is the host |
https:/attacker.example on an http page | attacker.example | The same case the other way round |
https:/attacker.example on an https page | your own site | The same scheme without two slashes counts as a path |
/%2F%2Fattacker.example | your own site | Encoded slashes separate nothing for the browser |
The last row is only half reassuring. Encoded slashes become dangerous as soon as software decodes the request path before inserting it into the rule. Then %2F%2F in the request turns into a real // in the target. It also works the other way round: a filter that strips unwanted characters from the target can push two slashes together. WordPress cleans every target in wp_redirect() and removes, among other things, apostrophes and tabs. That is how /'/attacker.example becomes //attacker.example.
So what needs checking is the final target, after substitution and after every cleaning step, the way the browser reads it. Checking the template alone is not enough.
What attackers use it for
The typical purpose is phishing. An email contains a link that starts with your domain, for example https://your-site.example/go//login.attacker.example. Anyone who checks the domain before clicking sees yours and clicks. The browser lands on a cloned login page. OWASP describes exactly this effect: because the server name in the link matches the genuine site, the phishing attempt looks more trustworthy.
For your visitors that is dangerous, for you it is a nuisance. In the worst case your domain turns up in other people's scam emails without anything having happened on your server. So closing it is worth it even if your own site holds nothing worth protecting.
Linkjet had this hole itself
Linkjet has had regex redirects since version 1.5.0 from August 2026. Even then the plugin refused placeholders in the host part of the target, but the check only recognised targets that start with // or with a scheme followed by //. /$1 did not fall under it, and neither did https:/$1 or http:$1. There was no check on each individual request.
We found it while reviewing the 1.5.3 source code on September 8, 2026. Versions 1.5.0 to 1.5.3 were affected, which in the WordPress directory means 1.5.3, listed there since September 4. The hole could only be exploited on sites with a regex rule whose target starts with a placeholder or puts it directly after the scheme. Redirects and short links without placeholders were not affected.
We reproduced both versions in WordPress Playground with WordPress 7.1.3 and PHP 8.3, each time with the package from the directory and the rule go/(.+) to /$1:
| Request or action | Linkjet 1.5.3 | Linkjet 1.5.4 |
|---|---|---|
/go/product-1 | Redirect to /product-1 | Redirect to /product-1 |
/go//selftest.invalid | Location: //selftest.invalid, foreign host | no redirect |
/go/%2F%2Fselftest.invalid | Redirect to /selftest.invalid, own host | no redirect |
Save a rule with target http:$1 | saved | refused |
Save a rule with target https:/$1 | saved | refused |
Rule with target https://partner.example/$1, request with x | Redirect to https://partner.example/x | Redirect to https://partner.example/x |
That 1.5.3 did not send the encoded variant in the third row off-site was not protection but a different bug: the plugin threw away every percent sequence while cleaning the path, which is also why redirects for addresses with umlauts such as /%C3%9Cber-uns did not match. 1.5.4 now decodes the path correctly. As a result %2F%2F reaches the rule as a real double slash, and that is exactly why the guard has to sit behind it. The encoding fix and the guard belong in the same release.
What Linkjet has done about it since version 1.5.4
Our first fix proposal on September 8 was to collapse leading double slashes in the target into one. That would have closed the reported case but left templates such as http:$1 and https:/$1 open, which need no double slash at all. So we built two checks instead, plus a protective rule for core addresses. As a precaution, the checks also cover backslashes and characters that only drop out during cleaning.
1. The final target is read the way a browser reads it
After the placeholders are filled in, Linkjet evaluates the target the way wp_redirect() would send it and a browser would read it: tabs and line breaks are dropped, a backslash counts as a slash, a scheme without // is resolved. Encoded slashes and backslashes (%2F, %5C) are counted too, as a precaution, in case a server decodes them later. After that, only the host the rule itself names is allowed. With /$1 the rule names none, so the target has to stay on your site. If a request would lead elsewhere, Linkjet skips the rule for that request. If no other rule matches, WordPress responds as if the rule did not exist, usually with the 404 page.
2. Dangerous templates are refused when you save
When you save, Linkjet fills all placeholders with a harmless test value. If that value alone already decides the host, as with http:$1, https:/$1, //$1 or https://partner.example$1, the rule is refused with a message. This applies to every route by which rules come into being: the form, the REST API, CSV and JSON import, the import wizard and bulk redirecting in the Pro edition. The live test in the rule editor uses the same guard and shows a notice instead of a target for a dangerous sample path.
3. WordPress core addresses are off limits
A rule may not cover an address that WordPress serves itself, such as wp-login.php, wp-sitemap.xml, wp-comments-post.php, wp-signup.php or xmlrpc.php. 1.5.4 refuses such slugs when you save, and older rules on these paths do not fire. This is only indirectly related to open redirects, but it belongs to the same question: which addresses should a rule be allowed to take over at all?
Two further changes in the same release point the same way. With parameter forwarding switched on, parameters from the request no longer overwrite parameters that are already in the target, so an appended ?tag=… no longer replaces your affiliate ID. And the settings, as well as the import that replaces all rules, now require administrator rights. Editors with Linkjet access still manage links.
We explicitly checked that what has to keep working still does: /guide/$1, https://partner.example/$1 and protocol-relative targets with a fixed host such as //cdn.partner.example/$1. Our security self-test for this release has 110 checks; 42 of them concern the open redirect, and eleven of those 42 make sure legitimate rules still fire. Before release, two separate review runs also resolved every target the guard let through with a browser parser, across 4,455 and 5,439 combinations of template and request. None led to a foreign host. Existing rules with a dangerous template no longer redirect off-site after the update either.
What the guard does not cover
- Linkjet rules only. Linkjet does not check redirects in
.htaccess, in the server configuration or in other plugins. For those, use the self-test in the next section. - Fixed external targets stay allowed. An affiliate link to a shop is what the plugin is for. The guard stops the visitor from choosing the host, not you.
- No update, no protection. The checks only work from 1.5.4 on. The same applies with Linkjet Pro, because there too the free Linkjet handles the redirects. How to install updates with little risk is covered in updating WordPress plugins.
Self-test: check your own rules
Two ground rules first. Only test sites you run yourself or have been engaged to test. And use an address ending in .invalid as the probe target. Under RFC 2606 that ending is reserved for addresses that are sure to be invalid. Even an open rule leads to no real site with it.
- Collect rules with placeholders. Go through the rule list of your redirect plugin and, if you have them, the
RewriteRulelines in.htaccess. Note every rule whose target contains$1to$9, and in.htaccessalso%1to%9. These percent placeholders come from aRewriteCond. If the value comes from the host name (%{HTTP_HOST}), as in the usual www redirect, an outside link cannot set it and you can skip the rule. If it comes from the query string (%{QUERY_STRING}), put the probe address in the parameter instead of the path. - Look at the position. If nothing, or only a scheme and slashes, comes before the placeholder, as in
$1,/$1,//$1,http:$1,https:/$1orhttps://$1, the rule goes on your test list. If it sits directly after the host name without a slash, as inhttps://partner.example$1, you need no probe: put a slash between host and placeholder right away. You can skip the other rules. - Build probe addresses. Take the fixed start of the pattern and append an extra slash and the probe target, and in a second probe two extra slashes. For
go/(.+)those are the paths/go//selftest.invalidand/go///selftest.invalid, plus the variants/go/%2F%2Fselftest.invalidand/go/%5Cselftest.invalid. You request each of them after your domain, for example ashttps://your-site.example/go//selftest.invalid. The second probe is needed for a target$1without a slash in front: there the first one only yields/selftest.invalid, a path on your own site. For a target such ashttp:$1,https://$1or//$1,/go/selftest.invalidis enough. - Request them and read the response. Open the developer tools in Chrome or Firefox with F12 (Cmd+Option+I on a Mac), switch to the Network tab and turn on the option that keeps the log across page loads. Then request the probe address. The first row shows the status code, the response headers show the
Locationline. On the command line,curl -si(on Windowscurl.exe -si) with the probe address shows the status code and headers without following the redirect. IfLocationnames another address on your site, request that one the same way.
| What you see | What it means | What to do |
|---|---|---|
| No redirect, or every redirect stays on your domain | The rule holds up against this probe | Nothing, if all probes end this way |
Location starts with //, /\ or \\, followed by selftest.invalid | Open redirect | Rebuild the rule, see the next section |
Location names selftest.invalid as the host, for example https://selftest.invalid | Open redirect | Rebuild the rule |
Location starts with http: or https:, followed by at most one slash and selftest.invalid | Open, depending on the scheme of the requesting page | Rebuild the rule |
| The browser reports that selftest.invalid cannot be reached | It followed the redirect, the rule is open | Rebuild the rule |
With Linkjet 1.5.4 it is quicker: in the rule editor, enter a path that matches the pattern in the Sample path field, for example go//selftest.invalid, and click Test pattern. If the rule is vulnerable, like go/(.+) to /$1, you get a notice saying that the rule is skipped for that path, instead of a target. For a safe rule the test shows a normal target, or No match if the path does not fit the pattern.
How to build rules that are never open in the first place
- Always put something fixed in front of the placeholder: a path segment such as
/guide/$1or a host with a slash such ashttps://partner.example/$1. - Capture only what you need.
([a-z0-9-]+)instead of(.+): without slashes, backslashes and colons in the value, even a placeholder at the start of the target can no longer introduce a host. The request/go//selftest.invaliddoes not match such a pattern at all. This adds to the fixed part in front of the placeholder, it does not replace it. - Check the result, not the template. If you write redirect code yourself: substitute first, then clean, then determine the host the way a browser reads it and compare it against a list of allowed hosts.
- Keep the circle small. Whoever may create rules can set any target. That is not a bug, but it is a reason to give that right to few people.
If you are tidying up anyway: how to redirect dead addresses deliberately is covered in our article on 404 errors in WordPress. What else Linkjet does and how moving over from another plugin works is described in our overview of free redirect plugins and our Pretty Links comparison.
Linkjet
Redirects, short links and regex rules, checked when you save and guarded on every request. Free in the WordPress directory, no external calls.
Frequently asked questions
What is an open redirect?
A redirect whose destination can be controlled from outside through the requested address. Anyone can then build a link that starts with your domain and ends on any site they like. The weakness is catalogued as CWE-601. It does not affect your server, it affects the trust in your domain, and it is mainly used for phishing.
Has my site been hacked if it has an open redirect?
No. On its own, an open redirect gives nobody access to your database, files or admin area. What gets abused is your domain name: a link looks like yours and still leads somewhere else. Close it anyway, because your visitors are the ones who suffer and your domain can turn up in other people's scam emails.
Why is a double slash in a redirect target dangerous?
Under the URL Standard, two slashes at the start of an address introduce a host name. The browser turns the target //attacker.example into https://attacker.example, taking only the scheme from the current page. A single slash, by contrast, stays a path on your own site.
Is it enough to collapse double slashes in the target into one?
No. Browsers also read a backslash as a slash, strip tabs before parsing and treat http:attacker.example on an https page as a foreign address. On top of that, filters that remove characters can push two slashes together after the fact. What needs checking is the final target, as it appears in the header and as the browser reads it.
How do I test my redirects without attacking anyone else?
Test only your own site and use an address ending in .invalid as the probe target, for example selftest.invalid. Under RFC 2606 that ending is reserved for addresses that are sure to be invalid, so even an open rule leads to no real site. Request the probe address with the developer tools open and read the Location line in the response.
Which Linkjet versions were affected?
Versions 1.5.0 to 1.5.3, and only on sites with a regex rule whose target starts with a placeholder or puts it directly after the scheme, such as /$1 or http:$1. Since October 12, 2026, Linkjet 1.5.4 has been in the WordPress directory. It checks the final target on every request, and when you save it refuses templates such as http:$1, where the placeholder alone decides the host.