// write-up
Open Redirect
My notes about Open Redirect
Category: [Server-Side / Client-Side]
Severity: [Low to Medium / High to Critical (chained)]
Impact: [OAuth / SSO Token Theft, XSS, SSRF Filter Bypass, Referer Header Leakage]
Definition
This vulnerability occurs when a target visits a website and that website sends their browser to a different URL, Open Redirect exploits the trust of a given domain to redirect the target to a malicious website. It also can lead to some phishing attacks, or sometimes it can being used to exploit other kind of vulnerabilities using the same origin to bypass SOP, attackers can also use it to steal OAuth tokens.
How open redirect works
It occurs when developer mistrusts the attacker-controlled input to redirect to another website, usually using a URL parameter, HTML <meta> refresh tag, or the DOM window location property.
Parameter-based
Example:
https://example.com/?redirect_to=https://site.com
in this URL, redirect_to parameter tells the application to redirect the user’s browser to https://site.com, usually by returning a 301 or 302 (3xx) status code, after that, location header determines where to redirect the GET requests.
Now, suppose an attacker just changed the URL to another value:
https://example.com/?redirect_to=https://attacker.com
If the application doesn’t validate the value of redirect_to to its own legitimate websites, attacker can redirect the users where they want to perform other kind of attacks, Simply, the browser of victim will send GET requests to https://attacker.com instead of supposed website.
<meta> tag based
In addition to parameter-based attacks, HTML <meta> tag and JavaScript can redirects browsers too. <meta> tag can tell browsers to refresh a page and make a GET request a URL defined in the tag’s content attribute, example:
<meta http-equiv="refresh" content="0; url=https://example.com/">
The content attribute defines how browsers make an HTTP request in 2 ways:
- First, it defines how long the browser waits before making the request to URL, in this example
0 seconds - Second, it defines the URL that the browser should send
GETrequest to after waiting, in this examplehttps://example.com/Attackers can use this behavior in situations where they have control oncontenttag by injecting their arbitrary value or other kinds of vulnerabilities.
JS DOM based
An attacker can also use JS to redirect users by modifying the window’s location property through the DOM (Document Object Model).
If the attacker be able to change the location value, they would set its value to their own server and abuse it, example:
window.location = "https://attacker.com";
window.location.href = "https://attacker.com";
window.location.replace("https://attacker.com");
It can also occur using the XSS vulnerability, where an attacker can change the JS.
For example: search.html:
<h1>Search results</h1>
<div id="output"></div>
<script>
const params = new URLSearchParams(window.location.search);
const query = params.get("q");
// Vulnerable: untrusted input written directly into the DOM as HTML
document.getElementById("output").innerHTML = "You searched for: " + query;
</script>
The page takes the q parameter from the URL and inserts it with innerHTML without sanitizing it. That is the XSS sink.
Attacker’s crafted link
https://victim.com/search.html?q=<img src=x onerror="window.location='https://attacker.com'">
Real-World examples
Shopify login open redirect vulnerable URL:
http://mystore.myshopify.com/account/login?checkout_url=.example
It was redirecting to:
http://mystore.myshopify.com.example
which is not a shopify domain, the attacker can use their own domain and create a subdomain named mystore.myshopify.com, and set the parameter to:
http://mystore.myshopify.com/account/login?checkout_url=.attacker.com
the result: mystore.myshopify.com.attacker.com which is a subdomain for attacker.com.
There’s another possible scenario for attacker, they can use @ or other special characters to truncate the URL, so the victim will be redirected to something like this:
http://mystore.myshopify.com/account/login?checkout_url=.@attacker.com
Final URL:
https://mystore.myshopify.com.@attacker.com
the server will consider the mystore.myshopify.com. as username and loads attacker.com
HackreOne Interstitial Redirect The core bug:
- HackerOne has a warning page (interstitial). Links to outside sites get an external icon and a “you’re leaving HackerOne” page. Links on
hackerone.comitself are trusted and skip it. /zendesk_sessionis a HackerOne link that forwards you to Zendesk (HackerOne’s support system), so it was treated as trusted and had no warning.- Zendesk lets one account redirect to another through
/ping/redirect_to_account?state=<account>, again with no warning. - The researcher (zombiehelp54) created his own Zendesk account,
compayn.zendesk.com. In the theme editor he added this to the page header:
<script>document.location.href = "http://evil.com";</script>
Anyone who lands on his account page gets bounced to evil.com.
5. He chained it into one link:
https://hackerone.com/zendesk_session?locale_id=1&return_to=https://support.hackerone.com/ping/redirect_to_account?state=compayn:/
The path is hackerone.com (trusted) → HackerOne’s Zendesk → compayn.zendesk.com (his account) → his JS runs → evil.com. The victim sees a hackerone.com link and no warning at any point.