> For the complete documentation index, see [llms.txt](https://ganesha-hk.gitbook.io/cybersecurity-writeups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ganesha-hk.gitbook.io/cybersecurity-writeups/port-swigger-authentication-labs/lab-7.md).

# lab-7

## 2FA Simple Bypass

**Difficulty:** Apprentice

### Lab Description

This lab's two-factor authentication can be bypassed entirely. You already have valid credentials for the victim's account but do not have access to their 2FA verification code.

**Your credentials:** `wiener:peter`\
**Victim's credentials:** `carlos:montoya`

**Objective:** Access Carlos's account page.

### Solution

**Step 1 — Map the authentication flow**

Log in as `wiener` and complete the full login process, including the 2FA step (retrieve the code from the email client). Observe the endpoint sequence:

| Step                  | Endpoint       |
| --------------------- | -------------- |
| Password verification | `POST /login`  |
| 2FA pin entry         | `POST /login2` |
| Authenticated page    | `/my-account`  |

**Step 2 — Bypass the 2FA step**

Log out and begin logging in as `carlos:montoya`. Intercept the traffic in Burp and forward the `POST /login` request normally — Carlos's password is valid, so this succeeds.

When the browser is redirected to `/login2` (the 2FA pin page), instead of forwarding that request, **drop it** and manually navigate the browser directly to `/my-account`.

The server grants access — Carlos's account page loads without a valid 2FA code ever being submitted.

**Step 3 — Why this works**

The 2FA is poorly implemented on the backend. After a successful password check, the server sets a partially-authenticated session that grants access to `/my-account` regardless of whether the 2FA step was completed. The 2FA page is essentially decorative — the backend never enforces that the pin was actually verified before granting access to protected pages.

### Conclusion

True 2FA requires the server to maintain state confirming *both* factors were successfully verified before granting access. Here the server only checked the password and ignored whether the security pin step was completed, making the second factor trivially skippable.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ganesha-hk.gitbook.io/cybersecurity-writeups/port-swigger-authentication-labs/lab-7.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
