The Referer Header That Redirected OAuth Tokens
A post-login redirect in Airbnb's OAuth callback was driven by the HTTP Referer header, allowing an attacker to control where users were sent after authentication. Combined with a login CSRF that let an attacker silently start an OAuth flow for a victim, this could deliver OAuth tokens to the attacker's page and lead to account takeover.
Published on masimshahzad.medium.com
Bug Bounty
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
Airbnb's login flow supported OAuth through Facebook and Google. The identity providers had already closed the classic attack route: no wildcard redirect URIs were registered, and the provider performed a server-side check that the redirect URI had not been tampered with during the code exchange. Airbnb's registered callbacks were a fixed list of its own localised domains, so the provider hop itself was locked down to exact matches.
The weak point sat inside Airbnb, after the provider handed control back. When a user who was already logged in completed an OAuth round trip, the callback sent them "back" to wherever the Referer header of the initiating request pointed. A Referer is set by whichever page triggers the request, so an attacker's page controls it. Combined with a login endpoint that accepted cross-site GET requests, this turned strict OAuth settings into account takeover.

AI-generated illustration.
The research was done by Arne Swinnen and published on 22 June 2017. It was reported on 4 June 2016 and fixed on 18 August 2016, with a $5,000 bounty. The article you are reading is an analytical case study of that public disclosure, not the author's own discovery, and it deliberately omits reproduction details.
Setup
The attack needs three things to be true at once:
- A victim who is already signed in to Facebook or Google and has a linked Airbnb account.
- An attacker-controlled page the victim visits, which supplies the
Refererfor the OAuth initiation request. - An Airbnb OAuth login start endpoint that accepts a cross-site GET, so the victim can be silently logged into their own account and the attacker-controlled return address is planted in the flow.
No specific tools, versions or test accounts are named in the report. The vulnerability type is an open redirect in an OAuth callback chained with login CSRF, leading to OAuth token theft. The report maps it analytically to CWE-601 and CWE-352, noting that this mapping is not from the source. No CVE was reported, and severity and CVSS are not reported either; the only quantitative figure is the $5,000 bounty.
Finding it
The provider-side defences were intact. Exact-match redirect URIs and the tamper check during code exchange meant the callback URI itself never changed, so provider-side checks passed on every request in the attack. The weak point was what Airbnb did with the user after the callback: it trusted the Referer header of the initiating request to decide where to send them.
That is wrong because the Referer is attacker input: it is set by whichever page triggers the request, so an attacker's page controls it. The OAuth login start endpoint also accepted a cross-site GET. That makes the flow forgeable: a victim can be silently logged into their own account, which plants the attacker-controlled return address in the session. Once that session exists, any later OAuth round trip follows the same redirect, including one that requests tokens in the URL fragment, which browsers carry across redirects.
Exploitation
Step 1: Force a login start with an attacker-controlled Referer
The attacker's page triggers a cross-site GET that starts an OAuth login. Because the endpoint accepts cross-site GETs, the victim is silently logged into their own account, and the Referer of the initiating request, controlled by the attacker's page, becomes the return address stored for the flow. The report does not publish the endpoint path or the exact request.
Step 2: Complete an OAuth round trip
With that session in place, a later OAuth round trip follows the same redirect. The callback URI is unchanged, so the provider's exact-match and tamper checks pass. The report notes that this works even for a flow requesting tokens in the URL fragment, because browsers carry the fragment across redirects.
Step 3: Collect the tokens
The redirect delivers the OAuth tokens to the attacker's page. Per Swinnen, the result is an authorization code usable to log in on the website, and a provider access token that Airbnb's mobile app accepted for login.
Root cause
The mistake is deriving a post-login redirect from the Referer header. The provider hop was protected by exact-match redirect URIs and a server-side tamper check, but those defences only cover the redirect URI registered with the provider, not Airbnb's own redirect after the callback. Because the callback URI never changed, every provider-side check passed while the user was sent to an attacker-chosen destination.
The login CSRF is the setup step that makes the redirect practical: forcing a victim into their own account plants the attacker-controlled return address, and any later OAuth round trip inherits it. The report does not describe the server-side implementation, so the exact code path that reads the Referer is not shown.
Impact
Any victim already signed in to Facebook or Google with a linked Airbnb account could lose their account by visiting one page. That exposes bookings, messages, payment methods and identity documents. The attack was generic across both identity providers, not tied to one app's misconfiguration. The report does not give a CVSS score or a formal severity rating.
Fix
Airbnb fixed both issues in August 2016. The remediation below is the author's own analysis, presented as defence-in-depth:
- Never derive redirects from the Referer. Store an internal return path server-side at flow start and accept only relative paths from an allowlist.
- Make login start a state-bound, same-site action. Reject cross-site requests to OAuth initiation, and bind
stateto a pre-session cookie the attacker cannot set. - Reject unexpected response types. If the callback expects a code, a flow carrying fragment tokens is an anomaly; terminate it instead of redirecting.
- Don't accept bare provider access tokens as mobile login. Use PKCE and a backend code exchange so a stolen token is not a session.
The suggested allowlist and flow handling look like this:
ALLOWED_RETURN_PREFIXES = ("/trips", "/inbox", "/account")
def start_oauth(request):
if request.headers.get("Sec-Fetch-Site") == "cross-site":
raise Rejected("cross-site login start")
rp = request.args.get("return_to", "/")
if not (rp.startswith("/") and not rp.startswith("//")
and rp.startswith(ALLOWED_RETURN_PREFIXES)):
rp = "/"
flow = new_flow(state=random_token(), return_path=rp,
response_type="code")
bind_to_presession_cookie(request, flow)
return redirect(provider_auth_url(flow))
def oauth_callback(request):
flow = load_flow_for_presession(request, request.args.get("state"))
if flow is None or "code" not in request.args:
raise Rejected("invalid or unexpected flow") # no redirect on failure
complete_login(flow, request.args["code"])
return redirect(flow.return_path) # never Referer
Variants to test
- Referer-driven post-login redirects. Look for any callback that sends the user "back" based on a header the browser lets other sites influence. A positive result is a redirect to an attacker-controlled origin after a legitimate OAuth round trip.
- Cross-site GET on OAuth initiation. Send the login start request from a different origin. A positive result is a session created without a same-site action, with the attacker's return address stored.
- Fragment tokens carried across redirects. Request a response type that returns tokens in the fragment and observe whether the redirect preserves them. A positive result is tokens arriving at the attacker's page.
- Bare provider tokens accepted as mobile login. Present a provider access token directly to the mobile login path. A positive result is a session established without a backend code exchange.
- Exact-match redirect URIs with a weak post-callback redirect. Even where the provider enforces exact matches, test what the application does after the callback. A positive result is the provider checks passing while the user lands somewhere the application did not intend.
What happened, in plain words
Airbnb lets people sign in with their Facebook or Google account through OAuth. This is called OAuth. In 2016, a security researcher named Arne Swinnen found a way to steal the login tokens from that process and take over someone's Airbnb account. Airbnb fixed the problem in August 2016 and paid him $5,000.
The interesting part is that Facebook and Google had already done their job properly. The hole was inside Airbnb itself, in what happened after Facebook or Google handed the user back. Airbnb decided where to send the user next by reading a piece of information called the Referer header, which the visitor's browser fills in and which an attacker's web page can control. Combined with a second flaw that let an attacker silently start a login on the victim's behalf, the strict OAuth settings became useless.
This article is a study of that public disclosure, written with AI assistance. It is not the author's own discovery, and it deliberately leaves out the details you would need to reproduce the attack.

AI-generated illustration.
The pieces you need to know first
Before the attack makes sense, here are the everyday ideas behind it.
- OAuth is the "Sign in with Google" or "Sign in with Facebook" button. You prove who you are to Google or Facebook, and they tell Airbnb "yes, this is really them". Airbnb never sees your Google password. Think of it like a hotel asking to see your passport: the passport office vouches for you, the hotel just checks the stamp.
- The identity provider is Google or Facebook in that comparison. The application is Airbnb, the site you are actually logging in to.
- A redirect URI is the address the identity provider sends you back to when it is done. Airbnb registers a list of allowed addresses with Google and Facebook in advance, so nobody can say "send the user to evil.example instead".
- A token is a short string of characters that acts like a temporary key. If you hold the token, you are treated as the logged-in user. It is like a cloakroom ticket: whoever has the ticket gets the coat.
- An authorization code is a one-time token that the application swaps for a longer-lived access token. It is like a claim check you exchange at the counter.
- The URL fragment is the part of a web address after the
#symbol. Browsers keep it when they follow a redirect, which matters later. - A header is extra information a browser attaches to every request, alongside the address. The
Refererheader tells the server which page you came from, so a link onnews.examplewill carryReferer: https://news.example/.... - A cookie is a small piece of data the server asks your browser to store and send back on every request, so the server can remember who you are between page loads. A session is what that cookie represents: your logged-in state on the server.
- CSRF (Cross-Site Request Forgery) means tricking a logged-in user's browser into sending a request the user did not intend. The browser automatically attaches the user's cookies, so the server cannot tell the difference. Login CSRF is the specific version where the attacker forces the victim to log in, usually into the attacker's account or, as here, into their own account in a way the attacker has prepared.
- An open redirect is when a site takes an address from the request and sends the user there without checking it. It is like a receptionist who will forward your parcel to any address you write on it.
- CWE is a catalogue of common weakness types. CVE is a catalogue of specific publicly tracked vulnerabilities. CVSS is a scoring system for how severe a vulnerability is.
The setup
The attack needs three things to be true at once:
- A victim who is already signed in to Facebook or Google and has linked that account to Airbnb.
- A page the attacker controls that the victim visits. That page supplies the
Refererfor the login request. - An Airbnb login-start endpoint that accepts a cross-site GET request, so the victim can be silently logged in and the attacker's chosen return address gets planted in the flow.
No specific tools, versions or test accounts are named. The vulnerability is classed as an open redirect in an OAuth callback chained with login CSRF, leading to OAuth token theft. No CVE was filed, and severity and CVSS are not reported. The only number is the $5,000 bounty.
How the researcher found it
The provider-side defences were intact. Airbnb had registered exact-match redirect URIs, with no wildcards, and the provider checked during the code exchange that the redirect URI had not been tampered with. So the callback address never changed, and every provider-side check passed on every request in the attack.
The weak point was what Airbnb did with the user after the callback: it read the Referer header of the request that started the flow and sent the user there. That is dangerous because the Referer is attacker input. It is set by whichever page triggers the request, and an attacker's page can point it anywhere.
The OAuth login-start endpoint also accepted a cross-site GET. That makes the flow forgeable: a victim can be silently logged into their own account, which plants the attacker-controlled return address in the session. Once that session exists, any later OAuth round trip follows the same redirect, including one that asks for tokens in the URL fragment, which browsers carry across redirects.
The attack, step by step
Step 1: Force a login start with an attacker-controlled Referer
The attacker's page triggers a cross-site GET that starts an OAuth login. Because the endpoint accepts cross-site GETs, the victim is silently logged into their own account, and the Referer of the request, controlled by the attacker's page, becomes the return address stored for the flow. The report does not publish the endpoint path or the exact request.
Why this step matters: the attacker is not stealing anything yet. They are setting up a session in which Airbnb has written down "when this is done, send the user to the attacker's page".
Step 2: Complete an OAuth round trip
With that session in place, a later OAuth round trip follows the same redirect. The callback URI is unchanged, so the provider's exact-match and tamper checks pass. The report notes that this works even for a flow requesting tokens in the URL fragment, because browsers carry the fragment across redirects.
Why this step matters: the provider is doing exactly what it was designed to do. It is Airbnb's own redirect afterwards that sends the user, and the tokens, to the wrong place.
Step 3: Collect the tokens
The redirect delivers the OAuth tokens to the attacker's page. Per Swinnen, the result is an authorization code usable to log in on the website, and a provider access token that Airbnb's mobile app accepted for login.
Why this step matters: the attacker now holds an authorization code usable to log in on the website and a provider access token that Airbnb's mobile app accepted for login.
The root cause
The mistake is deriving a post-login redirect from the Referer header. The provider hop was protected by exact-match redirect URIs and a server-side tamper check, but those defences only cover the redirect URI registered with the provider, not Airbnb's own redirect after the callback. Because the callback URI never changed, every provider-side check passed while the user was sent to an attacker-chosen destination.
The login CSRF is the setup step that makes the redirect practical: forcing a victim into their own account plants the attacker-controlled return address, and any later OAuth round trip inherits it. The report does not describe the server-side implementation, so the exact code path that reads the Referer is not shown.
Who was affected
Any victim already signed in to Facebook or Google with a linked Airbnb account could lose their account by visiting one page. That exposes bookings, messages, payment methods and identity documents. The attack was generic across both identity providers, not tied to one app's misconfiguration. The report does not give a CVSS score or a formal severity rating.
The fix
Airbnb fixed both issues in August 2016. The remediation below is the author's own analysis, presented as defence-in-depth, meaning several layers of protection rather than one.
- Never derive redirects from the Referer. Store an internal return path server-side at flow start and accept only relative paths from an allowlist.
- Make login start a state-bound, same-site action. Reject cross-site requests to OAuth initiation, and bind
stateto a pre-session cookie the attacker cannot set. - Reject unexpected response types. If the callback expects a code, a flow carrying fragment tokens is an anomaly; terminate it instead of redirecting.
- Don't accept bare provider access tokens as mobile login. Use PKCE and a backend code exchange so a stolen token is not a session.
The suggested allowlist and flow handling look like this:
ALLOWED_RETURN_PREFIXES = ("/trips", "/inbox", "/account")
Line by line: this is a list of the only page paths the application is willing to send a user back to after login. Anything else falls back to the home page. It is the equivalent of a receptionist who will only forward parcels to three known addresses.
def start_oauth(request):
if request.headers.get("Sec-Fetch-Site") == "cross-site":
raise Rejected("cross-site login start")
rp = request.args.get("return_to", "/")
if not (rp.startswith("/") and not rp.startswith("//")
and rp.startswith(ALLOWED_RETURN_PREFIXES)):
rp = "/"
flow = new_flow(state=random_token(), return_path=rp,
response_type="code")
bind_to_presession_cookie(request, flow)
return redirect(provider_auth_url(flow))
def oauth_callback(request):
flow = load_flow_for_presession(request, request.args.get("state"))
if flow is None or "code" not in request.args:
raise Rejected("invalid or unexpected flow") # no redirect on failure
complete_login(flow, request.args["code"])
return redirect(flow.return_path) # never Referer
Line by line:
def start_oauth(request):begins the function that handles the moment a user clicks "Sign in with Google" or "Sign in with Facebook".if request.headers.get("Sec-Fetch-Site") == "cross-site":checks a header modern browsers send to say whether the request came from another site. If it did, the next line rejects it, so an attacker's page cannot silently start a login.rp = request.args.get("return_to", "/")reads the requested return path from the URL, defaulting to the home page.- The
if not (...)block checks three things: the path starts with a single/(so it is a path on this site, not another site), it does not start with//(which browsers treat as another site), and it starts with one of the allowed prefixes. If any check fails,rp = "/"resets it to the home page. flow = new_flow(...)creates a record of this login attempt, with a randomstatevalue, the chosen return path, and a request for an authorization code rather than tokens in the fragment.bind_to_presession_cookie(request, flow)ties that record to a cookie the attacker cannot set, so the attacker cannot inject their own flow.return redirect(provider_auth_url(flow))sends the user to Google or Facebook to sign in.def oauth_callback(request):begins the function that runs when the provider sends the user back.flow = load_flow_for_presession(...)looks up the stored flow using thestatevalue from the URL and the pre-session cookie. If they do not match, there is no flow.if flow is None or "code" not in request.args:rejects the request if the flow is missing or the response does not contain an authorization code. The comment notes that it raises an error rather than redirecting, so a failure cannot itself become an open redirect.complete_login(flow, request.args["code"])exchanges the code for a real session.return redirect(flow.return_path)sends the user to the path stored on the server at the start, never to anything taken from theRefererheader.
What to test if you are looking for this
- Referer-driven post-login redirects. Look for any callback that sends the user "back" based on a header the browser lets other sites influence. A positive result is a redirect to an attacker-controlled origin after a legitimate OAuth round trip.
- Cross-site GET on OAuth initiation. Send the login-start request from a different origin. A positive result is a session created without a same-site action, with the attacker's return address stored.
- Fragment tokens carried across redirects. Request a response type that returns tokens in the fragment and observe whether the redirect preserves them. A positive result is tokens arriving at the attacker's page.
- Bare provider tokens accepted as mobile login. Present a provider access token directly to the mobile login path. A positive result is a session established without a backend code exchange.
- Exact-match redirect URIs with a weak post-callback redirect. Even where the provider enforces exact matches, test what the application does after the callback. A positive result is the provider checks passing while the user lands somewhere the application did not intend.
Key takeaways
- Exact-match redirect URIs protect the provider hop, not your own redirects after it.
- Login CSRF matters: forcing a victim into their own account can be the setup step.
- Any header the browser lets other sites influence is attacker input.
Credit and sources
Research by Arne Swinnen: Authentication bypass on Airbnb via OAuth tokens theft (22 June 2017; reported 4 June 2016, fixed 18 August 2016). Discovered via the Awesome-Bugbounty-Writeups index. Facts come from that post; analysis, code and remediation are original suggestions.
Glossary
- OAuth: a way to sign in to one site using an account you already have on another, without sharing your password with the first site.
- Identity provider: the service that confirms who you are during OAuth, such as Facebook or Google.
- Redirect URI: the address the identity provider sends you back to after you sign in, registered in advance by the application.
- Token: a string that acts as a temporary key; whoever holds it is treated as the logged-in user.
- Authorization code: a one-time token that the application exchanges for a longer-lived access token.
- Access token: a token that grants access to a user's data or account at the provider.
- URL fragment: the part of a web address after the
#symbol, which browsers carry across redirects. - Header: extra information a browser attaches to a request, such as where the request came from.
- Referer header: the header that tells the server which page triggered the request; it is set by the page, so other sites can influence it.
- Cookie: a small piece of data a server asks the browser to store and send back on each request, used to remember who you are.
- Session: the logged-in state a server keeps for a user, usually represented by a cookie.
- CSRF (Cross-Site Request Forgery): tricking a logged-in user's browser into sending a request the user did not intend.
- Login CSRF: a CSRF attack that forces the victim to log in, often into an account the attacker has prepared.
- Open redirect: a flaw where a site sends the user to an address taken from the request without checking it.
- GET request: a request that asks a server for a page or resource, normally triggered by clicking a link or loading an image.
- Cross-site request: a request sent from one website to another.
- Endpoint: a specific address on a server that performs a particular action.
- Allowlist: a list of values that are explicitly permitted, with everything else rejected.
- State parameter: a random value OAuth uses to tie a response back to the request that started it, preventing forgery.
- PKCE: an OAuth extension that makes stolen authorization codes useless without a secret the legitimate app holds.
- CWE: a catalogue of common weakness types, such as CWE-601 for open redirect and CWE-352 for CSRF.
- CVE: a catalogue of specific publicly tracked vulnerabilities.
- CVSS: a scoring system for the severity of a vulnerability.
- Defence-in-depth: using several independent layers of protection so one failure does not sink the whole system.
- Account takeover: an attacker gaining control of someone else's account.