Skip to content
Account takeover Write-up Intermediate

Bypassing 2FA via State Overwrite: A Tale of Logic Flaws and WAF Evasion

The 2FA setup endpoint returned a fresh TOTP secret even when 2FA was already enabled, and calling it overwrote the active secret in the backend. An attacker holding a hijacked session could fetch a new secret, generate a valid code from it, and disable 2FA entirely.

HackerMD Follow

Published on medium.com

How an unprotected API endpoint allowed complete removal of Two-Factor Authentication using a desynchronized state.

Hacker MD, 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 2FA setup endpoint did not check whether 2FA was already active before issuing and storing a new secret, so the stored secret was overwritten.

Impact

An attacker with a stolen session could strip the victim's 2FA and then change the password or move funds, leading to full account takeover; the program itself rated this as Informative because a stolen session was required.

What the attacker needed

A hijacked victim session; requests matching the browser fingerprint

The fix

The setup endpoint should refuse to issue a new secret while 2FA is active, and deactivation should only be validated against the currently active, verified secret.

How it was found

  1. Enable 2FA on a test account and note the active secret.
  2. Send a GET request to the 2FA setup endpoint while 2FA is enabled.
  3. Observe that the response contains a new, unverified secret.
  4. Generate an OTP from the new secret.
  5. Send a POST request to the set-2FA endpoint with that OTP and usage set to false.
  6. Observe that 2FA is now disabled.

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.

Two-factor authentication (2FA) is a second check, usually a short code from a phone app, on top of a password. Here the server handed out a new code-generating secret even though the account already had one, and it replaced the old secret with the new one. So anyone who already had the victim's logged-in session could switch off the extra protection without ever touching the victim's phone.

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 HackerMD

View all

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