Authorization disclaimer. This walkthrough is limited to the intentionally vulnerable PortSwigger Web Security Academy lab linked below. Test only systems you own or are explicitly authorized to assess.
Overview
The password-reset link is built using attacker-influenced host metadata. The lab uses that behavior to redirect the reset token to the exploit server.

Lab objective/setup
The supplied credentials, candidate lists, email client, and exploit server are used only inside this Academy instance to reproduce the authentication-flow evidence shown below.
What I observed
The reset service accepts X-Forwarded-Host when constructing the emailed URL. A reset request for Carlos using the exploit-server host sends his token to that server when he follows the link.


Why it is vulnerable
Trusting unvalidated forwarding or host headers when constructing security links lets an attacker choose where sensitive reset URLs point.
Walkthrough in the authorized PortSwigger lab
Confirm the normal Wiener reset email, then submit Carlos’s forgot-password request with the exploit server in X-Forwarded-Host. Read the token from the exploit-server access log, place it in the real lab reset URL, set a new password, and sign in as Carlos.
1 | POST /forgot-password HTTP/2 |


Verification
The final capture shows the Academy marking the password reset poisoning via middleware exercise as solved after the documented request sequence. No testing was performed outside the isolated lab.

Impact and defensive lesson
Authentication controls must bind identity, challenge state, reset tokens, and retry counters to server-side transactions. Return uniform failures, rate-limit by both account and trusted client signals, and use random revocable persistent-session tokens rather than credential-derived values.