Skip to content
Account takeover Write-up Beginner

“Forgot Password” to “I Own Your Account” via One Header

The application built password-reset links from the attacker-controllable Host header (or override headers such as X-Forwarded-Host) instead of a fixed configured domain. An attacker could therefore make the reset email point at their own server and capture the victim's secret reset token, leading to account takeover.

medium.com

Published on medium.com

Here’s a bug that turns “I forgot my password” into “I own your account” — and it hinges on one lazy assumption developers make constantly: the Host header tells me my own domain. It doesn't.

Nitin yadav, on medium.com

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 backend derived its own base URL for reset links from the request's Host or X-Forwarded-Host header rather than a hardcoded configuration value.

Impact

If the victim clicks the poisoned link, or the token leaks via the Referer header, the attacker could capture the reset token and take over the account; the text notes some cases only reflect the host without leaking the token.

What the attacker needed

A test account to receive the email; victim clicks the poisoned link (or Referer leak)

The fix

The reset link should be built from a fixed, configured base URL rather than from request headers.

How it was found

  1. Trigger the forgot-password flow for a test account and intercept the request.
  2. Change the Host header to an attacker domain, or keep the real host and add an X-Forwarded-Host override, or send duplicate Host headers.
  3. Check the reset email to see whether the link now points at the attacker domain.
  4. Capture the token on the attacker listener and use it on the real reset endpoint to set a new password and log in.

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 forget a password, the site emails you a special link containing a secret code. This site built that link using a value the visitor's own request supplies (the Host header), so an attacker could swap in their own web address and receive the secret code instead. With that code they can set a new password and take over the account.

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.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.