🗂️PortSwigger Lab Writeup: 2FA Broken Login

🎯 Objective
The objective of this lab is to exploit an multi-factor authentication weakness where the app does not implement any brute-force protection on multi-factor authentication page. The goal is to bypass the authentication of carlos and log in to the account.
- Lab URL:
https://portswigger.net/web-security/authentication/multi-factor/lab-2fa-broken-logic - Category: Authentication
- Difficulty: Practitioner
🧪 Exploitation Steps
🕵️Step 1: Observe the Website
- Firstly open the lab URL in your browser, and observe what it is about and how it works.


- At first glance, the website seems to be a blogging website with a login page. In the lab description, it is mentioned that we need to bruteforce the password of user -
carlosand log in to account.
📝Step 2: Log in as wiener
- Now we will first observe how multi-factor authentication works by logging in as
wienerfor which we have access to mails. - Enter the credentials
wiener:peterin login page and send the request.
- Now, we are being redirected to
/login2page for entering OTP sent on mail. - Open the Email client, to access the
wienermails and retrieve the OTP.
- Enter the
OTP - 1660on 2FA page to complete the login.
- After login completion, we are redirected to the user account page -
/my-account?id=wiener
🧑💼Step 3: Log in as carlos
- Now send the
GET /login2request from HTTP history to Repeater throughCtrl + R
- Change the cookie
verify:wienertoverify:carlosand send the request to generate the 2FA code.
- Now send the
POST /login2request from HTTP history to Intruder throughCtrl + I
- Change the cookie
verify:wienertoverify:carlosto crack the 2FA code forcarlos - Add the marker on mfa-code value and set the attack type to Sniper.

- In payloads section, set the payload type to Brute forcer
- Set the character set to
0123456789and Min/Max length to 4 as mfa code is of 4 digit.
- After configuring everything, start the attack.

- In all the payloads, you will see a unique response
302 Foundwhich means we have successfully cracked the MFA code forcarlos - Enter the credentials
carlos:montoyain login page and send the request.
- Now change the URL from
/login2to/myaccount?id=carlos - Hence, we are now successfully being logged in as
carloswithout completing 2FA. - Now, Right-click on this request and select Show response in browser. Copy the URL and load it in the browser.

- And Finally, the Lab is solved.
🧠 Conclusion
- This lab involves a broken 2FA implementation, where the
verify:<username>cookie and OTP challenge handling are trusted client-side and the/login2endpoint does not enforce server-side session binding or rate-limiting for MFA attempts. - Since the application accepts/relies on a client-supplied challenge identifier and lacks OTP brute-force protection, an attacker can tamper the cookie and repeatedly guess codes for another account.
- By changing
verify:wiener→verify:carlosand using Intruder to brute-force the 4-digit OTP (detecting success via a302 Foundredirect), we bypassed 2FA and accessedcarlos’s account.