> 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-13.md).

# lab-13

## Password Reset Broken Logic

**Difficulty:** Apprentice

### Lab Description

This lab's password reset functionality is vulnerable due to broken token validation logic.

**Objective:** Reset Carlos's password, then log in and access his account page.

**Credentials:** `wiener:peter` · Victim's username: `carlos`

### Root Cause

The application generates a token for resetting a password, but does not validate that token against the specific username when the new password is submitted. This means an attacker can initiate a reset for their own account to obtain a valid token, then submit the password-change request with a different username — and the application blindly accepts it, leading to full account takeover.

### Exploitation

1. Go to the forgot-password page and submit `username: wiener`.
2. Go to **Exploit Server → Email** and click the reset link in `wiener`'s email.
3. Intercept the password-change request in Burp and find:

   ```
   POST /forgot-password?temp-forgot-password-token=...
   ```
4. Send this request to Repeater.
5. Update the `username` parameter to `carlos` and set the `password` field to any value you choose.
6. Send the request — a `302` response confirms the password has been changed.
7. Log in as `carlos` using the new password to complete the lab.

### Lesson Learned

A password reset token must always be validated against the specific username it was issued for. The application should reject any request where the submitted token does not match the account being modified — it should never accept a token issued for one user to reset another user's password.


---

# 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-13.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.
