⚙️ 08. — 2FA Broken Logic
The 2FA verification endpoint trusted a client-controlled cookie to decide which user's code was being checked, so an attacker could point it at another account. By first requesting the 2FA page with the victim's username in that cookie, a fresh code was generated for the victim, and the attacker then brute-forced the four-digit code to log in as them.
medium.com
Published on medium.com
3. 🖱️ In Burp → Proxy → HTTP history → find this POST /login2 → Send to Intruder
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 derived the identity for 2FA verification from a client-controlled cookie instead of the server-side session, and it also generated codes for any username supplied that way.
Impact
An attacker could log in as another user without knowing their password or 2FA code, because the four-digit code could be brute-forced with no rate limiting.
What the attacker needed
A valid account on the site; ability to intercept and modify requests; victim has an account
The fix
The 2FA target user should be taken only from the server-side session set after the password step, codes should only be generated for that session, and attempts should be rate limited.
How it was found
- Log in as the normal user and complete 2FA, then inspect the POST /login2 request in Burp history.
- Send the GET /login2 request to Repeater, change the verify cookie to the victim's username, and send it to generate a fresh code for the victim.
- Log in again as the normal user, submit a wrong 2FA code, and send the resulting POST /login2 request to Intruder.
- In Intruder, change the verify cookie to the victim's username and mark the mfa-code value as the payload position.
- Configure a Numbers payload from 0 to 9999 with four digits and start the attack.
- Find the row with a 302 response, use 'Show response in browser', and open the account page.
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.
After you type your password, many sites ask for a short extra code (two-factor authentication, or 2FA) sent to your email or phone. This site stored a small piece of data in your browser, called a cookie, saying whose code should be checked, and it believed whatever the cookie said. An attacker could change that cookie to name another user, make the site send that user a new code, then try every possible four-digit code until one worked.
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.