> For the complete documentation index, see [llms.txt](https://kruknight.gitbook.io/daemon-of-hacking/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kruknight.gitbook.io/daemon-of-hacking/writeups/portswigger-labs/authentication/2fa-simple-bypass.md).

# 2FA simple bypass

## Lab description

<figure><img src="https://2387347627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F47EuhANOY5sIuDySBX97%2Fuploads%2F6mrCI6dVfia8DzyfbnIh%2Fimage.png?alt=media&amp;token=3363ae0c-cf3c-4726-93a8-d33b2e51f39f" alt=""><figcaption></figcaption></figure>

## Walkthrough

### **Step 1: Login to your account**

Use the given credentials `wiener:peter` to log in. Once you enter the correct username and password, the application redirects you to a page asking for a 2FA code.

<figure><img src="https://2387347627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F47EuhANOY5sIuDySBX97%2Fuploads%2Fq5YWwBSBkC7W8IvwFkow%2Fimage.png?alt=media&amp;token=e9817e46-cc0f-488c-8179-14cd8b99a759" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2387347627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F47EuhANOY5sIuDySBX97%2Fuploads%2F7TJNb7ywIAZbWoB6Q3ro%2Fimage.png?alt=media&amp;token=8cbe351f-776e-484f-89ea-37e74f9cf603" alt=""><figcaption></figcaption></figure>

### **Step 2: Bypass the 2FA mechanism**

After entering the correct One-Time Password (OTP) for the `wiener` account, you gain full access to your account. However, our goal is to bypass the 2FA for the victim's account (`carlos:montoya`).

<figure><img src="https://2387347627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F47EuhANOY5sIuDySBX97%2Fuploads%2FrI6VFWEw9BCTLz7LCOTR%2Fimage.png?alt=media&amp;token=da831eb5-d226-4056-816d-0c6964e98c34" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2387347627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F47EuhANOY5sIuDySBX97%2Fuploads%2FjRHDCzxg1dJaGvwFE3ft%2Fimage.png?alt=media&amp;token=0cf79362-62b5-418a-a092-9377cab90bb2" alt=""><figcaption></figcaption></figure>

### **Step 3: Exploit the 2FA bypass vulnerability**

Log in using the victim's credentials `carlos:montoya`. Instead of entering the OTP, manually navigate to the `/my-account` page by modifying the URL in your browser. This will bypass the 2FA mechanism.

For example:

* Replace the 2FA page URL (`/login2`) with `/my-account`.

### **Step 4: Verify the exploit**

After modifying the URL, you are successfully logged into Carlos's account without needing to provide the OTP. This confirms the 2FA bypass vulnerability.

<figure><img src="https://2387347627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F47EuhANOY5sIuDySBX97%2Fuploads%2F6NY4aBUfObxE6TIK8Smf%2Fimage.png?alt=media&amp;token=30dace45-348b-4a9f-a8a1-11ec9d229b06" alt=""><figcaption></figcaption></figure>
