Skip to content
Account takeover Write-up Intermediate

Bypassing OTP via reset password

The reset password API response leaked a live authentication token for the user's account. An attacker could use this token to call API methods, including disabling OTP, and then log in without the OTP code.

Ahmed Cj Follow

Published on medium.com

{{media:0}}

Ahmed, 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 private bug bounty program, referred to in the write-up as target.com. The product was an application whose interface was a front end for a single API: every function in the app, without exception, was directly related to that one API. The feature at the centre of the report is the account settings page, which offered a one-time password (OTP) option by phone number.

The vulnerability described here is not a flaw in the OTP check itself. It is a consequence of how the reset password method was implemented in the API: resetting the password through the email flow set a new live token for the account and leaked that token in the response. That token could then be used to call any method in the account over the API without signing in to the app interface, including the request that disables OTP.

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

Setup

The researcher was doing recon against the target and noticed that all functions were tied to one API, so starting with function scanning made sense. While checking the account settings, the OTP option by phone number was found, turned ON, and the session was logged out. The tools used were an intercepting proxy (the write-up mentions turning intercept ON and sending requests to the repeater) and access to the account email inbox to open the reset password link. No versions or specific tool names are given.

Finding it

After enabling OTP and logging out, the researcher logged in directly and tried to attack the OTP itself. Two avenues were tested:

  1. Rate limit bypassing and other bugs related to OTP. There was a rate limit implemented in the API itself and it could not be bypassed.
  2. Bypassing OTP by resetting the password via the email address. The app asked for the new password to be used to sign in again, and then for the 6 digit OTP code sent via SMS, so this path did not bypass the check at that point.
Image for post
Rate limit mechanism response From the original on medium.com

Rate limit mechanism response

The next step was to inspect every request and its response. With intercept ON, the reset password button response was checked first and nothing interesting was found there. The reset password link was then opened from the account email; the token in the link was complex and could not be brute-forced.

Exploitation

Step 1: Complete the reset password flow and inspect the response

The reset password link was opened, a new password was inserted, and the change my password button was pressed. The response to that request was checked. The reset password API method set a new live token for the account and leaked the token in the response.

Image for post
Token leakage in response From the original on medium.com

Token leakage in response

With that live token, every method in the account could be used via the API without the need to sign in to the app interface.

Step 2: Find the request that stops OTP

Rather than stopping at full API access, the researcher looked for a way to stop the OTP without signing in. Checking the account settings revealed the API request that stops OTP.

Step 3: Disable OTP with the leaked token

The request that stops OTP was entered in the repeater and sent using the live token from the reset password response. OTP was stopped via the API, and the researcher then logged in to the app interface without needing to insert the OTP code.

Image for post
Disable OTP API request From the original on medium.com

Disable OTP API request

Root cause

The write-up attributes the issue to a wrong application of the reset password method via API, which leads to the leakage of the user live token in the response. The reset password API method set a new live token for the account and leaked it in the response. Because every function in the app was backed by that same API, the leaked token allowed every method in the account to be used via the API without signing in to the app interface.

The rate limit on the OTP endpoint did hold, and the token inside the reset link was complex enough that brute force was not viable. Neither defence addressed the token leak in the reset response.

Impact

An attacker who can complete the reset password flow for an account, which requires access to the account email inbox, obtains a live token for that account and can use every method in the account via the API without signing in to the app interface. In the researcher's own demonstration this included the request that disables OTP, after which the account could be opened without inserting the OTP code. In the researcher's demonstration, the second factor was removed after completing the reset flow via the account email address. The report does not describe any attempt against another user's account; the demonstration was performed on the researcher's own account.

Fix

The write-up does not state what the program changed. Based on the described cause, the reset password API response should not contain a live account token, and any token issued by the reset flow should not grant access to account methods such as disabling OTP without a fresh authentication step.

Variants to test

  1. Reset password response inspection: complete a password reset on your own account with intercept on and read the full response body and headers. A positive result is a session token, bearer token or similar credential that the API accepts on other endpoints.
  2. Token scope check: take any token returned by the reset flow and call account settings endpoints, especially security settings such as disabling OTP or changing the email address. A positive result is a successful state change without a password or OTP prompt.
  3. OTP disable request replay: capture the request that turns OTP off while signed in, then replay it with only the token from the reset flow. A positive result is a success response and OTP no longer required at sign-in.
  4. Email change without confirmation: the researcher also found, in the same target, that the email address could be changed to any email without confirmation. Try changing the account email to an address you control and check whether a confirmation step is enforced. A positive result is the change taking effect with no verification sent to the old address.
  5. Rate limit on OTP verification: send repeated wrong OTP codes and observe the responses.

A closing note from the write-up: the email change bug was never reported, and when the researcher used the company's help email address as the new address, the account was disabled and the bug fixed. Report your bugs.

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 website (called target.com in the write-up) that offered a common safety feature: a one-time password, or OTP. When you switch OTP on, the site asks for your normal password and then, on top of that, for a short code (here, 6 digits) sent to your phone by SMS. The idea is that even if someone steals your password, they still cannot get in without your phone.

The researcher found a way around that second check. The weakness was not in the OTP code itself. It was in the "forgot my password" feature. When you reset your password through your email, the site's behind-the-scenes machinery (its API) sent back a live token, which is a kind of digital pass that proves you are signed in. That pass was handed out in the reply to the reset request. With that pass, the researcher could call any function of the account directly through the API, without going through the normal sign-in screen at all. That included the request that switches OTP off. Once OTP was off, the account could be opened with just the password, no code needed.

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

The researcher reported it on 7 July and got a first response the same day. It was marked as a duplicate, meaning someone else had already reported the same issue.

Some words you will need

Before the steps make sense, here are the ideas behind them, explained from scratch.

  • API: the set of doors a website's own pages use to talk to its servers. Think of a restaurant: the menu and the waiter are the website you see, and the kitchen is the API. The waiter carries your order to the kitchen and brings back the food. Many apps are just a pretty front end, and every button you press sends an order to the same kitchen.
  • Request and response: a request is a message your browser sends ("please reset my password"), and the response is the message the server sends back ("done", plus any data).
  • Token: a long random string that acts like a wristband at an event. Once the server gives you one, you show it on later requests instead of typing your password again. Anyone who has the wristband can get in, so it must be kept secret.
  • OTP (one-time password): a short code, valid once, usually sent by SMS. It is a second lock on the door, on top of your password.
  • Rate limit: a cap on how many times you can try something in a period. It is like a cash machine that swallows your card after three wrong PINs, so guessing thousands of codes is not practical.
  • Brute force: trying every possible value until one works. A 6 digit code has a million possibilities, which is why rate limits matter.
  • Intercepting proxy and repeater: tools that sit between your browser and the server. The proxy lets you pause (intercept) each message and read it. The repeater lets you take one captured request and send it again and again, changing small parts, to see what happens.
  • Recon: short for reconnaissance, the early looking-around phase where you map what the site does.

Setting the scene

The target was a private bug bounty program, which means the company invited selected researchers to test it and report problems. The product was an app whose visible interface was a front end for a single API: every function in the app, without exception, went through that one API. That matters because a weakness in the API affects everything the app can do.

The feature at the centre of the report is the account settings page, which offered an OTP option delivered by SMS. When it is on, the app asks for a 6 digit code sent by SMS after you sign in with your password.

The researcher was doing recon and noticed that all functions were tied to one API, so starting by scanning the functions for bugs made sense. While checking account settings, the OTP option by phone number was found, switched ON, and the session was logged out. The tools used were an intercepting proxy (the write-up mentions turning intercept ON and sending requests to the repeater) and access to the account email inbox to open the reset password link. No versions or specific tool names are given.

Trying to break the OTP directly

After enabling OTP and logging out, the researcher signed in again and attacked the OTP itself. Two avenues were tested:

  1. Rate limit bypassing and other OTP bugs. There was a rate limit implemented in the API itself, and it could not be bypassed. In plain terms: the cash machine really did swallow the card, so guessing codes was not an option.
  2. Bypassing OTP by resetting the password via the email address. The app asked for the new password to sign in again, and then for the 6 digit OTP code sent via SMS. So this path did not get around the check at that point: the reset flow still ended at the OTP gate.
Image for post
Rate limit mechanism response From the original on medium.com

Rate limit mechanism response

The image is captioned as the rate limit mechanism response.

Looking at every message

The next step was to inspect every request and its response. This is the patient part of the work: with intercept ON, you read what the app actually sends and receives, rather than trusting what the screen shows. The reset password button response was checked first, and nothing interesting was found there.

The reset password link was then opened from the account email. The token in the link was complex and could not be brute-forced. That is a good design: the link contains a long random value, so guessing it is hopeless.

Getting in through the reset flow

Step 1: Finish the reset and read the reply

The reset password link was opened, a new password was inserted, and the change my password button was pressed. Then the response to that request was checked. The reset password API method set a new live token for the account and leaked the token in the response.

Image for post
Token leakage in response From the original on medium.com

Token leakage in response

The image is captioned as the token leakage in the response. This is the heart of the bug: the server handed back a working pass in a reply that should only have said "password changed".

With that live token, every method in the account could be used via the API without the need to sign in to the app interface. In restaurant terms, the kitchen handed the waiter a master key along with the receipt, and the researcher could now walk into any room.

Step 2: Find the request that stops OTP

Rather than stopping at full API access, the researcher looked for a way to stop the OTP without signing in. Checking the account settings revealed the API request that stops OTP. The reasoning: the goal is not just to prove access, it is to show the concrete harm, which is removing the second lock.

Step 3: Switch OTP off with the leaked token

The request that stops OTP was entered in the repeater and sent using the live token from the reset password response. OTP was stopped via the API, and the researcher then logged in to the app interface without needing to insert the OTP code.

Image for post
Disable OTP API request From the original on medium.com

Disable OTP API request

The image is captioned as the disable OTP API request.

Why it worked

The write-up attributes the issue to a wrong application of the reset password method via API, which leads to the leakage of the user live token in the response. The reset password flow is supposed to authenticate the user and let them set a new password. Instead, the API response handed back a live session token for the account.

Because every function in the app was backed by that same API, a token issued by the reset flow was as good as a signed-in session. Because every function in the app was backed by that same API, the leaked token allowed every method in the account to be used via the API without signing in to the app interface. The rate limit on the OTP endpoint did hold, and the token inside the reset link was complex enough that brute force was not viable. Neither defence addressed the token leak in the reset response.

What it means in practice

An attacker who can complete the reset password flow for an account, which requires access to the account email inbox, obtains a live token for that account and can use every method in the account via the API without signing in to the app interface. In the researcher's own demonstration this included the request that disables OTP, after which the account could be opened without inserting the OTP code.

In the researcher's demonstration, the second factor was removed after completing the reset flow via the account email address. The report does not describe any attempt against another user's account; the demonstration was performed on the researcher's own account.

How it should be fixed

The write-up does not state what the program changed. Based on the described cause, the reset password API response should not contain a live account token, and any token issued by the reset flow should not grant access to account methods such as disabling OTP without a fresh authentication step.

Things you can try on your own account

These are the same checks, written so you can follow them with a browser and a proxy tool. Only ever do this on accounts you own or on programs that explicitly allow it.

  1. Read the reset response. Complete a password reset on your own account with intercept on and read the full response body and headers. A positive result is a session token, bearer token or similar credential that the API accepts on other endpoints.
  2. Check what the token can do. Take any token returned by the reset flow and call account settings endpoints, especially security settings such as disabling OTP or changing the email address. A positive result is a successful state change without a password or OTP prompt.
  3. Replay the OTP disable request. Capture the request that turns OTP off while signed in, then replay it with only the token from the reset flow. A positive result is a success response and OTP no longer required at sign-in.
  4. Try changing the email without confirmation. The researcher also found, in the same target, that the email address could be changed to any email without confirmation. Try changing the account email to an address you control and check whether a confirmation step is enforced. A positive result is the change taking effect with no verification sent to the old address.
  5. Test the OTP rate limit. Send repeated wrong OTP codes and observe the responses.

A closing lesson from the write-up

The email change bug was never reported. When the researcher used the company's help email address as the new address, the account was disabled and the bug fixed. The lesson the author draws is simple: report your bugs, first things first.

Glossary

  • API: the set of doors a website's own pages use to talk to its servers; the kitchen behind the visible menu.
  • Bug bounty program: an arrangement where a company invites researchers to test its systems and report problems, sometimes for a reward.
  • Private program: a bounty program open only to selected researchers, not the public.
  • Recon: short for reconnaissance, the early phase of mapping what a site does and how it is built.
  • Request: a message your browser or tool sends to a server, such as "reset my password".
  • Response: the message a server sends back, which may contain data as well as a status.
  • API method: one specific operation the API offers, such as "reset password" or "disable OTP".
  • Token: a long random string that acts as proof you are signed in, like a wristband; it must be kept secret.
  • Live token: a token the server currently accepts, as opposed to an expired or invalid one.
  • Session: the period during which the server treats you as signed in, usually tracked by a token or cookie.
  • Cookie: a small piece of data a site stores in your browser to remember you between requests.
  • OTP (one-time password): a short code, valid once, usually sent by SMS, used as a second lock on top of a password.
  • Second factor: an extra proof of identity beyond a password, such as an OTP code.
  • SMS: text message sent to a phone number.
  • Rate limit: a cap on how many attempts are allowed in a period, to stop guessing.
  • Intercepting proxy: a tool that sits between your browser and the server and lets you pause and read each message.
  • Intercept ON: the proxy setting that pauses each message so you can inspect it.
  • Repeater: a proxy feature that lets you take one captured request and resend it, with small changes, to see what happens.
  • Response body: the main content of a server's reply, as opposed to its headers.
  • Headers: the labelled lines at the top of a request or response that carry metadata.
  • Endpoint: a specific address on the API that performs one function.
  • Duplicate: a report of a bug that someone else already reported, so it is closed without a separate reward.
  • Root cause: the underlying reason a bug exists, as opposed to its visible symptom.
  • Impact: what an attacker could actually do because of the bug.
  • Replay: sending a captured request again, unchanged or with small edits.
  • State change: a lasting change to an account, such as switching a setting off or changing an email address.

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.