Full Account Takeover via Referer Header (OAuth token Steal, Open Redirect Vulnerability Chaining)
An OAuth callback endpoint passed the access token in the URL query string and also accepted a user-controlled redirect_uri. By bypassing the open-redirect filter, an attacker could send a victim to their own server, where the token leaked through the Referer header, allowing account takeover.
Published on web.archive.org
#### protector47
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.
Context
This write-up describes how an OAuth token issued by a private HackerOne program, referred to throughout as Redacted, could be stolen by chaining an open redirect with the behaviour of the Referer header. The application offered third-party login through Facebook, Google and Twitter. After a normal social login, the browser was sent to an endpoint that carried the OAuth token and a redirect_uri parameter in the query string, and that endpoint then redirected the user onwards.
The researcher, Muhammad Asim Shahzad (@protector47), frames the finding around three concepts, which he defines at the start of the post.
Referer header. The Referer request header contains the address of the previous web page from which a link to the currently requested page was followed. Servers use it to identify where visitors come from, for analytics, logging or optimised caching.
Open redirect. An open redirect is a flaw in an application or web page that causes it to fail to properly authenticate URLs, so an attacker can steer users to a malicious third-party site.
OAuth tokens. OAuth (Open Authorization) is an open standard for token-based authentication and authorisation. It lets an end user's account information be used by third-party services, such as Facebook, without exposing the user's password. Session tokens, access tokens and OAuth tokens are highly sensitive: anyone who obtains one can log in to the account without knowing its password. The post points to the Facebook breach of the time as an example of what token leakage leads to.
Setup
The testing was done against a private program on HackerOne, so the hostname is replaced with redacted.com and the token value in the examples is a placeholder. The report names BURP HTTP History for inspecting the login traffic and Intruder for fuzzing the redirect parameter. No versions are given. No versions are given.
The precondition for the attack is that a victim completes a social login on the target and that the resulting redirect can be pointed at an attacker-controlled server. Because the token travels in the URL by GET, it is also present in the Referer of whatever request the victim's browser makes next.
Finding it
While logging in to the account, the researcher reviewed the BURP HTTP History and found an endpoint that contained the OAuth token together with a second parameter, redirect_uri, used for redirecting the user. The shape of the request was as follows:
Here oauth carries the token and redirect_uri tells the application where to send the user after login. The reasoning was straightforward: if the redirect_uri filter could be bypassed and the victim redirected to the researcher's server, the browser's request to that server would carry a Referer header containing the previous page's address, which is the URL above, including the token. The token was transmitted by GET, so it sat in the URL rather than in a body or fragment.

Exploitation
Step 1: Confirm the token in the redirect URL
After a social login, the HTTP history showed the endpoint with the oauth token and the redirect_uri parameter, as in the request above. This established both that the token is exposed in the URL and that the destination is user-influenced.
Step 2: Attempt a direct redirect
The first attempt was to inject the researcher's own server URL into redirect_uri. It failed: the filter rejected it.
Step 3: Fuzz the redirect filter
With the direct value blocked, Burp Intruder was used to try hundreds of open-redirect payloads, taken from the PayloadsAllTheThings open redirect list:
https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open%20redirect
After 300 attempts, one payload produced a 301 response from the target server, meaning the redirect filter had been bypassed. The report does not show which payload succeeded.
Step 4: Capture the token from the Referer header
With the bypass in place, the victim was redirected to the researcher's server. The request that arrived there carried the OAuth token in the Referer header, because the previous page in the browser's history was the token-bearing URL. The request that arrived there carried the OAuth token in the Referer header.

The finding earned a $1,200 bounty.
Root cause
The design puts the OAuth token in the query string of a URL that is also the redirect source, and the redirect destination is taken from a user-supplied redirect_uri parameter. Two mistakes combine. First, the redirect target is not restricted to trusted destinations, so a user can be sent to an arbitrary third-party site. Second, the token is carried in the URL of the page that performs the redirect, so any request the browser makes after leaving that page leaks the full URL, token included, in the Referer header.
A correct redirect_uri allowlist would have stopped the chain at step 2, and keeping the token out of the URL, or stripping it before the redirect, would have removed the value that the Referer header exposes. The report does not describe the filter's implementation, so why the first direct attempt failed and which class of bypass worked is not stated; the bypass is only evidenced by the 301 response after fuzzing.
Impact
An attacker who can lure a victim through the crafted login flow obtains the victim's OAuth token and can log in to the account without the password. The attack requires the victim to complete the social login and follow the manipulated redirect, and it requires a working bypass of the redirect_uri filter. The report does not discuss other accounts, roles or additional data beyond the token.
Fix
Based on the root cause, the redirect target should be validated against a strict allowlist of trusted destinations rather than a blocklist that can be fuzzed, and the token should not be placed in a URL that is followed by a redirect to a third party: it should be delivered in a way that does not end up in the Referer header, or the redirect should be performed without the token in the referring URL.
Variants to test
- Other social login providers. Test the Facebook, Google and Twitter flows separately; a positive result is a token-bearing URL with a
redirect_uriparameter that can be pointed off-site. - Different bypass classes. Run the PayloadsAllTheThings open redirect list against each provider's
redirect_uri; a positive result is a301(or any redirect) to the attacker's host. - Referer leakage without an open redirect. Check whether the token-bearing URL is followed by any request to a third-party resource, such as an image or analytics call; a positive result is the token appearing in the
Refererof that request. - Token in other URL positions. Look for tokens in fragments, path segments or query parameters on post-login pages; a positive result is a token that survives into a subsequent cross-origin request.
What happened, in plain words
A security researcher was testing a private web application on HackerOne, a platform where companies invite researchers to look for bugs in their systems. The application is private, so the researcher calls it Redacted throughout. The application let people sign in with a third-party account, such as Facebook, Google or Twitter, instead of creating a separate password for the site.
When someone signs in that way, the site receives a token from the third-party provider. A token is a long string of characters that acts like a temporary key: whoever holds it is treated as the logged-in user. After logging in, the researcher found in the HTTP history an endpoint containing the token and a second value, redirect_uri, that told the site where to send the user next. That second value could be changed by the person visiting the page. By changing it, the researcher found a way to send the victim to a server the researcher controlled, and the victim's browser then handed the token over in a standard header called Referer. With that token, the researcher could log in as the victim without ever knowing the victim's password. The company paid a $1,200 bounty for the finding.
The write-up is built around three ideas, which the researcher explains before showing the attack. It is worth going through them slowly, because the whole attack depends on how they fit together.
What is the Referer header?
Every time your browser asks a server for something, it sends a small set of extra lines along with the request. These lines are called headers. They are not visible on the page; they are part of the conversation between your browser and the server, a bit like the envelope around a letter. One of those headers is Referer (the spelling with one "r" is a historical accident in the standard; the word is meant to be "referrer").
The Referer header contains the address of the previous web page from which a link to the currently requested page was followed. In plain terms: when you click a link on page A and land on page B, your browser tells page B's server "I came here from page A" by putting A's address in the Referer header. Servers use this for analytics (counting which pages send them visitors), for logging, and for optimised caching.
The important consequence for this story is that the Referer header carries the full address of the previous page, including anything that was in that address. If the previous page's address contained a secret, the secret travels with it.
What is an open redirect?
A redirect is when a server answers a request by saying "not here, go to this other address instead". Websites use redirects all the time: after you log in, you are sent to your dashboard; after you submit a form, you are sent to a thank-you page. The server tells the browser the new address, and the browser goes there automatically.
An open redirect is a security flaw in an application or a web page that causes it to fail to properly authenticate URLs. In everyday terms: the site accepts a destination from the visitor and forwards them there without checking that the destination is a place the site trusts. It is like a receptionist who will walk you to any address you name, including a stranger's house. An attacker can use this to steer users to a malicious third-party website, often with a link that starts on the trusted site's domain, which makes it look legitimate.
What is an OAuth token?
OAuth (Open Authorization) is an open standard for token-based authentication and authorization on the Internet. It is the mechanism behind "Log in with Facebook", "Log in with Google" and similar buttons. It allows an end user's account information to be used by third-party services, such as Facebook, without exposing the user's password. You never give the other site your Facebook password; Facebook gives the other site a token instead, and the other site uses that token to confirm who you are.
Session tokens, access tokens and OAuth tokens are highly sensitive data. If an attacker gets this information, they can be logged in to your account without knowing your account password. The researcher points to the Facebook breach of the time as an example of what token leakage leads to: stolen access tokens were the heart of that incident.
A useful comparison: a token is like a coat-check ticket. The attendant does not need to know your name or see your ID; whoever holds the ticket gets the coat. If someone photographs your ticket, they can collect your coat.
How the three ideas combine
The attack is a chain: each weakness on its own is limited, but together they hand over the account.
- The token sits in the address of a page.
- That page redirects the visitor to a destination the visitor can influence.
- If the destination can be pointed at the attacker's server, the browser's request to that server includes the previous page's address in the
Refererheader, and that address contains the token.
How I was able to steal the OAuth token?
The researcher was testing a web application on HackerOne. The application is private, so it is referred to as Redacted and the hostname in the examples is replaced with redacted.com. The token value shown in the examples is a placeholder, not a real token.

This kind of vulnerability is usually found on applications that use third-party login methods such as login with Facebook, Google or Twitter. Redacted had all three. The researcher logged in to the account normally, then looked at the traffic the browser had produced, using a tool called Burp Suite. Burp is a program that sits between your browser and the internet and records every request and response, so you can read them afterwards. The part of Burp used here is its HTTP history, a list of everything that went past.
In that history, the researcher found an endpoint containing the OAuth token, and a second parameter called redirect_uri used for redirecting the user. An endpoint is simply a specific address on a server that does a particular job, like a counter in a shop. A parameter is a named value attached to the address, written after a ? and separated by &; it is how a URL carries instructions. redirect_uri is the conventional name for "where should we send the user next".
The endpoint looked like this:
Line by line, in plain words:
https://redacted.com/is the site being visited.httpsmeans the connection is encrypted.?marks the start of the parameters. Everything after it is data being passed to the page, not part of the page's path.oauth=gfhju76554678ggfr576898gfhjis the first parameter. Its name isoauthand its value is the token. In the real request this value was a live token; here it is a made-up string.&separates one parameter from the next.redirect_uri=https://test.comis the second parameter. Its name isredirect_uriand its value is the address the site should send the user to. In the example it ishttps://test.com, a stand-in for wherever the user should land.
The researcher's reasoning was direct. The Referer header contains the address of the previous web page. So if the redirect_uri filter could be bypassed and the victim redirected to the researcher's server, then the request arriving at that server would carry a Referer header containing the previous page's address, which is the URL above, token included. The token was being transmitted by GET, meaning it travelled in the URL itself rather than in a form submission body. That matters because the URL is exactly what ends up in Referer.
A comparison: imagine a courier who, on arriving at your door, always reads out the address they just came from. If the previous address had your safe combination written on the door, the courier would read that out too.
Exploitation
The work proceeded in four steps.
Step 1: Confirm the token in the redirect URL
After a social login, the HTTP history showed the endpoint with the oauth token and the redirect_uri parameter, as in the request above. This established two things at once: the token is exposed in the URL, and the destination is influenced by whoever visits the page. Without both, the chain would not work.
Step 2: Attempt a direct redirect
The first attempt was to put the researcher's own server address into redirect_uri. It failed: the filter rejected it. A filter here is a check in the application that inspects the value and refuses ones it does not like. The direct attempt was the obvious move, and the application was already guarding against it.
Step 3: Fuzz the redirect filter
With the direct value blocked, the researcher used Burp Intruder, the part of Burp that automatically sends many variations of a request, one after another, substituting a different value each time. This process is called fuzzing: throwing a large set of candidate inputs at a check to see which one slips through. The candidates were open-redirect payloads taken from a public list, PayloadsAllTheThings:
https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open%20redirect
That line is a web address pointing to a folder in a public GitHub repository. GitHub is a site where people share code and lists; this particular folder collects known tricks for bypassing open-redirect filters. The researcher did not write the payloads by hand; the list supplied them.
After 300 attempts, one payload produced a 301 response from the target server. A 301 is an HTTP status code meaning "this page has moved permanently, go to this other address". In this context it meant the redirect filter had been bypassed: the server was now willing to send the visitor where the researcher asked. The write-up does not show which payload succeeded.
Step 4: Capture the token from the Referer header
With the bypass in place, the victim was redirected to the researcher's server. The request that arrived there carried the OAuth token in the Referer header, because the previous page in the browser's history was the token-bearing URL. The request that arrived there carried the OAuth token in the Referer header.

The finding earned a $1,200 bounty.
Why it worked
The design puts the OAuth token in the query string of a URL that is also the redirect source, and the redirect destination is taken from a user-supplied redirect_uri parameter. Two mistakes combine.
First, the redirect target is not restricted to trusted destinations, so a user can be sent to an arbitrary third-party site. Second, the token is carried in the URL of the page that performs the redirect, so any request the browser makes after leaving that page leaks the full URL, token included, in the Referer header.
A correct redirect_uri allowlist (a list of destinations that are explicitly permitted, with everything else refused) would have stopped the chain at step 2. Keeping the token out of the URL, or stripping it before the redirect, would have removed the value that the Referer header exposes. The write-up does not describe how the filter was implemented, so why the first direct attempt failed and which class of bypass worked is not stated; the bypass is only evidenced by the 301 response after fuzzing.
Impact
An attacker who can lure a victim through the crafted login flow obtains the victim's OAuth token and can log in to the account without the password. The attack requires the victim to complete the social login and follow the manipulated redirect, and it requires a working bypass of the redirect_uri filter. The write-up does not discuss other accounts, roles or additional data beyond the token.
Fix
Based on the root cause, the redirect target should be validated against a strict allowlist of trusted destinations rather than a blocklist that can be fuzzed, and the token should not be placed in a URL that is followed by a redirect to a third party: it should be delivered in a way that does not end up in the Referer header, or the redirect should be performed without the token in the referring URL.
Variants to test
- Other social login providers. Test the Facebook, Google and Twitter flows separately; a positive result is a token-bearing URL with a
redirect_uriparameter that can be pointed off-site. - Different bypass classes. Run the PayloadsAllTheThings open redirect list against each provider's
redirect_uri; a positive result is a301(or any redirect) to the attacker's host. - Referer leakage without an open redirect. Check whether the token-bearing URL is followed by any request to a third-party resource, such as an image or analytics call; a positive result is the token appearing in the
Refererof that request. - Token in other URL positions. Look for tokens in fragments, path segments or query parameters on post-login pages; a positive result is a token that survives into a subsequent cross-origin request.
Glossary
- API: a defined set of addresses and rules that one program uses to talk to another; here, the endpoints the browser calls during login.
- Access token: a credential that grants access to a resource on behalf of a user; anyone holding it is treated as that user.
- Allowlist: a list of values that are explicitly permitted, with everything else refused.
- Blocklist: a list of values that are explicitly refused, with everything else permitted; easier to bypass than an allowlist because it only stops what someone thought of.
- Bounty: a payment a company makes to a researcher who reports a valid security bug.
- Burp Intruder: the part of Burp Suite that automatically sends many variations of a request, substituting a different value each time.
- Burp Suite: a tool that sits between a browser and the internet and records requests and responses so they can be inspected and modified.
- Endpoint: a specific address on a server that performs a particular job.
- Filter: a check in an application that inspects input and refuses values it does not like.
- Fuzzing: sending a large set of candidate inputs at a check to see which one slips through.
- GET: an HTTP method used when a browser asks for a page or resource; any data it carries travels in the URL.
- Header: an extra line of information sent alongside an HTTP request or response, not visible on the page.
- HTTP history: Burp's recorded list of every request and response that passed through it.
- OAuth: an open standard for token-based authentication and authorization that lets a third-party service use your account information without exposing your password.
- OAuth token: the token issued through OAuth that proves who you are to the application you are logging in to.
- Open redirect: a flaw where an application accepts a destination from the visitor and forwards them there without checking that the destination is trusted.
- Parameter: a named value attached to a URL after a
?, separated by&, used to pass instructions to the page. - Payload: the specific input an attacker sends to try to trigger a behaviour, such as a crafted redirect destination.
- Query string: the part of a URL after the
?that carries parameters. - Redirect: a server response telling the browser to go to a different address instead.
- Referer header: a request header containing the address of the previous web page from which a link to the currently requested page was followed.
- Session token: a credential that identifies a logged-in session; like an access token, it is sensitive.
- 301: an HTTP status code meaning the page has moved permanently and the browser should go to the new address.
- Token: a long string of characters that acts as a key; whoever holds it is treated as the user it belongs to.
- URL: the address of a page or resource on the web.
redirect_uri: the parameter that tells an application where to send the user after login.