Skip to content
Account takeover Write-up Intermediate

My First Account Takeover

The staging site's signup flow checked the email against a separate database from the main site, so an email already registered on the main site was treated as new. An attacker who knew a victim's email could sign up on staging with that email and their own phone number, verify the OTP, and be logged into the victim's main-site account.

JAI NIRESH J Follow

Published on medium.com

Back with another juicy writeup. This time a Big one ..

JAI NIRESH J, 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. 5 min read.

Context

This write-up describes an account takeover (ATO) found on a staging subdomain of a web application. The researcher refers to the target as "Magma.com" because the bug had not been patched at the time of writing; the name is an alias, not the real domain.

The application has a signup and login flow that requires two identifiers: an email address and a phone number. The flow works like this:

  1. The user enters an email address.
  2. If the email already exists, the application asks for the password to log in.
  3. If the email does not exist, the user is asked to enter a phone number and verify an OTP to create an account and log in.

So creating an account requires both an email and a phone number. The main site is www.Magma.com, and the staging site is staging.Magma.com, which the researcher describes as an exact replica of the main website used for staging.

From the original on medium.com

Setup

The researcher was hunting on a program selected from Google dorking, based on scope and bounty. The tools in use were Burp Suite for manual testing and a small automation tool the researcher had written for subdomain enumeration, run in the background.

Preconditions for the finding:

  • An account already existed on the main site www.Magma.com, created with the researcher's own email and phone number.
  • The staging site staging.Magma.com was reachable and served the same signup and login flow.
  • The researcher had a second phone number available (a family member's number) that was not registered on the main site.

Finding it

The researcher first spent time on the main site looking for XSS and SQL injection with Burp Suite. Some responses looked promising, but none could be escalated to actual XSS. After around 3 to 4 days of testing, only a couple of P4 findings had come out of it.

The researcher then ran the subdomain enumeration tool. The results were described as raw, with no useful findings. Only around 4 subdomains were active, and takeover testing on the rest produced nothing.

The interesting subdomain was:

Text
staging.Magma.com

It was an exact replica of the original website, used for staging. The researcher had seen many subdomains with "staging" in front of them before but was not sure of their purpose, guessing they were used the same way as the original site but for testers and developers.

The same techniques tried on www.Magma.com were tried on staging.Magma.com. On that page the researcher found the following scope note:

OUT OF SCOPE :

Vulnerabilities on sites hosted by third parties unless they lead to a vulnerability on the main website.

Because of that note, testing for XSS, SQL injection and IDOR on staging.Magma.com was stopped as it would be of no use.

Exploitation

Step 1: Try the existing main-site account on staging

Since staging.Magma.com was an exact replica of www.Magma.com, it also had a signup and login page. The researcher tried to log in with the same account already created on the main site, entering the same email address.

Instead of a login form, the staging site showed a signup page, as if the email had never been registered in its database. That suggested the database storing emails and phone numbers for the login page was different for the two sites.

Step 2: Sign up on staging with the same email and a different phone number

The researcher entered the existing email on staging.Magma.com. As expected, the signup form appeared. For the phone number, the researcher did not use the number registered on the main site, but a different one (a family member's number). The application then asked for an OTP to verify that phone number.

Step 3: Verify the OTP and observe the result

After entering the OTP for the new phone number, the researcher was logged into the old account, the one created on the main website.

The registration and sign-in pages of the two sites were different, but past that point the account database was not separate: the staging site's email and phone number combination logged the user into the main website's account.

Step 4: The attack path

The researcher summarised the attack as follows. If an attacker knows the victim's email address, they navigate to:

Text
staging.Magma.com/login-signup

They enter the victim's email and their own phone number, verify the OTP sent to that number, and are then logged into the victim's account.

Root cause

The signup and login front ends of staging.Magma.com and www.Magma.com behaved as if they used separate stores of emails and phone numbers: an email registered on the main site was treated as unregistered on staging, which pushed the flow into signup. But the account records behind that flow were shared, so completing signup on staging with an existing email and a new phone number logged the user into the existing account..

In other words, the staging environment reused the production account database while exposing its own registration flow, and that flow logged the user into the existing account after OTP verification.. The scope note on staging excluded third-party hosted sites unless they led to a vulnerability on the main website.

Impact

An attacker who knows a victim's email address can take over that victim's account on the main website, without any password and without access to the victim's phone. The researcher summarised that knowing the victim's email is enough to log into the victim's account this way. The researcher notes that the bug had not been patched at the time of writing.

Fix

The report does not describe a fix. Based on the root cause, the staging environment should not share the production account store, or, if it must, the signup flow should refuse to attach a new phone number to an email that already has an account and should require proof of ownership of the existing account before any change.

Variants to test

  • Staging or test subdomains of other targets. Enumerate subdomains such as staging., test., dev. and uat. and try logging in with an account that exists on production. A positive result is a signup form appearing for an email that is already registered on the main site.
  • Shared identity stores across environments. Complete signup on the staging site with a production email and a fresh phone number. A positive result is being logged into the production account after OTP verification.
  • Email-first login flows. On any application that asks for the email first and then branches to login or signup, check whether the branch decision is made against a different store than the one used to create the session. A positive result is a mismatch between the branch taken and the account eventually logged into.
  • Phone-number binding on existing accounts. Where a phone number can be added during signup, test whether an existing account accepts a new phone number without verifying the old one. A positive result is a session for the existing account after verifying only the new number.

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

What happened, in plain words

A security researcher found a way to log into someone else's account on a website without knowing their password. The trick was to use a second, less-guarded copy of the same website.

Most websites have a main address, like www.example.com, that everyone uses. Many also keep a second copy, often called a staging site, where developers test changes before releasing them to the public. The staging copy usually looks identical to the main one, but it is meant for testing.

On this target, the main site and the staging site had separate signup and login pages, but behind those pages they shared the same list of user accounts. The researcher discovered that by signing up on the staging site with an email address that already belonged to an account on the main site, and a phone number that did not, the staging site logged the person straight into that existing account.. That means anyone who knows a victim's email address could take over the victim's account by using their own phone number.

The researcher calls the target "Magma.com" because the bug had not been patched when the report was filed; the name is the researcher's alias, not the real domain. That name is an alias, not the real domain.

From the original on medium.com

The signup and login flow

The application asks for two things to identify a person: an email address and a phone number. The flow works like this:

  1. The user enters an email address.
  2. If the email already exists, the application asks for the password to log in.
  3. If the email does not exist, the user is asked to enter a phone number and verify an OTP to create an account and log in.

An OTP (one-time password) is a short code, usually a few digits, sent by text message or email. You type it into the site to prove you control that phone number or mailbox. It is like a temporary key that only works once and expires quickly.

So creating an account requires both an email and a phone number. The main site is www.Magma.com, and the staging site is staging.Magma.com, which the researcher describes as an exact replica of the main website used for staging.

Setting up

The researcher was hunting on a bug bounty program. A bug bounty program is a scheme where a company invites outside people to look for security problems in its systems and pays them for reporting the issues responsibly. The researcher picked the program from results found through Google dorking, which means using specially crafted search queries to find pages or systems that companies may not have intended to expose publicly.

The tools in use were Burp Suite for manual testing and a small automation tool the researcher had written for subdomain enumeration, run in the background.

Burp Suite is a program that sits between your browser and a website. It lets you pause, inspect and change every request your browser sends and every response it receives. Think of it as a transparent proxy that lets you see and edit the conversation.

Subdomain enumeration is the process of finding all the smaller addresses that belong to a main domain. If the main site is example.com, subdomains might be blog.example.com, shop.example.com or staging.example.com. Each one is a separate host that may run different software or expose different features.

Before the finding, three things were already true:

  • An account already existed on the main site www.Magma.com, created with the researcher's own email and phone number.
  • The staging site staging.Magma.com was reachable and served the same signup and login flow.
  • The researcher had a second phone number available (a family member's number) that was not registered on the main site.

Finding it

The researcher first spent time on the main site looking for XSS and SQL injection with Burp Suite. Some responses looked promising, but none could be escalated to actual XSS. After around 3 to 4 days of testing, only a couple of P4 findings had come out of it.

XSS (cross-site scripting) is a bug where a website lets an attacker slip their own JavaScript code into a page that other people view. The code then runs in the victim's browser as if the website itself had written it. SQL injection is a bug where user input is pasted into a database query in a way that lets the attacker change the query itself, often to read or alter data they should not see. P4 is a severity rating used by many bug bounty platforms: P4 is the lowest level, meaning a low-impact issue.

The researcher then ran the subdomain enumeration tool. The results were described as raw, with no useful findings. Only around 4 subdomains were active, and takeover testing on the rest produced nothing.

Subdomain takeover is a specific bug where a subdomain points to a service that no longer exists, so an attacker can claim that service and serve their own content under the company's name. Testing for it means checking whether each subdomain still points to something the company controls.

The interesting subdomain was:

Text
staging.Magma.com

This is just a hostname: the address you would type into a browser to reach the staging copy of the site. It was an exact replica of the original website, used for staging. The researcher had seen many subdomains with "staging" in front of them before but was not sure of their purpose, guessing they were used the same way as the original site but for testers and developers.

The same techniques tried on www.Magma.com were tried on staging.Magma.com. On that page the researcher found the following scope note:

OUT OF SCOPE :

Vulnerabilities on sites hosted by third parties unless they lead to a vulnerability on the main website.

A scope note tells researchers which systems are fair game and which are not. This one says that problems on third-party hosted sites are not eligible, unless the problem also affects the main website. Because of that note, testing for XSS, SQL injection and IDOR on staging.Magma.com was stopped as it would be of no use.

IDOR (insecure direct object reference) is a bug where a website uses a simple identifier, such as a number in a URL, to decide which record to show, and does not check whether the person asking is allowed to see that record. Changing the number then shows someone else's data.

Exploitation

Step 1: Try the existing main-site account on staging

Since staging.Magma.com was an exact replica of www.Magma.com, it also had a signup and login page. The researcher tried to log in with the same account already created on the main site, entering the same email address.

Instead of a login form, the staging site showed a signup page, as if the email had never been registered in its database. That suggested the database storing emails and phone numbers for the login page was different for the two sites.

A database is where a website keeps its records: user accounts, orders, messages and so on. Think of it as a set of linked spreadsheets that the website reads from and writes to. If the staging site's login page looked at a different spreadsheet from the main site's, then an email known to the main site would look brand new to staging.

Step 2: Sign up on staging with the same email and a different phone number

The researcher entered the existing email on staging.Magma.com. As expected, the signup form appeared. For the phone number, the researcher did not use the number registered on the main site, but a different one (a family member's number). The application then asked for an OTP to verify that phone number.

This step is the heart of the test. The researcher entered the existing email with a different phone number and verified the OTP. If the site simply creates a new account, that is normal. If it attaches the new phone to the existing account, that is a problem.

Step 3: Verify the OTP and observe the result

After entering the OTP for the new phone number, the researcher was logged into the old account, the one created on the main website.

The registration and sign-in pages of the two sites were different, but past that point the account database was not separate: the staging site's email and phone number combination logged the user into the main website's account.

When you log in, the website usually gives your browser a session, which is a short-lived proof that you have already authenticated. It is often stored in a cookie, a small piece of data the browser keeps and sends back with every request, or in a token kept by the page. Think of it as a wristband you get at an event: once you have it, staff let you back in without checking your ID again. In this case, verifying the OTP on staging logged the researcher into the main site's account.

Step 4: The attack path

The researcher summarised the attack as follows. If an attacker knows the victim's email address, they navigate to:

Text
staging.Magma.com/login-signup

This is the address of the combined login and signup page on the staging site. The attacker enters the victim's email and their own phone number, verifies the OTP sent to that number, and is then logged into the victim's account.

The attacker enters the victim's email and their own phone number, verifies the OTP, and is logged into the victim's account.

Root cause

The signup and login front ends of staging.Magma.com and www.Magma.com behaved as if they used separate stores of emails and phone numbers: an email registered on the main site was treated as unregistered on staging, which pushed the flow into signup. But the account records behind that flow were shared, so completing signup on staging with an existing email and a new, attacker-controlled phone number bound the attacker's phone to the victim's existing account and issued a session for it.

In other words, the staging environment reused the production account database while exposing its own registration flow, and that flow did not check whether the email already belonged to an account before allowing a new phone number to be attached to it. The scope note on staging did not prevent this, because the resulting access was to the main website's account, which is exactly the exception the note carves out.

A useful comparison is a hotel with two reception desks. One desk is the main lobby, the other is a side desk for staff training. The side desk has its own sign-in sheet, so it does not recognise guests who checked in at the main lobby. But both desks write into the same room-booking system. If the side desk's sign-in sheet does not recognise the guest but both desks share the same booking system, naming the guest at the side desk can still get a stranger into that guest's room.

Impact

An attacker who knows a victim's email address can take over that victim's account on the main website, without any password and without access to the victim's phone. The only requirement is that the staging signup flow is reachable and that the attacker can receive an OTP on a phone number of their own. The researcher notes that the bug had not been patched at the time of writing.

Fix

The report does not describe a fix. Based on the root cause, the staging environment should not share the production account store, or, if it must, the signup flow should refuse to attach a new phone number to an email that already has an account and should require proof of ownership of the existing account before any change.

Variants to test

  • Staging or test subdomains of other targets. Enumerate subdomains such as staging., test., dev. and uat. and try logging in with an account that exists on production. A positive result is a signup form appearing for an email that is already registered on the main site.
  • Shared identity stores across environments. Complete signup on the staging site with a production email and a fresh phone number. A positive result is being logged into the production account after OTP verification.
  • Email-first login flows. On any application that asks for the email first and then branches to login or signup, check whether the branch decision is made against a different store than the one used to create the session. A positive result is a mismatch between the branch taken and the account eventually logged into.
  • Phone-number binding on existing accounts. Where a phone number can be added during signup, test whether an existing account accepts a new phone number without verifying the old one. A positive result is a session for the existing account after verifying only the new number.

Glossary

  • Account takeover (ATO): a bug that lets an attacker gain control of another person's account, usually without knowing their password.
  • Bug bounty program: a scheme where a company invites outside researchers to find and report security problems in exchange for a reward.
  • Burp Suite: a tool that sits between a browser and a website so you can inspect and modify every request and response.
  • Cookie: a small piece of data a website asks the browser to store and send back with later requests, often used to remember who you are.
  • Database: the organised store where a website keeps its records, such as user accounts.
  • Google dorking: using carefully crafted search queries to find pages or systems that were not meant to be publicly visible.
  • IDOR (insecure direct object reference): a bug where changing an identifier in a request lets you see or change someone else's data because the site does not check permission.
  • OTP (one-time password): a short code sent to a phone or email to prove you control it; it works once and expires.
  • P4: the lowest severity rating on many bug bounty platforms, meaning a low-impact issue.
  • Scope note: a statement from the program saying which systems and bug types are eligible for a reward.
  • Session: the state a website keeps after you log in, so it can recognise your later requests without asking for your password again.
  • SQL injection: a bug where user input changes the database query itself, often letting an attacker read or alter data.
  • Staging site: a copy of a website used by developers and testers to try changes before they reach the public site.
  • Subdomain: a smaller address under a main domain, such as staging.example.com under example.com.
  • Subdomain enumeration: the process of discovering all the subdomains that belong to a domain.
  • Subdomain takeover: a bug where a subdomain points to a service nobody controls any more, letting an attacker claim it and serve content under the company's name.
  • Token: a piece of data, similar in purpose to a cookie, that proves you are logged in and is sent with requests.
  • XSS (cross-site scripting): a bug where a site lets an attacker's JavaScript run in other users' browsers as if the site itself had written it.

More by JAI NIRESH J

View all

2 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.