Skip to content
Account takeover Write-up Intermediate

How a Flawed OTP Flow Led to Full Account Takeover

The passwordless login flow allowed an attacker to bypass the resend cooldown by going back and resubmitting the email, generating many valid OTPs that all remained active for 10 minutes. By brute-forcing the 6-digit code with IP rotation, an attacker could guess one of the many valid codes and take over any user's account.

medium.com

Published on medium.com

Otp

EL_SHE5, 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

The target was a major travel booking platform, assessed during a security review. The feature under examination was its passwordless authentication system: instead of a password, the site emails a One-Time Password (OTP) to the address supplied at login, and the user enters that code on a verification page to obtain a session.

The flow has two pages. On the first, the user submits an email address. The platform then redirects to a verification page and sends a standard 6-digit code. The verification page carries a "Resend OTP" button, and the platform protects it with a cooldown timer that increases each time the button is clicked.

From the original on medium.com

Setup

The assessment was carried out against the travel platform's passwordless login flow. The researcher used their own email address to walk the flow, and Burp Suite's Intruder to automate OTP submission against a victim's account. No specific versions, accounts or roles beyond a normal user of the login flow are described.

Finding it

The starting point was mapping the entire lifecycle of the token. Entering an email address on the login page produced a redirect to the verification page and a 6-digit code by email. Clicking "Resend OTP" several times showed the platform's defence: a cooldown timer that increased with every click.

That defence only covers the button on the second page. The question that followed was whether the first step could be replayed instead: ignore the verification page, press the browser's Back button, and submit the email address again from the very first step. If the backend generates a fresh OTP on that submission without applying the cooldown, the rate limit is bypassed entirely.

Exploitation

The vulnerability was a chain of three authentication logic flaws that had to work together:

  1. The cooldown bypass. The cooldown timer was attached only to the "Resend OTP" button on the second page. Navigating back to the first page and resubmitting the email forced the backend to generate a new OTP instantly, bypassing the intended rate limit.
  2. Missing OTP invalidation. Generating a new OTP should invalidate the old one. On this platform, earlier OTPs remained valid after new ones were issued, a state management failure.
  3. The 10-minute window. Every generated OTP remained valid for a full 10 minutes.

The consequence is a change in the arithmetic of brute force. Guessing a single 6-digit code in a few tries has near-zero odds. If an attacker can generate 5,000 valid codes that all work simultaneously for the next 10 minutes, the odds of randomly guessing at least one of those valid codes become very high.

Step 1: The setup

The researcher targeted a victim's email address and started the passwordless login flow for it.

Step 2: Flooding the tokens

Instead of entering a code, the researcher clicked "Back", resubmitted the email, and repeated the process rapidly. Because the backend did not restrict this flow, the server generated a large number of valid OTPs for the victim's account within a few minutes.

Step 3: The math shifts

With, say, 1,000 OTPs generated, the attacker no longer needs to guess one specific code: any of those 1,000 active codes will log into the account.

Step 4: The brute force

The OTP submission request was sent to Burp Suite's Intruder, which then guessed random 6-digit codes.

Step 5: Bypassing the IP block

The platform had a firewall that returned a 502 Bad Gateway when a single IP made too many wrong guesses. Rotating the IP address, for example by switching from Wi-Fi to a mobile hotspot or using a proxy pool, allowed guessing to continue.

Step 6: The result

Because the pool of valid OTPs was so large, very few guesses were needed before the automated tool hit a match. The server accepted the code and issued a fully authenticated session as the victim.

Root cause

The cooldown timer was attached only to the "Resend OTP" button on the second page, while resubmitting the email from the first page also generated a new OTP without it. The cooldown lives on the "Resend OTP" button on the verification page, while the first page's email submission also triggers OTP generation and is not subject to it. That is the cooldown bypass.

The second failure is state management: issuing a new OTP does not invalidate previously issued ones, so every code generated during the flood stays valid. The third is the lifetime: each code remains valid for 10 minutes, which is the window in which the accumulated pool can be used.

Together these turn a rate-limited single-secret guess into a search over a large set of simultaneously valid secrets. The firewall returned a 502 Bad Gateway when a single IP made too many wrong guesses; rotating the IP address allowed guessing to continue.

Impact

The result is a complete Account Takeover. A malicious actor only needs to know a victim's email address to hijack the account. Once inside, the attacker can view personal information, cancel existing travel bookings, and drain the user's digital wallet, cashback rewards and loyalty points. Because the attack bypasses the core authentication mechanism, the damage is total and immediate.

Fix

The report does not describe a fix or a retest. The flaws it identifies point to what should change: apply the rate limit to OTP generation on the server for every path that issues a code, not just the resend button; invalidate all previously issued OTPs whenever a new one is generated; and keep the validity window short. Rate limiting on wrong guesses should also not be defeatable by simply changing source IP.

Variants to test

  1. Replay the first step. On any passwordless flow, submit the email, then go back and resubmit it repeatedly. A positive result is a new code arriving each time with no cooldown applied.
  2. Check invalidation. Request a code, request a second one, then try the first. If the older code still authenticates, old OTPs are not being invalidated.
  3. Measure the window. Time how long an issued code remains usable. A long window combined with unlimited generation enlarges the valid pool.
  4. Look for other generation paths. Any endpoint that triggers an OTP (resend, change email, re-login) may bypass the cooldown that only guards one button.
  5. Test the guess limiter. Send wrong codes from one IP until blocked, then change IP and continue. A positive result is the block applying per IP only, with no account-level lockout.

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

What happened, in plain words

A security researcher was testing a travel booking website. This website lets you log in without a password: you type your email address, the site emails you a short number (a code), and you type that number into a page to get in. This kind of login is called passwordless authentication, and the emailed number is called a One-Time Password, or OTP.

The researcher found that the site had three small mistakes in how it handled these codes. Each mistake alone looks minor. Together they let someone who knows only your email address guess their way into your account. That is called an Account Takeover, or ATO: another person ends up logged in as you.

From the original on medium.com

Before going further, a few words that come up constantly:

  • Server / backend: the computer at the company that does the real work. Your browser is the front; the server is the back. When you click something, your browser sends a message to the server and the server decides what happens.
  • Request: that message from your browser to the server. Think of it as an order slip you hand to a waiter.
  • Response: what the server sends back, such as a web page, a redirect to another page, or an error.
  • Session: the state of being logged in. After you prove who you are, the server gives your browser a kind of wristband (a session token) so it recognises you on the next page without asking again.
  • Rate limit: a cap on how often you may do something, like a shop limiting each customer to one free sample per hour. It exists to stop people doing something thousands of times in a loop.
  • Brute force: guessing repeatedly and quickly, trying many possibilities until one works, instead of being clever.

The setup

The target was a major travel booking platform, tested during a security review. The feature examined was its passwordless login: instead of a password, the site emails a One-Time Password to the address given at login, and the user types that code on a verification page to obtain a session.

The flow has two pages:

  1. On the first page, you submit your email address.
  2. The platform redirects you to a verification page and emails you a standard 6-digit code. You type the code there.

The verification page has a "Resend OTP" button, and the platform protects it with a cooldown timer that increases each time the button is clicked.

The researcher used their own email address to walk through the flow, and a tool called Burp Suite, specifically its Intruder component, to automate submitting codes. Burp Suite is a program that sits between your browser and the website and lets you capture, inspect and replay the messages your browser sends. Intruder is the part of it that sends the same request over and over with different values filled in, which is exactly what you need for guessing. The report does not describe any specific software versions, accounts or user roles beyond a normal user of the login flow.

Finding it

The starting point was mapping the entire lifecycle of the token: where a code is created, how it travels, how long it lives, and what makes it stop working. A token here simply means the secret value that proves you are allowed in, in this case the 6-digit code.

Entering an email address on the login page produced a redirect to the verification page and a 6-digit code by email. Clicking "Resend OTP" several times showed the platform's defence: a cooldown timer that increased with every click. So the site was clearly trying to stop people from requesting endless codes.

But that defence only covers the button on the second page. The question that followed was whether the first step could be replayed instead: ignore the verification page, press the browser's Back button, and submit the email address again from the very first step. If the server generates a fresh OTP on that submission without applying the cooldown, the rate limit is bypassed entirely. This is the key idea of the whole report: the protection was attached to one button in the page, not to the action of creating a code on the server.

Exploitation

The vulnerability was a chain of three authentication logic flaws that had to work together. "Logic flaw" means the code runs without crashing, but the rules it enforces are wrong: the site does something it should not allow, rather than suffering a technical breakdown.

  1. The cooldown bypass. The cooldown timer was attached only to the "Resend OTP" button on the second page. Navigating back to the first page and resubmitting the email forced the server to generate a new OTP instantly, bypassing the intended rate limit.
  2. Missing OTP invalidation. Generating a new OTP should invalidate the old one. On this platform, earlier OTPs remained valid after new ones were issued, a state management failure. "State" is just the record of what is currently true, and "invalidation" means marking something as no longer usable, like cancelling an old key card when a new one is printed.
  3. The 10-minute window. Every generated OTP remained valid for a full 10 minutes.

The consequence is a change in the arithmetic of brute force. Guessing a single 6-digit code in a few tries has near-zero odds. If an attacker can generate 5,000 valid codes that all work simultaneously for the next 10 minutes, the odds of randomly guessing at least one of those valid codes become very high.

Why does the maths change so much? A 6-digit code has one million possible values, from 000000 to 999999. If only one of them is valid, a handful of guesses almost certainly misses. But if a thousand different codes are all valid at the same time, then a thousand out of those one million values work, so roughly one guess in a thousand succeeds. That is why the flood of codes matters more than the guessing itself.

Step 1: The setup

The researcher targeted a victim's email address and started the passwordless login flow for it. Nothing else was needed: no password, no access to the victim's mailbox, just the address.

Step 2: Flooding the tokens

Instead of entering a code, the researcher clicked "Back", resubmitted the email, and repeated the process rapidly. Because the server did not restrict this flow, the server generated a large number of valid OTPs for the victim's account within a few minutes.

The point was not that the victim reads them; the point is that every one of those codes is now sitting on the server, marked as valid for that account.

Step 3: The math shifts

With, say, 1,000 OTPs generated, the attacker no longer needs to guess one specific code: any of those 1,000 active codes will log into the account. The guessing target has changed from a single secret to a whole set of secrets.

Step 4: The brute force

The OTP submission request was sent to Burp Suite's Intruder, which then guessed random 6-digit codes. In plain terms: the researcher captured the message the browser sends when you type a code and press submit, handed it to the automation tool, and told the tool to send it again and again with a different 6-digit number each time.

Step 5: Bypassing the IP block

The platform had a firewall that returned a 502 Bad Gateway when a single IP made too many wrong guesses. Rotating the IP address, for example by switching from Wi-Fi to a mobile hotspot or using a proxy pool, allowed guessing to continue.

Two terms here. An IP address is the numeric address your device uses on the internet, roughly like a return address on an envelope; the server sees it and can decide to ignore envelopes from one address. A firewall is a filter that inspects incoming traffic and blocks what looks abusive. 502 Bad Gateway is an HTTP status code, a standard numbered message from a web server; here the firewall returned it when a single IP made too many wrong guesses. A proxy pool is a set of intermediary computers that forward your traffic, so the site sees their addresses instead of yours.

The block was tied to the address the guesses came from, so changing address was enough to carry on. Changing address was enough to carry on.

Step 6: The result

Because the pool of valid OTPs was so large, very few guesses were needed before the automated tool hit a match. The server accepted the code and issued a fully authenticated session as the victim. In other words, the researcher's browser was now logged in as the victim, with all the victim's access.

Root cause

The cooldown timer was attached only to the "Resend OTP" button on the verification page, while the first page's email submission also triggered OTP generation without it. The cooldown lives on the "Resend OTP" button on the verification page, while the first page's email submission also triggers OTP generation and is not subject to it. That is the cooldown bypass.

The second failure is state management: issuing a new OTP does not invalidate previously issued ones, so every code generated during the flood stays valid. The third is the lifetime: each code remains valid for 10 minutes, which is the window in which the accumulated pool can be used.

Together these turn a rate-limited single-secret guess into a search over a large set of simultaneously valid secrets. The firewall returned a 502 Bad Gateway when a single IP made too many wrong guesses; rotating the IP address allowed guessing to continue.

Impact

The result is a complete Account Takeover. A malicious actor only needs to know a victim's email address to hijack the account. Once inside, the attacker can view personal information, cancel existing travel bookings, and drain the user's digital wallet, cashback rewards and loyalty points. Because the attack bypasses the core authentication mechanism, the damage is total and immediate.

"Authentication" is simply the process of proving who you are. If that process can be walked around, everything behind it is exposed, which is why account takeover is treated as a severe outcome.

Fix

The report does not describe a fix or a retest. The flaws it identifies point to what should change: apply the rate limit to OTP generation on the server for every path that issues a code, not just the resend button; invalidate all previously issued OTPs whenever a new one is generated; and keep the validity window short. Rate limiting on wrong guesses should also not be defeatable by simply changing source IP.

Variants to test

These are the same checks applied to other sites, written so that anyone can follow them with a browser and a normal account of their own.

  1. Replay the first step. On any passwordless flow, submit the email, then go back and resubmit it repeatedly. A positive result is a new code arriving each time with no cooldown applied.
  2. Check invalidation. Request a code, request a second one, then try the first. If the older code still authenticates, old OTPs are not being invalidated.
  3. Measure the window. Time how long an issued code remains usable. A long window combined with unlimited generation enlarges the valid pool.
  4. Look for other generation paths. Any endpoint that triggers an OTP (resend, change email, re-login) may bypass the cooldown that only guards one button. An endpoint is a specific address on the server that performs one action, like a particular counter in a building.
  5. Test the guess limiter. Send wrong codes from one IP until blocked, then change IP and continue. A positive result is the block applying per IP only, with no account-level lockout.

Glossary

  • Account Takeover (ATO): a situation where an attacker gains control of someone else's account and can act as that person.
  • Authentication: the process of proving who you are, usually with a password, a code or another factor.
  • Backend / server: the remote computer that stores data and makes the real decisions; your browser only displays the results.
  • Brute force: guessing many possibilities quickly and automatically until one works.
  • Burp Suite: a tool that sits between a browser and a website to capture, inspect and replay the messages sent between them.
  • Cooldown timer: a waiting period enforced after an action, during which the action cannot be repeated.
  • Endpoint: a specific address on a server that performs one particular action.
  • Firewall: a filter that inspects network traffic and blocks what looks abusive.
  • Intruder: the part of Burp Suite that resends one request many times with different values, used for automated guessing.
  • Invalidation: marking something as no longer usable, such as cancelling an old code when a new one is issued.
  • IP address: the numeric address a device uses on the internet, visible to the sites it connects to.
  • Logic flaw: a mistake in the rules a program enforces, where it runs normally but permits something it should not.
  • One-Time Password (OTP): a short code, here 6 digits, sent to you and meant to be used once to log in.
  • Passwordless authentication: logging in without a password, typically by receiving a code by email or text.
  • Proxy pool: a set of intermediary computers that forward your traffic so the site sees their addresses rather than yours.
  • Rate limit: a cap on how often an action may be performed in a given period.
  • Redirect: an instruction from a server telling the browser to go to a different page.
  • Request: the message a browser sends to a server asking it to do something.
  • Response: what the server sends back, such as a page, a redirect or an error.
  • Session: the logged-in state, kept alive by a token the server gives your browser after you authenticate.
  • State management: how a program keeps track of what is currently true, such as which codes are still valid.
  • Token: a value that stands in for proof of identity or permission, such as a session token or an OTP.
  • 502 Bad Gateway: an HTTP status code meaning a server or gateway could not complete the request; here it appeared when the firewall blocked repeated wrong guesses.
  • Verification page: the second page of the login flow, where the emailed code is entered.

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.