Security article
2FA Broken Logic
2FA Broken Logic: Exploit a broken 2FA flow to log in as carlos starting from a valid session for wiener:peter. • PortSwigger • Authentication • mfa, broken-logic
🎯 Objective
Exploit a broken 2FA flow to log in as carlos starting from a valid session for wiener:peter.
🧭 Scope / Setup
- Tooling: Burp Suite (HTTP history, Repeater, Intruder)
- Accounts:
wiener:peter(known), target to impersonate:carlos
🔎 Steps
- Log in as
wiener:peter. CapturePOST /login2containing the username parameter.
- Log out.
- Send
GET /login2to Repeater and change the account tocarlosto trigger a 2FA code for Carlos.
- Log back in as
wiener:peterand submit any 2FA code; sendPOST /login2to Intruder. - Set
verify=carlosand brute‑force the numeric OTP.

- Identify the 302 redirect among 200s → open in browser → authenticated as Carlos.

🧪 Why This Works
- 2FA generation and verification are decoupled from the authenticated user session.
- Lack of binding between OTP and the initiating user enables account pivot.
✅ Outcome
- Successful account takeover of Carlos due to flawed 2FA validation/binding.
🛡️ Mitigations
- Bind OTP to user and session; include nonce tied to login flow.
- Rate‑limit and lockout after repeated failures; monitor anomalies.
- Use short‑lived OTP with strict server‑side state checks.
📝 Notes
- Always verify OTP consumption is scoped to the original authentication transaction.