Pentester Nepal
Published in

Pentester Nepal

Open Redirect: Just a redirection?

Greetings, everyone! i’m back with a new article after a long absence. In this writeup, i will attempt to explain everything i know about open redirect. I recently discovered an open redirect on a private program and successfully exploited it to gain access to the account of the victim. I though I’d let the community know that an open redirect isn’t only the way to lead a victim to a phishing site with the help of this article.

What is Open Redirect?

When a web application or server utilizes an unvalidated user-submitted link to redirect the user to a specific website or page, this is known as an open redirection.

Picture Source: business2community

Where to find Open Redirect?

Here are some of the possible parameters for open redirect (You may use them to FUZZ , Google Dork or manually look):

  • “go”
  • “return”
  • “r_url”
  • “returnUrl”
  • “returnUri”
  • “locationUrl”
  • “goTo”
  • “return_url”
  • “return_uri”
  • “ref=”
  • “referrer=”
  • “backUrl”
  • “returnTo”
  • “successUrl”

In order to better understand it, let’s have a look at a particularly weak spot in the codebase.

Vulnerable code #1:

<?php$redirect_url = $_GET['url'];echo "pass me url to get redirected";header("Location: " . $redirect_url);?>

Here, the parameter “url” is directly passed to the header Location to redirect the user to the value of url parameter.That is why the server redirects user to URL passed through the url parameter.

example #1 openredirect

As you can see above, you will get redirected towards if you pass the value // to the parameter “url”.

Account Takeover scenario:

Suppose your target have Oauth configuration, then when a user authenticates with his/her credentials, the URL may look like this:

redirect_uri=CALLBACK_URL: where the service redirects the user after an authorization code is granted.

When authenticating via oauth the final destination with the token is handled by return_uri= In the above example, the site will return to along with a ?code=, defined in response_type=code. , so if you are able to redirect to a site you control, you will be able to leak the token. Most Oauth setups will whitelist **. We can bypass this by abusing the open redirect we found before. (workflow is same but the parameters may vary)

Abusing Open redirect to steal access_token:

  1. We can send the user to the following: (Since the is whitelisted, it will accept this as redirect_uri)
  2. The user will authenticate and the token will be generated.

3. The web application redirects to

4. The web application redirects to //

5. Now, since you got the code parameter on your server, you can use the code to login to the victim’s account.

Stealing Tokens via OpenRedirect

Abusing Open Redirect to bypass SSRF filter:

Open redirect is something that is often used to bypass filters . Imagine that you have a service that are allowed to access content from a specific domain, but that domain could redirect anywhere. Then an attacker can enter the allowed server, and from there go anywhere.

Vulnerable Code #2

let url = new URL(window.location);
let searchParams = new URLSearchParams(;
<h1>Demo Open Redirect to XSS</h1>

Now, i assume you can already sense about the open Redirect as the parameter url is taken from the window.location and is used to redirect to url which is passed.

Abusing Open Redirect for XSS:

Open Redirect to XSS

Since it is redirecting to url passed through url parameter, As url is not sanitized and used inside script tag, it is possible to inject javascript code on the url parameter and get execute the malicious javascript code to gain XSS.


Processing unvalidated user inputs, particularly URL query strings, is the most common cause of open redirection. When possible, avoid user-controllable data in URLs and carefully sanitize it when it must be used to reduce the possibility of undesired redirects. Whitelisting all permissible target locations and redirecting all other values to a default location is a good idea. Another option is to produce a unique ID for each redirect target, eliminating the URL’s user-controllable names. You can further decrease the possibility of token leaks by restricting referrer URL visibility with a proper Referrer-Policy header.

Common Bypasses:

I reported open redirect and it got rejected?

Not always being able to redirect a user to another domain will be a valid vulnerability until you can escalate it to show some serious impact on the target.

Some publicly Disclosed HackerOne Reports:

Learn More Here: BugBountyHunter, PayloadAllThings, PortSwigger

Ping Me up if you have any Doubts:

Bye until Next time.



Aim to feature infosec, bug bounty, privacy and security awareness articles from Nepali security researchers and bug bounty hunters.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store