Skip to content
Open redirect Disclosed report Beginner

Open redirects protection bypass

The redirect authorisation check in ExpressionEngine used a substring match on the Referer header, so a Referer containing the site hostname anywhere (for example as a query parameter) passed the check. An attacker could craft a link that redirects the victim to an arbitrary external site.

strukt Follow

Originally disclosed on HackerOne

  • Triaged in 4 days
  • Fixed in 11 days
  • Disclosed after 11 days

Hello,

When a redirect is to be issue on an ExpressionEngine instance, a request to the following URL is made: http://HOST/PATH_TO_EE/index.php?URL=TARGET_URL Where TARGET_URL is replaced with the actual URL we desire to redirect to. The script PATH_TO_EE_DIR/system/ee/legacy/libraries/Redirect.php is the one responsible for making sure that redirects are authorized by checking the value of the Referer header against the hostname where the ExpressionEngine instance is installed. In order to do so, the following code excerpt is performed:

if ($force_redirect == TRUE OR ( ! isset($_SERVER['HTTP_REFERER']) OR ! stristr($_SERVER['HTTP_REFERER'], $host)))

Ignoring the very first condition because it is not relevant, and the second because it simply checks if the Referer header is not set in the request, the third condition is the actual problem here. The PHP stristr function is used to compare the value of the $host variable, which contains the hostname, to the value of the Referer header. The mentioned function returns TRUE iff the second parameter has been found at least once in the first string parameter, so for example if the actual hostname of the ExpressionEngine instance is http://www.example.com and the Referer header's value is http://evil.com?http://www.example.com, comparing the former and the latter would yield a TRUE return value from the stristr function, leaving the check flawed.

I have prepared a live example that shows the issue in action, follow the steps below to reproduce: 1- Visit http://strukt.tk/pocs/eeredirect.html 2- Enter your hostname with the URL GET parameter set to whatever external page you desire, the supplied URL should look like http://HOST/PATH_TO_EE/index.php?URL=https://www.example.com 3- Click the Test !! button and then click the link that will appear below the input box 4- Notice that you have been redirected directly to the supplied value of the URL GET parameter rather than being prompted as usual

Regards,

The original report as published on HackerOne, by strukt. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The code used a substring search (stristr) to check whether the hostname appeared in the Referer header, instead of verifying that the Referer's host exactly matched the site's host.

Impact

An attacker could redirect a victim to an arbitrary external site.

What the attacker needed

Victim clicks a crafted link

The fix

The check should compare the Referer's host exactly with the site's host.

How it was found

  1. Visit the proof-of-concept page.
  2. Enter the target hostname and set the URL parameter to the external page.
  3. Click the test button and then the link that appears.
  4. Observe the redirect to the supplied URL instead of the usual prompt.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A redirect is a web feature that sends a visitor from one page to another. ExpressionEngine tried to allow redirects only when the request came from its own site, by checking the 'Referer' header, which tells where the visitor came from. The check only looked for the site's name anywhere inside that header, so an attacker could put the site's name in a link and still get redirected to a malicious page.

What is Open redirect?

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.

More by strukt

View all

15 more disclosed reports, best first.

More from ExpressionEngine

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Open redirect

The lesson behind this report.

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.