Skip to content
Open redirect Write-up Intermediate

#BugBounty @ Linkedln-How I was able to bypass Open Redirection Protection

Avinash Jain Follow

Published on medium.com

{{media:0}}

Avinash Jain (@logicbomb_1), on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

LinkedIn exposes an endpoint that performs an external redirect, taking the destination from a url parameter and a companion urlHash parameter. The vulnerable URL in the report was:

Text
https://www.linkedin.com/lite/external-redirect?url=http://evilzone.org&urlHash=YKI5

The feature's job is to send a user to an external site, but only when the request is legitimate. The researcher's goal was to make the endpoint redirect to an arbitrary external domain, which is the classic open redirection condition: an application incorporates user-controllable data into the target of a redirection in an unsafe way, letting an attacker construct a URL within the application that redirects to an arbitrary external domain.

The report opens with a generic illustration of the pattern. A vulnerable link might look like this, where vulparam indicates where to send the user after a successful login:

Text
http://xyz.com/login.html?vulparam=https://xyz.com/next

If the site does not validate that the target page is legitimate and intended, the attacker can manipulate the parameter to send a victim to a fake page:

Setup

No accounts, roles, tools or versions are described in the report. The work was done against the LinkedIn web endpoint above, using the raw HTTP request as the main object of study. The only external reference used was a GitHub issue in the snowplow/referer-parser project, which the researcher consulted to find the LinkedIn Android app's referer value.

Finding it

The endpoint takes two parameters. Simply changing url to any malicious site does not work, because urlHash appears to be a hash value for the URL the user is being redirected to. A successful redirect only happens when urlHash is the actual valid hash for the given url. That pairing is the protection the researcher had to defeat.

Common bypass techniques were tried first and all failed:

Text
url=../evilzone.org
url= ///evilzone.org
url= ///[redacted]/%2f%2e%2e

At that point it was clear that basic techniques would not achieve anything, so the researcher went back to the raw request to look for another angle.

Image for post
Open Redirection Raw Request From the original on medium.com

The raw request includes the referer field, which indicates the last page the user was on, that is, the page where they clicked the link. That raised the question of whether the validation also looked at the referer, so the next step was to change the referer header value and observe the behaviour.

Exploitation

Step 1: Test arbitrary referer values

The referer header was changed to various other domains. The redirection still did not succeed with other domain values in the referer header.

Step 2: Find a referer value LinkedIn would accept

The researcher searched for the LinkedIn Android app referer and found the snowplow/referer-parser issue at https://github.com/snowplow/referer-parser/issues/131. There the LinkedIn Android referer value is given as:

Text
android-app://com.linkedin.android

Step 3: Send the request with that referer

That value was placed in the referer header field, with the rest of the request as shown below.

Image for post
Image for post From the original on medium.com

The result was a successful redirection, which bypassed the open redirection protection.

Root cause

The urlHash must be the valid hash for the url. The researcher suspected the request's referer header might also be taken into account, and the successful redirect with the Android app referer suggests it was. The referer check is the weak point. The referer is client-supplied, and sending the Android app scheme android-app://com.linkedin.android produced a successful redirect. Supplying that referer value produced a successful redirect to the external url. The report does not explain how the referer value related to the urlHash check. The report does not describe the server-side implementation, so the exact validation logic is not stated.

Impact

An attacker can construct a LinkedIn URL that redirects a victim to an arbitrary external domain, which is the standard open redirection impact: sending users to a fake page crafted by the attacker.

Fix

The report gives a timeline rather than a description of the code change:

Date Event
11-Nov-2017 Bug reported to the company
07-Dec-2017 Bug marked fixed
21-Dec-2017 Re-tested and confirmed the fix

Variants to test

  1. Referer-based validation on redirect endpoints. Send the redirect request with a referer from a first-party mobile app scheme, such as an android-app:// or ios-app:// value belonging to the target, and see whether the redirect to an external url succeeds. A positive result is a 3xx response with a Location header pointing at the external domain.
  2. Hash-paired parameters. Where a redirect endpoint pairs a destination with a hash or signature, check whether any other request attribute (referer, user agent, origin) relaxes the check. A positive result is a redirect that succeeds only when that attribute is present.
  3. Scheme and path tricks on the destination. Try relative paths, triple slashes and userinfo-style hosts in the url parameter, as the researcher did, and watch for any that produce an external Location. A positive result is a redirect whose host is not the target's.
  4. Mobile app referer values from public sources. Look up known app referer strings in public parser projects and issue trackers, then replay them against redirect endpoints. A positive result is the same as in variant 1.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

A security researcher found a way to make a LinkedIn web address send visitors to any other website the attacker chose, even though LinkedIn had protections in place to stop exactly that. This kind of flaw is called an open redirection. The researcher reported it, LinkedIn fixed it, and the researcher re-tested to confirm the fix. This article walks through the same steps for someone who has never done security testing before: what the feature does, why the obvious tricks failed, and how a single request header, the referer, turned out to be the weak point.

Background: what an open redirect is

When you click a link, your browser asks a web server for a page. Sometimes the server does not return the page itself; instead it replies with a short message that says "go and look at this other address instead". That message is called a redirect. Redirects are normal and useful: after you log in, a site may redirect you to your account page; after you click a shortened link, the shortener redirects you to the full address.

An open redirect is when a site takes an address from the URL you gave it and uses that address as the redirect target without checking that it is safe. The danger is that an attacker can craft a link that looks like it belongs to the trusted site but actually sends the visitor to a fake site. The fake site can look identical to the real one and ask for a password, for example.

The report opens with a generic example of the pattern. A vulnerable link might look like this, where vulparam indicates where to send the user after a successful login:

Text
http://xyz.com/login.html?vulparam=https://xyz.com/next

Here xyz.com is a made-up site. The part after the question mark is a parameter: a named value passed in the URL. The parameter is called vulparam, and its value is https://xyz.com/next, the page the site intends to show after login. If the site does not validate that the target page is legitimate and intended, an attacker can change that value to point somewhere else:

In this second link the parameter value is now http://evil.com, an attacker-controlled site. A victim who clicks the link sees the trusted domain at the start and may not notice the parameter at the end. The server, if it trusts the parameter blindly, redirects the victim to evil.com.

The LinkedIn feature that was tested

LinkedIn had a page whose job is to send a user to an external site. The address of that page, as given in the report, was:

Text
https://www.linkedin.com/lite/external-redirect?url=http://evilzone.org&urlHash=YKI5

Breaking this down:

  • https://www.linkedin.com is the LinkedIn web server.
  • /lite/external-redirect is the path of the feature on that server. The name suggests its purpose: redirect to an external site.
  • ?url=http://evilzone.org is the first parameter. url holds the destination the user should be sent to. In the example it is http://evilzone.org, a site used here to stand in for any external site.
  • &urlHash=YKI5 is the second parameter. urlHash looks like a short code computed from the url value. The ampersand & separates the two parameters.

The researcher's goal was to make this endpoint redirect to an arbitrary external domain, which is the classic open redirection condition: an application incorporates user-controllable data into the target of a redirection in an unsafe way, letting an attacker construct a URL within the application that redirects to an arbitrary external domain.

First attempts: why the obvious tricks failed

Simply changing the url value to any malicious site does not work here. The reason is the second parameter, urlHash. It appears to be a hash value for the URL the user is being redirected to. A hash, in this context, is a short code produced by a mathematical function from some input; the same input always gives the same code, and a different input gives a different code. The report describes urlHash as looking like a hash value for the URL, and says a successful redirect only happens when it is the actual valid hash for the url. A successful redirect only happens when urlHash is the actual valid hash for the given url. That pairing is the protection the researcher had to defeat.

Before looking for a way around it, the researcher tried some common bypass techniques. All of them failed:

Text
url=../evilzone.org
url= ///evilzone.org
url= ///[redacted]/%2f%2e%2e

These are attempts to confuse the server about where the address really points:

  • url=../evilzone.org uses .., which in file paths means "go up one folder". The idea is that the server might resolve the path and end up at a different host.
  • url= ///evilzone.org starts with three slashes. Browsers and servers sometimes treat extra slashes loosely, and an attacker hopes the server will interpret the value as a full address to evilzone.org.
  • url= ///[redacted]/%2f%2e%2e combines several tricks. The @ in a URL separates user information from the host, so a parser might read www.linkedln.com as a username and www.evilzone.org as the real host. The %2f and %2e%2e are URL-encoded characters: %2f is a slash and %2e%2e is ... The aim is to make the address look like LinkedIn while actually pointing elsewhere.

None of these worked. At that point it was clear that basic techniques would not achieve anything, so the researcher went back to the raw request to look for another angle.

Looking at the raw request

A raw request is the exact text your browser sends to a server when it asks for a page. Tools for developers and security testers can show it, and it is made of a request line followed by headers. Headers are lines of the form Name: value that carry extra information: what browser you use, what page you came from, what formats you accept, and so on. Looking at the raw request means reading those lines instead of only looking at the URL in the address bar.

Image for post
Open Redirection Raw Request From the original on medium.com

The image shows the raw request for the redirect, with the referer field visible. The referer header indicates the last page the user was on, that is, the page where they clicked the link. When you click a link on a page, your browser normally tells the next server which page you came from, so the server can see the context of the visit. The researcher's question was whether the validation also looked at the referer. If it did, then changing the referer might change the outcome. That is why the next step was to change the referer header value and observe the behaviour.

Step 1: Test arbitrary referer values

The referer header was changed to various other domains. The idea was simple: if the server checks that the request comes from a trusted page, then a referer pointing at a random domain should be rejected, but a referer pointing at a trusted domain might be accepted. The redirection still did not succeed, so the referer check, if any, was not satisfied by just any value. The redirection still did not succeed with other domain values in the referer header.

Step 2: Find a referer value LinkedIn would accept

The researcher then searched for the LinkedIn Android app referer. Mobile apps can also open web pages, and when they do, they can send a referer value that identifies the app rather than a web page. These app referers use a special scheme, such as android-app://, followed by the app's package name. The search led to a public issue in the snowplow/referer-parser project at https://github.com/snowplow/referer-parser/issues/131. That project is a library for parsing referer values, and its issue tracker contained the LinkedIn Android referer value:

Text
android-app://com.linkedin.android

This string means "the LinkedIn Android app". android-app is the scheme, and com.linkedin.android is the app's package identifier. The researcher now had the LinkedIn Android app referer value and used it in the request.

Step 3: Send the request with that referer

That value was placed in the referer header field, with the rest of the request as shown below.

Image for post
Image for post From the original on medium.com

The image shows the request with the referer header set to android-app://com.linkedin.android, alongside the url and urlHash parameters. The result was a successful redirection, which bypassed the open redirection protection.

Why it worked

The urlHash must be the valid hash for the url. The researcher suspected the request's referer header might also be taken into account, and the successful redirect with the Android app referer suggests it was. The referer check is the weak point. The referer is client-supplied, and sending the Android app scheme android-app://com.linkedin.android produced a successful redirect. Supplying that referer value produced a successful redirect to the external url. The report does not explain how the referer value related to the urlHash check. The report does not describe the server-side implementation, so the exact validation logic is not stated.

A useful comparison is a club doorman who checks two things: that your ticket number matches the event, and that you say you are a member. The ticket check is strong because the number is hard to guess. The membership check is weak because anyone can say "I am a member". Here the urlHash is the ticket and the referer is the membership claim. The researcher could not get past the urlHash with the obvious tricks, but sending the LinkedIn Android app referer produced a successful redirect.

Impact

An attacker can construct a LinkedIn URL that redirects a victim to an arbitrary external domain, which is the standard open redirection impact: sending users to a fake page crafted by the attacker.

Fix

The report gives a timeline rather than a description of the code change:

Date Event
11-Nov-2017 Bug reported to the company
07-Dec-2017 Bug marked fixed
21-Dec-2017 Re-tested and confirmed the fix

Variants to test

If you want to look for similar issues in your own testing, these are the directions the researcher suggests. Each one describes what to send and what a positive result looks like.

  1. Referer-based validation on redirect endpoints. Send the redirect request with a referer from a first-party mobile app scheme, such as an android-app:// or ios-app:// value belonging to the target, and see whether the redirect to an external url succeeds. A positive result is a 3xx response with a Location header pointing at the external domain. A 3xx response is the family of HTTP status codes that mean "look elsewhere"; the Location header is where the browser is told to go.
  2. Hash-paired parameters. Where a redirect endpoint pairs a destination with a hash or signature, check whether any other request attribute (referer, user agent, origin) relaxes the check. A positive result is a redirect that succeeds only when that attribute is present.
  3. Scheme and path tricks on the destination. Try relative paths, triple slashes and userinfo-style hosts in the url parameter, as the researcher did, and watch for any that produce an external Location. A positive result is a redirect whose host is not the target's.
  4. Mobile app referer values from public sources. Look up known app referer strings in public parser projects and issue trackers, then replay them against redirect endpoints. A positive result is the same as in variant 1.

Glossary

  • API: a defined way for one piece of software to ask another for something, like a menu of requests a service accepts.
  • Cookie: a small piece of data a website stores in your browser and that your browser sends back on later requests, often used to remember who you are.
  • Endpoint: a specific address on a server that performs a specific action, such as /lite/external-redirect.
  • Hash: a short code computed from some input by a mathematical function; the same input always gives the same code, and a different input gives a different code.
  • Header: a line of extra information sent with an HTTP request or response, in the form Name: value.
  • HTTP: the language browsers and servers use to exchange requests and responses.
  • Location header: the response header that tells a browser where to go when the server replies with a redirect.
  • Open redirect: a flaw where a site takes a destination from user-supplied data and redirects there without checking that the destination is safe.
  • Parameter: a named value passed in a URL after a question mark, such as url=... or urlHash=....
  • Raw request: the exact text a browser or tool sends to a server, including the request line and all headers.
  • Redirect: a server response that tells the browser to fetch a different address instead.
  • Referer: an HTTP header that tells the server which page the user came from when they clicked a link.
  • Scheme: the first part of a URL, such as http, https or android-app, which says how to interpret the rest of the address.
  • Status code: a three-digit number in an HTTP response that summarises the result, such as 200 for success or 3xx for a redirect.
  • URL encoding: writing characters that are not allowed in a URL as a percent sign followed by two hexadecimal digits, such as %2f for a slash.
  • User agent: a request header that identifies the browser or app making the request.
  • Vulnerability: a weakness in software that an attacker can use to make it behave in a way its owners did not intend.

More by Avinash Jain

View all

29 more disclosed reports, best first.

More from LinkedIn

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.