Skip to content
Account takeover Write-up Intermediate

Story of a Beautiful Account Takeover.

During signup email verification, the application trusted the email address supplied in the request rather than binding it to the OTP session, so changing the email to a victim's address returned the victim's token and logged the attacker into their account. An attacker who knew a registered user's email address could take over that account without any interaction from the victim.

Ambush Neupane Follow

Published on medium.com

Hello Everyone, I am Ambush Neupane from Nepal. I hope you all are doing great.

Ambush Neupane, 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. 6 min read.

Context

Ambush Neupane found this issue on a Dutch government site. The site had a public profile feature, and users could choose to make their email address public. That detail matters for the whole story: the attack needs only a victim's email address, and on this site email addresses were not necessarily secret.

The feature involved is the signup flow. After signing up, the site sent a one-time password (OTP) to the email address for verification. The account was then queued for an administrator's permission, and only after that approval could the account be used. The forgot password feature worked in a similar way: a 6 digit verification code was sent to the email address, and the request that validated it carried an OTP, an email address and some kind of token.

The author's own summary of the outcome: the OTP was used for email verification after signup, and by changing his own email address to the victim's email address in the request during the email verification step, account takeover was possible.

Setup

  • A normal registered account on the site, created through signup and approved by an administrator after a few days.
  • Burp to capture and modify requests.
  • No special role or privilege is described. The precondition for the attack is knowledge of the victim's email address, which the public profile feature could expose.
  • The author notes that finding and understanding the endpoint took a long time, partly because each attempt required entering a new address and verifying it with an OTP.

Finding it

After the account was approved and usable, the author explored the site's functionality and then focused on the login and forgot password features. In the forgot password flow, a 6 digit code was sent to the email address. He entered a random OTP, captured the request in Burp, and saw that an OTP, an email address and some kind of token were passed in the request.

He then worked through a list of bypass ideas against the forgot password endpoint. None of them worked:

  1. Checked whether the OTP leaked in the response or was sent along with the request. It was not.
  2. Left the OTP value blank and forwarded the request, on the theory that some applications validate the OTP only when a value is present. It did not work.
  3. Removed the OTP parameter from the request entirely. This produced an error.
  4. Passed an array of emails, ["attacker.[@xyz](http://twitter.com/xyz).com","victim.[@xyz](http://twitter.com/xyz).com"], to see whether the same OTP would be sent to both accounts. It was not.
  5. Entered the correct OTP but changed the email address to the victim's. Unsuccessful: the OTP appeared to be tied to the email address.
  6. Tried to brute-force the code, but rate limiting was present.
  7. Passed an array of several OTPs including the valid one, a technique he had read about elsewhere. It did not work.
  8. Sent many requests at once to the forgot password endpoint to check the randomness of the OTP, and received an error saying too many requests, so there was probably a limit in place.

With the password reset feature exhausted, he moved to the signup function, which also sent an OTP for verification. Creating an account with an already registered email produced an "Email already Exists" error. He then tried adding %00, a space at the end and a space at the beginning of the email, and none of these ideas succeeded.

Exploitation

Step 1: reach the OTP validation request in signup

He forwarded the signup request and the site asked him to enter the OTP sent to his address. The following request was made for validating the OTP.

From the original on medium.com

Step 2: try the same OTP tricks on the signup endpoint

He played with the OTP in the signup validation request the same way he had in the forgot password endpoint, without success. He also tried a response manipulation technique to bypass the check, and that did not work either. The response of these unsuccessful attempts is shown below.

From the original on medium.com

Step 3: swap the email address

In the request above he noticed an email address present. He changed his own address, [redacted], to the victim's address, [redacted]. The response he got is shown below; the values in it were modified for privacy reasons.

I have modified the values for Privacy reasons. From the original on medium.com

Something happened: the response contained information about the victim. On its own this is not much of a leak, because the public profile feature already exposed that information to anyone viewing the profile.

Step 4: forward and land in the victim's account

He forwarded the request, and in the next request he saw the victim's token. Forwarding that request logged him into the victim's account. He then tested it for verification and confirmed that logging into the account with only the email information was possible.

In his words, he could take over any account he wanted with the victim's email address and without user interaction. He made a POC video and sent the report to the Dutch government.

Root cause

The signup OTP validation request carried the email address alongside the OTP, and the server trusted the email address supplied in that request when deciding which account to verify and which session or token to issue. In the forgot password flow, changing the email address after entering the correct OTP failed, and the OTP appeared to be tied to the email address. In the signup validation step, replacing the email address with the victim's returned information about the victim, and the next request showed the victim's token. The exact server-side logic is not described in the report, so the precise mistake is likely a missing binding between the OTP, the email address it was issued for and the account being verified.

The defences that did exist did not cover this path. Rate limiting and the OTP being tied to the email address were observed in the forgot password endpoint, and the signup endpoint was a separate flow where the same protections did not prevent the swap. The OTP value itself was never guessed or brute-forced.

Impact

An attacker who knows a victim's email address could take over that account without any interaction from the victim. On this site the email address was not necessarily secret, because users could make it public through the public profile feature. The author states that any registered account could be taken over this way. The report does not describe what an attacker could do with a taken-over account beyond being logged in as the victim.

Fix

The report says the vulnerability is fixed now, and that the programme decided to send the author a T-shirt as swag. It does not describe the change that was made. The fix that follows from the root cause is to bind the OTP to the email address it was issued for and to the account being verified, and to ignore any email address supplied by the client at validation time, taking it instead from the server-side state created when the OTP was issued.

Variants to test

  • On other signup and email verification flows, capture the OTP validation request and replace the email address with another registered address. A positive result is a response containing the other user's data or a token that logs you in as that user.
  • Try the same swap in forgot password and login OTP validation. A positive result is a reset or login for the substituted address without knowing its OTP.
  • Compare how the OTP is bound across flows on the same site: if one endpoint rejects the swap, check whether another endpoint that issues OTPs handles the email address differently.
  • Look for public profile or directory features that expose registered email addresses, since they turn this bug from a targeted attack into one that can be run against many accounts.
  • Test whether the OTP parameter can be omitted, left blank or sent as an array alongside a valid value, and whether rate limiting applies to the signup validation endpoint as it does to forgot password. A positive result is validation succeeding without a correct OTP for the target address.

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

A security researcher named Ambush Neupane found a serious flaw on a Dutch government website. The flaw let anyone who knew a registered user's email address log into that user's account, without needing the password, without needing the code that gets emailed to the real owner, and without the real owner having to click anything.

The trick was simple once you see it. When you sign up on the site, the site emails you a short code (a one-time password, or OTP) to prove the email address is yours. You type that code into a form, and your browser sends a request to the site containing the code and your email address. The researcher discovered that the site trusted the email address in that request. Swapping his own email address for someone else's returned information about that person, and the next request showed their token.

Before finding this, the researcher spent a long time trying the same kind of tricks on the forgot password feature, and every one of them failed. That contrast is the heart of the story: the same idea worked in one place and not in another, and understanding why is what makes the bug interesting.

Some background you need first

What a website actually is, from your browser's point of view

When you use a website, your browser is constantly sending small messages to a computer somewhere else (the server) and getting messages back. Each message is called a request, and each reply is called a response. A request says what you want ("show me this page", "log me in with these details"), and the response says what happened ("here is the page", "wrong password", "here is your login token").

Most of the time you never see these messages, because the browser builds them for you from the forms you fill in. But they are just text, and anyone with the right tool can look at them, pause them, and change them before they are sent. That is the entire basis of the kind of testing described here.

What an API is

An API (application programming interface) is the part of a website that accepts these requests and answers them with data rather than with a pretty page. A useful comparison: a restaurant. The dining room (the web page) is what you see, but the kitchen (the API) is where the actual work happens. You do not walk into the kitchen yourself; you give your order to a waiter, and the waiter carries it back and forth. When you fill in a login form, your browser is the waiter, and the API is the kitchen. The security question in this story is whether the kitchen checks the order properly or just trusts whatever the waiter wrote on the slip.

What a token is

A token is a long string of random-looking characters that the server gives you after you log in. Think of it like a cloakroom ticket: you hand over your coat (your password), and you get a ticket. From then on, you do not show your coat again; you show the ticket, and the staff fetch your coat. If someone else gets hold of your ticket, they can collect your coat, because the staff only check the ticket, not who is holding it.

On websites, the token is usually stored in a cookie, which is a small piece of data your browser keeps for a particular site and sends back with every request to that site. If an attacker can obtain a victim's token, they can send it with their own requests and the server will treat them as the victim. That is exactly what happened at the end of this story.

What an OTP is

An OTP (one-time password) is a short code, often six digits, that is sent to your email or phone and can only be used once. It is a second proof that you are who you say you are: even if someone has your password, they also need the code that only arrives in your inbox. Banks use them, and so do many signup and password reset forms.

What "account takeover" means

Account takeover (often shortened to ATO) is exactly what it sounds like: an attacker gains control of someone else's account. It is one of the most serious kinds of web vulnerability, because once you are inside an account you can often do everything the real owner can: read their data, change their settings, and sometimes lock them out.

What Burp is

Burp (Burp Suite) is a tool that sits between your browser and the website, like a postbox that lets you open every letter before it is delivered. You can read each request, change it, and send it on. The researcher used it to capture the requests in this story and to modify them. You do not need to install anything to follow the story, but knowing what Burp does makes the steps make sense.

What "rate limiting" and "brute-forcing" mean

Brute-forcing means guessing a secret by trying every possibility. A six-digit code has a million possible values, which sounds like a lot, but a computer can try them quickly. Rate limiting is the defence: the server counts how many attempts come from one place in a short time and starts refusing them. Think of a cash machine that swallows your card after three wrong PINs. It does not make the PIN harder to guess; it just makes guessing impractical.

The setup

To follow along, the researcher had:

  • A normal registered account on the site, created through the signup form and approved by an administrator after a few days.
  • Burp, to capture and modify requests.
  • No special role or privilege. The only thing needed to attack someone else was their email address.

That last point is important. On many sites an email address is semi-private, so an attacker would need to find it first. On this site, users could choose to make their email address public through a public profile feature. So the email address was not a secret at all, and the attack could be aimed at any user whose profile showed one.

The author also notes that finding and understanding the endpoint took a long time, partly because every attempt required entering a new address and verifying it with an OTP. In other words, the work was slow and repetitive, not clever.

Finding it

Once the account was approved and usable, the researcher explored the site's features and then focused on two of them: login and forgot password.

In the forgot password flow, the site sent a six-digit code to the email address. He entered a random OTP (deliberately wrong), captured the request in Burp, and saw that the request carried three things: an OTP, an email address, and some kind of token. That is a useful observation in itself: the request tells the server which account it is about, and the server has to decide whether to believe it.

He then worked through a list of bypass ideas against the forgot password endpoint. A bypass here means getting past the OTP check without knowing the correct code. None of them worked:

  1. He checked whether the OTP leaked in the response or was sent along with the request. It was not. The idea: sometimes a server accidentally includes the secret in its reply, or echoes it back, which would make the check pointless.
  2. He left the OTP value blank and forwarded the request, on the theory that some applications only validate the OTP when a value is present. It did not work. The idea: a missing value is not the same as a wrong value, and some code checks for one but not the other.
  3. He removed the OTP parameter from the request entirely. This produced an error. The idea: if the server does not expect the parameter, it may skip the check; here it did not.
  4. He passed an array of emails, ["attacker.[@xyz](http://twitter.com/xyz).com","victim.[@xyz](http://twitter.com/xyz).com"], to see whether the same OTP would be sent to both accounts. It was not. The idea: if the server processes a list of addresses and only checks the first, the code might go to the attacker while the account being changed is the victim's.
  5. He entered the correct OTP but changed the email address to the victim's. Unsuccessful: the OTP appeared to be tied to the email address. The idea: if the code is not bound to the address it was sent to, you could use your own code on someone else's account.
  6. He tried to brute-force the code, but rate limiting was present. The idea: a six-digit code is only safe if guessing is slow.
  7. He passed an array of several OTPs including the valid one, a technique he had read about elsewhere. It did not work. The idea: some code compares only the first element of a list, so a list containing the right value in the right position can slip through.
  8. He sent many requests at once to the forgot password endpoint to check the randomness of the OTP, and received an error saying too many requests, so there was probably a limit in place. The idea: if codes were predictable (for example, sequential), guessing would be much easier, so checking how they are generated matters.

With the password reset feature exhausted, he moved to the signup function, which also sent an OTP for verification. Creating an account with an already registered email produced an "Email already Exists" error. He then tried adding %00, a space at the end and a space at the beginning of the email, and none of these ideas succeeded. The idea behind those tricks: %00 is a null byte, a character that some programs treat as the end of a string, so [redacted]%[redacted] might be read as one address by one part of the system and a different address by another. Leading and trailing spaces are similar: one layer may trim them and another may not, so the two layers disagree about which account is meant.

Exploitation

Step 1: reach the OTP validation request in signup

He forwarded the signup request, and the site asked him to enter the OTP sent to his address. The following request was made for validating the OTP.

From the original on medium.com

The image shows the captured request that the browser sends when you submit the OTP during signup. In plain terms, this is the moment the site asks "is this code correct for this email address?", and the request is the question itself. The researcher's goal at this point was simply to see the question clearly, because you cannot tamper with what you cannot see.

Step 2: try the same OTP tricks on the signup endpoint

He played with the OTP in the signup validation request the same way he had in the forgot password endpoint, without success. He also tried a response manipulation technique to bypass the check, and that did not work either. Response manipulation means changing the server's reply on its way back to the browser, for example turning a "failure" into a "success", to see whether the browser or a later step trusts the reply blindly. The response of these unsuccessful attempts is shown below.

From the original on medium.com

The image shows the server's reply to those failed attempts. The point of showing it is that the server was rejecting the tampering, which is what a well-built check should do. At this stage the researcher had no reason to think the signup flow was weaker than the forgot password flow.

Step 3: swap the email address

In the request above he noticed an email address present. He changed his own address, [redacted], to the victim's address, [redacted]. The response he got is shown below; the values in it were modified for privacy reasons.

I have modified the values for Privacy reasons. From the original on medium.com

This is the turning point. The email address in the request now pointed at the victim. The server's reply contained information about the victim. On its own that is not much of a leak, because the public profile feature already exposed that information to anyone viewing the profile. But it was a signal: the server had accepted the substituted address and was now talking about the victim's account rather than rejecting the request outright.

Step 4: forward and land in the victim's account

He forwarded the request, and in the next request he saw the victim's token. Forwarding that request logged him into the victim's account. He then tested it for verification and confirmed that logging into the account with only the email information was possible.

In his words, he could take over any account he wanted with the victim's email address and without user interaction. He made a POC video and sent the report to the Dutch government. A POC (proof of concept) is a short demonstration, usually a video or a set of screenshots, that shows the bug actually working, so the people who need to fix it can see it rather than just read about it.

Why it worked

The signup OTP validation request carried the email address alongside the OTP, and the server trusted the email address supplied in that request when deciding which account to verify and which session or token to issue. In other words, the server asked the browser "which account is this?" and believed the answer.

In the forgot password flow, changing the email address after entering the correct OTP failed, and the OTP appeared to be tied to the email address. In the signup validation step, replacing the email address with the victim's returned information about the victim, and the next request showed the victim's token. The exact server-side logic is not described in the report, so the precise mistake is likely a missing binding between the OTP, the email address it was issued for, and the account being verified.

The defences that did exist did not cover this path. Rate limiting and the OTP being tied to the email address were observed in the forgot password endpoint, and the signup endpoint was a separate flow where the same protections did not prevent the swap. The OTP value itself was never guessed or brute-forced.

A useful comparison: imagine a hotel receptionist who asks for your room number and then hands over the key to whatever number you say, without checking it against the name on the booking. The lock on the door is fine. The problem is at the desk.

What an attacker could do with it

An attacker who knows a victim's email address could take over that account without any interaction from the victim. On this site the email address was not necessarily secret, because users could make it public through the public profile feature. The author states that any registered account could be taken over this way. The report does not describe what an attacker could do with a taken-over account beyond being logged in as the victim.

How it was fixed

The report says the vulnerability is fixed now, and that the programme decided to send the author a T-shirt as swag. It does not describe the change that was made. The fix that follows from the root cause is to bind the OTP to the email address it was issued for and to the account being verified, and to ignore any email address supplied by the client at validation time, taking it instead from the server-side state created when the OTP was issued.

In plain terms: the server should remember, on its own side, which address it sent the code to, and it should never ask the browser to remind it.

Things worth trying on other sites

If you are learning and want to look for the same class of bug on sites you are allowed to test, these are the directions the story points to:

  • On other signup and email verification flows, capture the OTP validation request and replace the email address with another registered address. A positive result is a response containing the other user's data or a token that logs you in as that user.
  • Try the same swap in forgot password and login OTP validation. A positive result is a reset or login for the substituted address without knowing its OTP.
  • Compare how the OTP is bound across flows on the same site: if one endpoint rejects the swap, check whether another endpoint that issues OTPs handles the email address differently. This is exactly the comparison that led to the finding here.
  • Look for public profile or directory features that expose registered email addresses, since they turn this bug from a targeted attack into one that can be run against many accounts.
  • Test whether the OTP parameter can be omitted, left blank or sent as an array alongside a valid value, and whether rate limiting applies to the signup validation endpoint as it does to forgot password. A positive result is validation succeeding without a correct OTP for the target address.

Glossary

  • API: the part of a website that receives requests and returns data, as opposed to the pages you see in the browser.
  • Account takeover (ATO): an attacker gaining control of someone else's account.
  • Brute-force: guessing a secret by trying many possibilities in turn.
  • Burp (Burp Suite): a tool that sits between your browser and a website so you can read, pause and modify requests and responses.
  • Bypass: getting past a security check without satisfying it, for example passing an OTP check without knowing the code.
  • Cookie: a small piece of data a browser stores for a site and sends back with each request to it, often used to hold a login token.
  • Endpoint: a specific address on a server that accepts a particular kind of request, such as the one that validates an OTP.
  • Forgot password flow: the sequence of pages and requests a site uses when you ask to reset a forgotten password.
  • Null byte (%00): a character some programs treat as the end of a string, which can make two layers of a system disagree about a value.
  • OTP (one-time password): a short code sent to your email or phone that proves you control it and can be used only once.
  • POC (proof of concept): a demonstration, often a video or screenshots, showing a vulnerability actually working.
  • Public profile: a page on a site that shows information about a user to anyone, sometimes including their email address if the user chooses.
  • Rate limiting: a server refusing further attempts after too many in a short time, which makes guessing impractical.
  • Request: the message your browser sends to a server asking it to do something.
  • Response: the message a server sends back, saying what happened or returning data.
  • Response manipulation: changing a server's reply on its way back to the browser, to see whether something later trusts it blindly.
  • Signup flow: the sequence of pages and requests used to create an account, often including email verification.
  • Swag: free merchandise a bug bounty programme sends as a thank-you.
  • Token: a long random string a server issues after login, which the browser sends back to prove who it is; anyone holding it is treated as that user.
  • User interaction: anything the victim has to do for an attack to work, such as clicking a link; this attack needed none.

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.