The “Middleman” Attack: Hijacking Accounts via Password Reset
The backend built password reset links using the client-supplied X-Forwarded-Host header instead of a fixed domain. An attacker could point that header at their own server, so a victim's reset token was delivered to the attacker, who then used it to take over the account.
Published on mukibas37.medium.com
Friend link: link — non member can access
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application derived the base URL for reset emails from the user-controllable X-Forwarded-Host header rather than a hardcoded server-side configuration value.
Impact
An attacker could take over another user's account, but only if the victim clicks the poisoned link in the reset email.
What the attacker needed
Attacker-controlled server; victim clicks the reset link; vulnerable header handling
The fix
The base URL for reset links should be hardcoded in server-side configuration, or header values should be checked against a strict whitelist of allowed domains.
How it was found
- Request a password reset for your own account on the forgot-password page.
- Capture the request and change the email to the victim's, adding an X-Forwarded-Host header pointing at a server you control.
- Forward the request and note the 200 response.
- Check your server's access log to collect the reset token sent to the victim.
- Open the real reset page and use the stolen token to set a new password.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When you ask a site to reset your password, it emails you a link containing a secret code (a token). The site has to decide which domain name to put in that link. Here it asked the incoming request instead of using its own fixed name, so an attacker could make the link point at their own server and receive the victim's secret code.
What is Account takeover?
Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.