Basic password reset poisoning

2 min read Easy Portswigger
HTTP Host header
Contents

On this page

The lab

here is how portswigger describes it

This lab is vulnerable to password reset poisoning. The user carlos will carelessly click on any links in emails that he receives. To solve the lab, log in to Carlos's account. You can log in to your own account using the following credentials: wiener:peter. Any emails sent to this account can be read via the email client on the exploit server.

the password reset email builds its link from the Host header of the request that triggers it, instead of a fixed server-side domain. so whatever host we put in the request is the host carlos's reset link points at. we trigger a reset for carlos but set the Host to our exploit server, his email then carries a reset link to our domain with his token in it, and because he clicks anything, the token lands in our access log. we take his token, splice it into a genuine reset URL, and set his password.

why the host header poisons the reset#

the flaw is that the application trusts the incoming Host header to construct an absolute URL for the reset link. that header is attacker-controlled, it is just another request field, yet the token, which is the one secret that proves ownership of the account, is sent out in a link built around it. when we set Host to our server and ask for carlos's reset, the back-end still generates his valid token but wraps it in a URL pointing at us.

Step 1 - map the reset flow#

we go to the login page and use Forgot your password? to request a reset for our own account. on the exploit server's email client we receive the reset email and notice the URL carries a temp-forgot-password-token query parameter.

1

Step 2 - find the trigger request#

we click the link, get prompted for a new password, and reset it. studying the HTTP history we see POST /forgot-password triggers the reset email and carries the target username as a body parameter. we send this request to Repeater.

2

Step 3 - confirm the Host header is reflected#

in Repeater we change the Host header to an arbitrary value and the reset still succeeds. back on the email server, the new email's URL contains our arbitrary Host value in place of the real domain, so the link host is attacker-controlled.

3
4

Step 4 - poison carlos's reset#

we set the Host header to our exploit server's domain (YOUR-EXPLOIT-SERVER-ID.exploit-server.net) and change the username parameter to carlos, then send the request.

5

Step 5 - capture carlos's token#

on the exploit server we open the access log and find a GET /forgot-password request whose temp-forgot-password-token parameter holds carlos's reset token, logged the moment he clicked the link.

6

Step 6 - reset carlos's password#

we copy the genuine reset URL from our own first email, visit it in the browser, and replace our token with carlos's. we set his password to whatever we like and log in as carlos.

7

with this, the lab is solved!