Hello! In our last lesson, we dug into session fixation, where an attacker can hijack a user's session by forcing them to authenticate into a session the attacker already controls. We saw how this stems from the application's failure to create a new session ID upon login.
Today, we'll shift our focus to another critical authentication workflow that is a prime target for attackers: the password reset process. This lesson directly addresses the learning outcome: Test password reset workflows for logic flaws, such as token leakage or parameter tampering, to achieve account takeover.
A flawed password reset mechanism can completely undermine an application's security, allowing an attacker to walk right through the front door. We will explore two primary ways this happens:
- Token Leakage via Parameter Tampering: Tricking the application into sending a legitimate password reset token to an attacker.
- Predictable Tokens: Exploiting weak token generation logic to guess or deduce a victim's reset token.
Let's begin by understanding what can go wrong.
1. The Anatomy of a Password Reset Flaw
A secure password reset process is designed to ensure only the legitimate owner of an account can reset its password. This typically involves generating a unique, high-entropy, single-use, and short-lived token that is sent to the user's registered email address.
Vulnerabilities appear when any part of this process is mishandled. An attacker's goal is to either intercept the token intended for the victim or to predict the token before the victim can use it. Today, we'll focus on the logic flaws that make this possible.
2. Attack Vector 1: Leaking the Token via Parameter Tampering
This class of attack involves manipulating parts of the HTTP request to trick the server's back-end logic. The server generates a perfectly valid token but is deceived about where to send it or how to construct the link containing it.
Host Header Poisoning
One of the most common ways to achieve this is through Host Header Poisoning. Many web applications use the Host header from the incoming HTTP request to construct absolute URLs, including password reset links sent in emails. If the application doesn't validate this header, an attacker can substitute their own domain.
The attack flow is simple:
- The attacker requests a password reset for the victim's account.
- They intercept this request using a proxy like Burp Suite.
- They modify the
Hostheader to point to a server they control (e.g.,attacker.com). - The application receives the request, generates the reset token, and constructs the reset link using the malicious
Hostheader:http://attacker.com/reset?token=.... - This email is sent to the victim's email address, but the link points to the attacker's server. If the victim clicks it, their browser sends the valid reset token directly to the attacker.
A more direct variation is when the application uses the Host header not just for the link, but to determine which email server to talk to. By changing it, the reset email itself can be routed to an attacker's mail server.
This video provides a great hands-on demonstration of this attack.
Password Reset Poisoning | Account Takeover in 5 Minutes
The video 'Password Reset Poisoning | Account Takeover in 5 Minutes' by whoamitang provides a practical demonstration of this attack using Burp Suite and the OWASP WebGoat vulnerable application.
Watch from 01:50 to 04:23. The key sections show how to intercept the request (01:50), modify the Host header to an attacker-controlled mail server (02:28), and use the captured token to complete the account takeover (03:25).
This vulnerability often arises because developers assume the Host header is a reliable piece of information, but like any user-supplied input, it must be validated. For a more detailed textual explanation and examples of the HTTP requests involved, you can refer to the "Host Header Poisoning" section of the VaaData article on password reset vulnerabilities.
Tampering with Other Parameters
The Host header is not the only user-controllable parameter that can be abused. Some applications explicitly use a parameter in the request body (e.g., in a JSON object) to construct the base URL for the reset link.
This is a design flaw, but it happens. For a practical look at this, let's explore an article that details a real-world exploit.
Password Reset Vulnerabilities and Security Best Practices
The article 'Password Reset Vulnerabilities and Security Best Practices' from VaaData provides several excellent examples. We'll focus on a specific case where a manipulatable baseurl parameter led to account takeover.
Read the section titled 'Password Reset Link Hijacking'. Pay close attention to how the application used a baseurl parameter in a JSON request and how the pentesters bypassed the server's validation using a specially crafted payload (attacker.com\@serveur_dorigine.com) to confuse the URL parser. This is a great example of deep-diving into application logic.
As you can see from this example, even when developers attempt to validate user input, clever manipulation can bypass weak checks. Your computer science background will help you appreciate how different parsers and libraries can interpret the same string in different ways, leading to security flaws.

3. Attack Vector 2: Predicting the Token
What if you can't trick the application into sending you the token? The next best thing is to predict it. This becomes possible if the token is not generated with sufficient randomness (entropy). A common anti-pattern is using predictable values, like the server's timestamp, as a primary source for token generation.
If two password reset requests are processed at the exact same millisecond, and the token generation algorithm relies on that timestamp, both requests might end up with the exact same token.
This leads to a classic attack:
- The attacker sends two password reset requests at the same time: one for their own account and one for the victim's account.
- If the server processes them simultaneously, it generates the same token for both accounts.
- The attacker receives the reset link for their own account via email.
- They take the token from their own link and use it to reset the password for the victim's account.
The following video gives a quick and clear overview of this concept.
This password reset bug is too dangerous...
The video 'This password reset bug is too dangerous...' by DeadOverflow explains this time-based token vulnerability in a very accessible way.
Watch from 00:29 to 01:48. This part explains how a timestamp-based token can be predictable and then demonstrates sending two requests simultaneously to receive the same token for different users.
Hands-On: Exploiting a Time-Sensitive Vulnerability
Now, let's look at how to execute this in a real-world scenario using Burp Suite. PortSwigger, the creators of Burp, have a lab specifically for this type of time-sensitive vulnerability. While you won't be doing the lab interactively right now, understanding the solution steps is crucial.
Lab: Exploiting time-sensitive vulnerabilities
The solution guide for the PortSwigger lab 'Lab: Exploiting time-sensitive vulnerabilities' provides a step-by-step methodology for exploiting a password reset function with weak, time-based tokens.
Read the 'Solution' section of the lab. Focus on these key steps: Study the behavior: Observe that multiple requests in sequence get different tokens. Bypass the per-session locking restriction: This is a critical insight. Many servers process requests from the same session sequentially. To achieve true parallel processing, the attacker uses two different session cookies. Confirm the vulnerability: By sending requests with different session cookies in parallel, they observe that when response times are identical, the generated tokens are also identical. Exploit: Finally, they send two parallel requests for different usernames (wiener and carlos) and use the token received in their own email to reset Carlos's password.
The key takeaway from this lab is the methodology: you must ensure your requests are being processed concurrently, not sequentially. Bypassing session-based locking by using different session cookies for each request is a vital technique for testing this and other race condition vulnerabilities.
Test your understanding!
You are testing a password reset function. You send a request for victim@example.com and intercept it. The request body is a JSON object: {"username": "victim@example.com"}. You notice the Host header is api.secure-app.com.
You try changing the Host header to your own domain, but the application rejects the request. However, you discover that you can add a new key to the JSON object: {"username": "victim@example.com", "notification_url": "http://attacker.com"}. When you send this, you see a request hit your server at attacker.com containing the victim's password reset token.
What kind of vulnerability have you found, and why is this a critical flaw?
Show answer
You have found a server-side logic flaw that leads to password reset token leakage. It's a form of parameter tampering, similar to Host Header Poisoning, but exploits a different user-controllable input (notification_url).
This is a critical flaw because it allows for a full account takeover. By simply adding a parameter to the request, you've forced the application's back-end to send the sensitive reset token to a destination you control, completely bypassing the intended security mechanism of emailing it to the registered user.
Conclusion
Password reset functionality is a gateway to a user's account, and as we've seen, it can have many implementation flaws. A successful attack here almost always leads to a critical-impact finding.
Key Takeaways:
- Always Test the Reset Workflow: It's a high-value target for bug bounties and penetration tests.
- Tamper with Everything: Scrutinize every part of the password reset request that you control. This includes the
Hostheader and any parameters in the URL, body, or other headers that could influence how the reset link is generated. - Race for the Token: Test for predictability. Use Burp Suite's parallel request features (like in Repeater tab groups) to send simultaneous requests for your account and a target's account to see if you can force a token collision. Remember to use different session cookies to bypass sequential processing.
- The Goal is the Token: Whether you leak it or predict it, getting your hands on a valid reset token for another user's account is the objective.
Next Lesson Preview:
We've now covered flaws in session management and password resets. What happens when an application adds another layer of security? In our next lesson, we will begin to answer that by learning how to identify and exploit insecure multi-factor authentication (MFA) implementations for bypass.