Skip to content
Account takeover Write-up Beginner

#BugBounty — “User Account Takeover-I just need your email id to login into your shopping portal account”

The login endpoint accepted either a valid OAuth2 access token or just an email address as proof of identity, so an attacker could log in as any user by supplying only their email. This allowed full account takeover of any user whose email was known or could be enumerated.

Avinash Jain Follow

Published on medium.com

#### Avinash Jain (@logicbomb1)

Avinash Jain (@logicbomb_1), on medium.com

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

Context

This is a write-up about an account takeover in a popular online shopping portal. The portal offered the usual OTP and password login, and in addition a "sign in with google/facebook" option. The researcher focused on the Google sign-in path, which is backed by an OAuth2 signing authorisation service.

The login flow sends two pieces of data to the server: an accessToken carrying the Google OAuth2 sign-in token, and a login parameter carrying the user's mail id. Normally the server should tie the token to the identity it represents and only then let the session through. Here the check was weaker than that, and the whole account takeover follows from it.

The researcher's framing is worth keeping in mind throughout: the most fragile part of software security is integration, and most loopholes come from incorrect implementation when third-party services and modules are wired into an application.

Setup

The researcher worked against the live login page of the shopping portal. No special tooling, versions or privileged accounts are described. The only preconditions were:

  1. A friend with an account on the site, whose mail id the researcher knew.
  2. The ability to enumerate user mail ids on the login page, which the researcher says was possible and which makes the attack scale beyond a known friend.

Finding it

The login page offered the Google/Facebook sign-in alongside OTP and password login.

Image for post
Login Page From the original on medium.com

The researcher signed in with Google and captured the resulting HTTP request.

Image for post
Google Sigin with oauth2 From the original on medium.com

Looking at how the OAuth2 service was implemented on the client side, the raw login request showed two parameters used for login verification: accessToken, carrying the Google OAuth2 sign-in token, and login, carrying the user's mail id.

Image for post
Login HTTP raw request From the original on medium.com

That pairing is what looked wrong. The server appeared to verify either of the two things, the accessToken from OAuth2 or the login mail id, rather than requiring the token to correspond to that mail id. If the identity is taken from a parameter the client controls, the token check becomes decorative.

Exploitation

Step 1: Capture the legitimate login request

The researcher signed in with Google and recorded the request the client sends to the server, with the accessToken and login parameters described above.

Step 2: Swap the login value for the victim's mail id

The login value was replaced with the mail id of a friend who had an account on the site. The researcher notes that such mail ids could also be obtained by user enumeration on the login page. The response to the modified request came back as follows.

Image for post
Change the login value to victim’s mail id From the original on medium.com

Step 3: Observe the successful login

The server accepted the request and the researcher was logged in as the friend, with access to the friend's complete profile.

Because the only thing needed was the victim's login mail id, any user's account could be taken over this way.

Root cause

The OAuth2 service was integrated, but the implementation was weak: the server verified either the accessToken or the login mail id instead of binding the two together. The server verified either the accessToken or the login mail id, so the login parameter, controlled by the client, decided whose account the session belonged to.

Impact

An attacker who knows a victim's login mail id can log into that victim's account and access the complete profile. Since mail ids could be enumerated on the login page, the attack was not limited to people the attacker already knew. The researcher describes this as takeover of any user account on the portal.

Fix

The report records the timeline rather than the code change:

Date Event
10 July 2018 Bug reported to the company
14 August 2018 Bug marked fixed
14 August 2018 Re-tested and fix confirmed
5 October 2018 Rewarded

What was actually changed is not described. A fix that follows from the root cause would be to derive the account identity from the verified OAuth2 token and reject any request where the login value does not match it.

Variants to test

  1. Identity parameter next to a token. On any social-login endpoint, look for a parameter carrying the email or user id alongside the OAuth token. Replace it with another account's value and resend. A positive result is a session or profile belonging to the other account.
  2. Either/or verification. Try sending a valid token with a mismatched identity. A positive result is either combination being accepted.
  3. User enumeration on the login page. Submit candidate mail ids and compare responses. A positive result is a response that distinguishes registered from unregistered addresses, which supplies the targets for the two tests above.
  4. Token reuse across accounts. A positive result is more than one account being reachable with the same token.

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

What happened, in plain words

A security researcher found a way to log into any user's account on a popular online shopping website. The site let people sign in with their Google or Facebook account, as well as with a one-time password (OTP) or a normal password. The researcher tried the Google sign-in and noticed that the request sent to the server contained two pieces of information: a token from Google proving who had signed in, and the user's email address. The server checked either the token or the email address, but not that the two belonged to the same person. So the researcher changed the email address in the request to a friend's, and the server logged them in as the friend. Because email addresses could be found out from the login page, the researcher could have taken over any account, not just a friend's. The bug was marked fixed, the researcher re-tested and confirmed the fix, and a reward was given.

Introduction

This is a story about a very simple but serious security mistake. The mistake was in how the shopping website connected to Google's sign-in service. The researcher points out that when software is built by connecting other services (like Google sign-in), most security problems come from doing that connection incorrectly. Developers should not leave any configuration mistakes open when they add these services.

The login page

The researcher went to the login section of the shopping site. Like many sites, it offered "sign in with Google/Facebook" in addition to the usual OTP and password login. The login page looked like this:

Image for post
Login Page From the original on medium.com

Login Page

Trying Google sign-in

The researcher clicked the Google sign-in button and captured the HTTP request that the browser sent to the server. That request is shown below:

Image for post
Google Sigin with oauth2 From the original on medium.com

Google Sign in with oauth2

Looking at the request

The site uses OAuth2, a system that lets you sign in with Google without giving the site your Google password. The researcher looked at how the site's code (the client side, meaning the part running in the browser) implemented this. The raw HTTP request for the login is shown below:

Image for post
Login HTTP raw request From the original on medium.com

Login HTTP raw request

In the screenshot, you can see two parameters used for login verification: accessToken and login. The accessToken carries the Google OAuth2 sign-in token, and the login parameter carries the user's email address.

The researcher repeats: most security holes happen because of incorrect implementation when connecting third-party services. That is exactly what happened here: the OAuth2 service was added, but the implementation was weak and vulnerable.

The vulnerability

The researcher found that the code was only checking one of two things: either the accessToken from OAuth2 or the login email address. It did not check that the token and the email address belonged to the same person. So the researcher replaced the login value with the email address of a friend who had an account on the site. (The researcher also mentions that such email addresses could be found by user enumeration on the login page, which means trying different email addresses and seeing which ones are registered.) The response to that modified request is shown below:

Image for post
Change the login value to victim’s mail id From the original on medium.com

Change the login value to victim's mail id

Successful login

The server accepted the request and logged the researcher in as the friend. The researcher had access to the friend's complete profile.

Login Successful

This is how the researcher could take over any user's account by just knowing the login email address.

Report details

The researcher reported the bug to the company on 10 July 2018. The bug was marked fixed on 14 August 2018. The researcher re-tested and confirmed the fix on the same day. The reward was given on 5 October 2018.

Glossary

  • Account takeover: When an attacker gains access to someone else's account without permission.
  • API: A set of rules that lets one piece of software talk to another. Think of it as a waiter taking your order to the kitchen.
  • Client side: The part of a website that runs in your browser, as opposed to the server side that runs on the website's computers.
  • Cookie: A small piece of data stored in your browser by a website, often used to keep you logged in.
  • HTTP request: A message your browser sends to a server to ask for something, like a web page or to submit a form.
  • OAuth2: An open standard for access delegation, commonly used to let users sign in to a website using their Google, Facebook, or other accounts without sharing passwords.
  • OTP (One-Time Password): A password that is valid for only one login session or transaction, often sent via SMS or email.
  • Parameter: A piece of information sent in an HTTP request, usually as a name-value pair.
  • Token: A piece of data that represents proof of authentication or authorization, like a temporary key.
  • User enumeration: The process of discovering valid usernames or email addresses by observing differences in responses from a system.
  • Vulnerability: A weakness in a system that can be exploited to compromise security.

More by Avinash Jain

View all

29 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.