BookMyShow account takeover using social login
BookMyShow's social login did not verify which application issued the Facebook access token or Google ID token, so an attacker could use a token from their own app to log into any user's account. This allowed account takeover.
Published on medium.com
{{media:0}}
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
BookMyShow (BMS) is an Indian ticketing platform. The feature in scope is its social login: signing in to a BMS account with Facebook or with Google instead of a BMS password. Normally the BMS app obtains an access token (Facebook) or an ID token (Google) for the user and hands it to BMS, which uses it to identify the user and log them in.
The write-up is framed around a fictional victim, Derpina Victims, whose BMS account is taken over after she uses a viral Facebook app that tells her when she will die. The app's creator collects users' access tokens and uses them against BMS. The author is explicit that this framing is a story meant to show how a misconfigured social login can be exploited.

Visual representation of the assumption of how the victim's access token is used to log into BMS.
Setup
The researcher needed a Facebook application of his own, which he created with the email scope. He created a Facebook app with the email scope and used the access token it produced in place of the token generated by the BookMyShow app. No special tooling is described beyond "my tools ready", and no versions are given.
Finding it
The starting point was an email from BookMyShow telling users that their accounts had been compromised because of data leaks on other platforms.

The researcher did not accept that explanation. He reasoned that this is not 2005 and that there had to be something more behind the compromises. He first tried SQL injection on the login endpoint; nothing happened. He then turned to Login with Facebook and noticed that BMS was using access_token for login. That is the observation that mattered: the login flow accepted a Facebook access token as the credential, which raised the question of whether BMS checked who had issued that token.
Exploitation
Step 1: Create a Facebook app with the email scope
He created his own Facebook application and obtained an access token from it with the email scope. This token belongs to a third-party app, not to the BookMyShow app.
Step 2: Submit the third-party token to BMS
He used the token created by his own app instead of the access token generated by the BookMyShow app. The report does not reproduce the request itself, only the result: he was logged into BookMyShow using an access token created by a third-party app.

Access token of the researcher's Facebook app.

Logged into BMS using the access token of the researcher's app.
Step 3: Repeat against Login with Google
Login with Facebook was not the only affected flow. Login with Google was misconfigured in the same way: BMS did not check the creator of the id_token.
Root cause
BMS validated the token only as a valid Facebook token and then checked whether the email associated with it existed in its user database. It did not check who had issued the access token. BMS checked only that the token was a valid Facebook token and that the email was in its database, not who issued the token. The same flaw existed on the Google side, where the issuer of the id_token was not verified.
In effect the login flow treated "a valid token from the identity provider" as equivalent to "a token issued to BookMyShow", which are different trust statements. The report points to Bhavuk Jain's write-up on misconfigured Login with Facebook/Google for the fuller technical explanation.
Impact
An attacker who operates a Facebook (or Google) application and gets a victim to authorise it can collect the victim's access token and use it to log into the victim's BMS account, provided the victim's social account email matches a BMS account. The attacker does not need the victim's BMS password. In the story, the lure is a viral app that tells users when they will die; the token collection happens as a side effect of the victim using the app.
Fix
BookMyShow sent a security update email on 13 Jun 2019 at 1:06 AM. The vulnerability was found at 1:35 AM and reported with mitigation suggestions at 4:23 AM the same day. On 26 Jun 2019 at 9:43 PM the researcher received an email saying the bug had been fixed, and on 28 Jun 2019 at 3:43 PM a bounty was rewarded. The report does not describe the code change itself. He reported the bug with mitigation suggestions, though the report does not describe them.
Variants to test
- Facebook access token from your own app. Create a Facebook app with the
emailscope, obtain a token for an account whose email matches a target account, and submit it to the target's Facebook login. A positive result is being logged into the target account. - Google
id_tokenfrom your own client. Obtain an ID token from a Google OAuth client you control and submit it to the target's Google login. A positive result is a session on the target account. - Email matching. For either provider, confirm whether the target links accounts by email alone; a positive result is a login where the only shared attribute is the email address.
- Other social providers. Apply the same test to any other social login the target offers, checking whether the issuer or audience of the token is validated.
What happened, in plain words
BookMyShow (often shortened to BMS) is an Indian website and app for booking cinema tickets, concerts and other events. Like many sites, it lets you sign in with a social account instead of a BookMyShow password. You click "Login with Facebook" or "Login with Google", the social network confirms who you are, and BookMyShow lets you in. This feature is called social login.
The write-up tells the story of a made-up victim called Derpina Victims. Derpina sees a silly Facebook app that claims to tell her when she will die. Her friends are posting their results, so she tries it too. What she does not know is that the person behind that app is quietly keeping a copy of something called an access token for every person who uses it. That token is a short string of characters that a social network hands out to prove "this person really is who they say they are". The attacker then feeds Derpina's token to BookMyShow, and BookMyShow lets him into her account. He never learns her BookMyShow password.
The author is clear that the story is only an illustration, a way to show how a badly configured social login can be abused. The real finding is simpler: BookMyShow accepted a token that had been issued to somebody else's app, as long as the token was a genuine Facebook token and the email inside it matched an existing BookMyShow account.

The picture shows the author's assumption of how the victim's access token ends up being used to log into BookMyShow.
The pieces you need to know
Before the steps make sense, a few everyday ideas.
- API: an API is the way one piece of software talks to another. Think of a restaurant: you (the app) do not walk into the kitchen; you tell the waiter (the API) what you want, and the waiter brings it back. BookMyShow's login is an API that the app talks to.
- Token: a token is like a cloakroom ticket. You hand in your coat (you prove who you are once), and you get a small ticket. Later you show the ticket and get the coat back, without proving who you are again. A token is a short piece of text that stands in for your identity for a while.
- Access token (Facebook): the ticket Facebook gives to an app after you approve it, saying "this app may act for this user".
- ID token (Google): Google's version of the same idea. It is a small signed statement about who you are.
- Scope: the list of permissions an app asks for. The
emailscope means "let this app see my email address". - Issuer: the party that created the token. A token issued to the BookMyShow app and a token issued to a random quiz app can both be valid Facebook tokens, but they were issued to different apps. Checking the issuer means checking which app the token was made for.
- SQL injection: a classic attack where you type database commands into a login form in the hope the site runs them. It is a different bug from the one found here.
Setting up
The researcher needed a Facebook application of his own, which he created with the email scope. That is something any Facebook user can do through Facebook's developer pages; you register an app, give it a name, and Facebook gives you credentials for it.
He created a Facebook app that asked for the email scope, and then used the access token that app produced in place of the token the real BookMyShow app would produce. The write-up mentions getting "my tools ready" but does not name any special software, and gives no version numbers.
How the finding started
The starting point was an email from BookMyShow telling users that their accounts had been compromised because of data leaks on other platforms. In other words, BookMyShow was blaming breaches at other companies for the break-ins on its own site.

The researcher did not accept that explanation. His reasoning was that this is not 2005 any more, and there had to be something more going on than stolen passwords from elsewhere. So he began probing the login.
He tried SQL injection on the login endpoint first. Nothing happened: the login form did not behave in the way a vulnerable one would. He then turned to Login with Facebook and noticed something important: BookMyShow was using a parameter called access_token for the login. That is the observation that mattered. The login flow was accepting a Facebook access token as the credential, which immediately raises the question: does BookMyShow check who issued that token?
Exploitation
Step 1: Create a Facebook app with the email scope
He created his own Facebook application and obtained an access token from it with the email scope. This token belongs to a third-party app, not to the BookMyShow app. In cloakroom terms, he got a ticket from a different cloakroom and planned to wave it at BookMyShow's counter.
Step 2: Submit the third-party token to BookMyShow
He used the token created by his own app instead of the access token generated by the BookMyShow app. The write-up does not reproduce the actual request, only the result: he was logged into BookMyShow using an access token created by a third-party app.

The access token of the researcher's own Facebook app.

The researcher logged into BookMyShow using the access token of his own app.
Step 3: Repeat against Login with Google
Login with Facebook was not the only affected flow. Login with Google was misconfigured in the same way: BookMyShow did not check the creator of the id_token. The report says Google login was misconfigured in the same way.
Why it worked
BookMyShow validated the token only as a valid Facebook token, and then checked whether the email associated with it existed in its user database. It did not check who had issued the access token. BookMyShow checked only that the token was a valid Facebook token and that the email was in its database, not who issued the token. The same flaw existed on the Google side, where the issuer of the id_token was not verified.
In effect the login flow treated "a valid token from the identity provider" as equivalent to "a token issued to BookMyShow", which are two different trust statements. The write-up points to Bhavuk Jain's article on misconfigured Login with Facebook/Google for the fuller technical explanation.
What an attacker could do
An attacker who operates a Facebook (or Google) application and gets a victim to authorise it can collect the victim's access token and use it to log into the victim's BookMyShow account, provided the victim's social account email matches a BookMyShow account. The attacker does not need the victim's BookMyShow password. In the story, the lure is a viral app that tells users when they will die; the token collection happens as a side effect of the victim using the app.
Timeline and fix
BookMyShow sent a security update email on 13 Jun 2019 at 1:06 AM. The vulnerability was found at 1:35 AM and reported with mitigation suggestions at 4:23 AM the same day. On 26 Jun 2019 at 9:43 PM the researcher received an email saying the bug had been fixed, and on 28 Jun 2019 at 3:43 PM a bounty was rewarded. The write-up does not describe the code change itself. He reported the bug with mitigation suggestions, though the write-up does not describe them.
Variants to test
- Facebook access token from your own app. Create a Facebook app with the
emailscope, obtain a token for an account whose email matches a target account, and submit it to the target's Facebook login. A positive result is being logged into the target account. - Google
id_tokenfrom your own client. Obtain an ID token from a Google OAuth client you control and submit it to the target's Google login. A positive result is a session on the target account. - Email matching. For either provider, confirm whether the target links accounts by email alone; a positive result is a login where the only shared attribute is the email address.
- Other social providers. Apply the same test to any other social login the target offers, checking whether the issuer or audience of the token is validated.
Glossary
- API: the agreed way for one piece of software to ask another for something, like a waiter taking your order to the kitchen.
- Access token: a short piece of text a social network gives an app after you approve it, standing in for your identity for a while.
- ID token: Google's signed statement about who you are, handed to an app after you sign in.
- Scope: the list of permissions an app asks for, such as
email. - Issuer: the party that created a token; checking the issuer means checking which app the token was made for.
- Social login: signing in to a site using a Facebook or Google account instead of a password for that site.
- OAuth: the general system behind "Login with Facebook/Google", where one site asks another to confirm who you are.
- SQL injection: typing database commands into a form in the hope the site runs them.
- Endpoint: a specific address on a server that an app sends requests to, such as the login address.
- Account takeover: an attacker getting into someone else's account without their password.
- Bounty: a reward a company pays a researcher for reporting a security bug.
- Mitigation: a change that closes the hole, here verifying the token's issuer.