Skip to content
Account takeover Write-up Intermediate

The Weak Link in Two-Factor Authentication: Exploiting Reusable OTPs

The application allowed a one-time password (OTP) to be reused multiple times after it had been used once, and the OTP remained valid until a new one was generated. An attacker who obtained a valid OTP could replay it to obtain a JWT token and access the victim's account without the password.

tusharpuri6 Follow

Published on medium.com

During a recent penetration test, I was tasked with evaluating the authentication security of an application. These tests are always exciting because, in my experience, authentication mechanisms often hide subtle yet severe vulnerabilities.

Tusharpuri, 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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the server did not invalidate the OTP after its first successful use and did not enforce rate limiting on OTP verification, allowing replay and brute-force attacks.

Impact

An attacker could brute-force the OTP and reuse it to take over any user account, view personal information, and maintain access via the JWT token.

What the attacker needed

A valid email address registered in the application; ability to intercept and replay HTTP requests; no password required for the victim

The fix

The application should invalidate OTPs immediately after use, enforce strict rate limits on OTP entry, avoid exposing personal data in authentication responses, and require the password to be validated together with the OTP.

How it was found

  1. Log in with a test user account using email and password to trigger an OTP.
  2. Intercept the OTP verification request containing the email and OTP.
  3. Replay the same OTP verification request using a proxy tool.
  4. Observe that the server responds with the same JWT token and user data.
  5. Switch to a different machine and replay the same request to confirm the OTP is reusable.
  6. Use the obtained JWT token to access the victim's dashboard without re-entering the password.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A one-time password (OTP) is a code sent to your email or phone that should work only once. Here, the server did not invalidate the code after it was used, so the same code could be sent again and again. This means someone who saw or guessed the code could log in as the user even without the password.

What is Account takeover?

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

More by tusharpuri6

View all

1 more disclosed report, 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.