Skip to content
Account takeover Write-up Beginner

**Password reset link stays valid after requesting a new one (old token not invalidated on reissue)**

Requesting a new password reset link does not invalidate previously issued, unused reset links, so multiple tokens remain valid at the same time. An attacker holding an old unused link could still use it to set a new password and take over the account until that token is used or expires.

Joko Purwanto Follow

Published on medium.com

Cybersecurity

Joko Purwanto, 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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

The target is a password reset flow on a site whose domain the write-up masks as www.***.com. The feature is the standard "forgot password" mechanism: a user submits their email address on /ForgotPassword, receives a message containing a reset link, and follows that link to a form where a new password is chosen. The link carries the reset token in a query parameter named prq:

Text
https://www.***.com/MemberResetPassword?prq=<token>

The reset link behaves as a bearer credential for the account. Whoever holds it can set a new password and be signed in immediately, with no further verification step. The question the researcher asked of the flow was therefore not whether the token is strong, but how many tokens can be live for one account at the same time.

Setup

The write-up describes no special tooling, accounts or roles. The only other requirement is patience: the old link has to be kept around rather than discarded, which is exactly the behaviour that makes the flaw easy to miss.

Finding it

While walking through the password reset flow, the researcher noticed that requesting a second "forgot password" email does not invalidate the first one. Both links remain live simultaneously, and either can be used to take over the account, right up until one of them is actually used.

This looked wrong because of what a reset link is: a bearer credential. If an old link has leaked into a place it should no longer be trusted from, such as a mailbox that was compromised and has since been secured, a link cached by a mail scanner, a shared computer's browser history, or an old email search index, then the legitimate user asking for a fresh link should reasonably expect the old one to stop working. In this flow it does not.

Exploitation

Step 1: request the first reset email

Go to the forgot-password page and submit the account's email address:

Text
https://www.***.com/ForgotPassword

An email arrives containing a link of the form:

Text
https://www.***.com/MemberResetPassword?prq=<token>

The prq parameter carries the reset token. The link is deliberately not clicked at this point; it is kept for later.

Step 2: request a second reset email

Return to /ForgotPassword and submit the same email address again. A second email arrives, this time with a different token. The first token has not been invalidated by the issuance of the second.

Step 3: open both links

Open both links, either in two tabs or one after the other. Both load the "Please choose a new *** password" form. Neither link has been invalidated by the other one existing.

Step 4: complete the reset with the older link

Use the first, older link's form: set a new password and submit. The reset succeeds.

Step 5: try the newer link

Go back to the second, newer link and load it. It is now dead: a blank page with no form. Completing a reset through either token does kill the other one, so that part of the design works correctly. The gap is specifically the window between requesting a new token and actually using one. During that window, every token issued so far is valid at the same time.

Root cause

The reset tokens are not invalidated when a new one is issued for the same account. Invalidation happens only when a token is consumed: using one link kills the others, but merely requesting a new link does not. The write-up does not show the underlying code, so the exact implementation is not stated. The suggested fix notes that if tokens are tracked with an issued_for_user_id plus a used/invalidated flag, invalidating prior tokens on reissue is usually a one-line change.

The strength of the token is not the problem. The prq value is very high-entropy, roughly 490 bits, hex-encoded, and nowhere near brute-forceable. The issue is purely how many of these otherwise-strong tokens are allowed to be simultaneously valid, not the strength of any individual one.

Impact

The realistic scenario is this: someone, whether an attacker, a mail provider's link-prefetching bot, or anyone else, gets hold of an old, unused, not-yet-expired reset link. A plausible source is a period when the account's mailbox was compromised or shared and has since been locked back down. When the account owner then requests a brand new reset link for themselves, that does nothing to shut the old link off. It stays live until it is actually used by someone, attacker or owner, whoever gets there first, or until its own individual roughly 24-hour window runs out. That is a real gap in the moment when a user believes they have secured their account: the fix they would reasonably expect, asking for a fresh link and ignoring the old one, does not actually invalidate the old one.

The researcher is explicit that this is a narrower finding than others from the same hunt. It needs a specific precondition, namely that an attacker already holds an old, valid, unused link from some earlier point, rather than being exploitable from a cold start.

Fix

When a new password-reset token is issued for an account, invalidate every other outstanding, unused reset token for that same account at that moment, not only when one of them is consumed. If tokens are tracked with an issued_for_user_id plus a used/invalidated flag, this is usually a one-line change: on issuing a new token, mark all prior unused tokens for that user as invalidated in the same transaction.

Variants to test

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 9 min read.

What happened, in plain words

Many websites have a "forgot password" button. You type in your email address, the site sends you an email with a special link, and clicking that link lets you choose a new password. That link is the key to your account for a short while: anyone who has it can set a new password and get in.

The researcher was looking at exactly this flow on a site whose real name is hidden in the write-up as www.***.com. They noticed something easy to miss: if you ask for a second "forgot password" email, the first email's link does not stop working. Both links stay usable at the same time. Only when one of them is actually used does the other one die.

Why does that matter? Because an old link is like a spare key you thought you had taken back. If that old link ever ended up somewhere it should not be, for example in a mailbox that was once compromised and has since been locked down again, then asking for a fresh link should reasonably make the old one useless. Here it does not. The old link keeps working until someone uses it or until its own roughly 24-hour lifetime runs out.

The researcher is honest that this is a narrow finding. It needs a specific starting condition: an attacker must already hold an old, still-valid, unused link from some earlier point. It cannot be exploited from nothing.

From the original on medium.com

The feature being tested

The target is the standard "forgot password" mechanism. A user goes to a page called /ForgotPassword, types their email address, and the site sends them a message. That message contains a link. Following the link opens a form where the user picks a new password.

The link looks like this:

Text
https://www.***.com/MemberResetPassword?prq=<token>

Line by line, in plain words:

  • https:// is the normal, encrypted way a browser talks to a website.
  • www.***.com is the site's address, with the real name masked out in the write-up.
  • /MemberResetPassword is the page on the site that shows the "choose a new password" form.
  • ? starts the part of the address that carries extra information.
  • prq=<token> is a name and a value. prq is the name of the field, and <token> is a long random string that identifies this particular reset request.

A token here is a long random string that acts like a temporary password or a claim ticket. The site generates it, puts it in the link, and later checks it when the form is submitted. If the token matches one the site issued and has not used yet, the password change is allowed.

The important property is that this link works like a bearer credential. "Bearer" means: whoever holds it, gets it. There is no second check, no extra question, no code sent to your phone. If you have the link, you can set a new password and be signed in straight away.

So the researcher's question was not "is the token strong enough?" but "how many of these tokens can be alive for one account at the same time?"

Setting up

There is no special tooling described. No accounts with special roles, no scripts, no proxy tools. The test needs two reset emails so their links can be compared. The other requirement is patience: you have to keep the old link around instead of throwing it away, which is exactly why the flaw is easy to miss in normal use.

Finding it

While walking through the password reset flow, the researcher noticed that asking for a second "forgot password" email does not cancel the first one. Both links stay live at the same time, and either one can be used to take over the account, right up until one of them is actually used.

This looked wrong because of what a reset link is: a bearer credential. Think of it as a signed note that says "let this person in and change the password". If an old note has leaked into a place you no longer trust, such as:

  • a mailbox that was compromised and has since been secured,
  • a link cached by a mail scanner,
  • a shared computer's browser history,
  • an old email search index,

then a legitimate user asking for a fresh link should reasonably expect the old one to stop working. In this flow it does not.

Reproducing it, step by step

Step 1: request the first reset email

Go to the forgot-password page and submit the account's email address:

Text
https://www.***.com/ForgotPassword

This is the page where you type your email and press the button that means "send me a reset link". The site then sends an email containing a link of the form:

Text
https://www.***.com/MemberResetPassword?prq=<token>
  • The first line is the page you visit to ask for the email.
  • The second line is what arrives in your inbox: a link to the reset form, with a token in the prq field.

The link is deliberately not clicked at this point. It is kept for later, like keeping a receipt in a drawer.

Step 2: request a second reset email

Go back to /ForgotPassword and submit the same email address again. A second email arrives, this time with a different token. The first token has not been cancelled by the second one being issued.

Why do this? Because the whole question is whether asking for a new link retires the old one. If the old link still works after this step, the answer is no.

Step 3: open both links

Open both links, either in two browser tabs or one after the other. Both load the "Please choose a new *** password" form. Neither link has been cancelled by the other one existing.

This is the moment the flaw becomes visible. Two separate keys to the same account are both in working order at the same time.

Step 4: complete the reset with the older link

Use the first, older link's form: set a new password and submit. The reset succeeds.

Why this step? To check what happens to the other token once one is used. This is the control test: does using one link kill the other?

Step 5: try the newer link

Go back to the second, newer link and load it. It is now dead: a blank page with no form. So completing a reset through either token does kill the other one. That part of the design works correctly.

The gap is specifically the window between asking for a new token and actually using one. During that window, every token issued so far is valid at the same time.

Why it happens

The reset tokens are not cancelled when a new one is issued for the same account. Cancellation happens only when a token is used: using one link kills the others, but merely asking for a new link does not.

The write-up does not show the underlying code, so the exact implementation is not stated. The suggested fix notes that if tokens are tracked with an issued_for_user_id field plus a used or invalidated flag, invalidating earlier tokens on reissue is usually a one-line change.

The strength of the token is not the problem. The prq value is very high-entropy, roughly 490 bits, hex-encoded, and nowhere near brute-forceable. "High entropy" means it is a very long random string, so guessing it is hopeless. "Hex-encoded" means it is written using the characters 0 to 9 and a to f. The issue is purely how many of these otherwise-strong tokens are allowed to be valid at the same time, not the strength of any individual one.

What an attacker could do with it

The realistic scenario is this: someone, whether an attacker, a mail provider's link-prefetching bot, or anyone else, gets hold of an old, unused, not-yet-expired reset link. A plausible source is a period when the account's mailbox was compromised or shared and has since been locked back down.

When the account owner then asks for a brand new reset link for themselves, that does nothing to shut the old link off. It stays live until it is actually used by someone, attacker or owner, whoever gets there first, or until its own individual roughly 24-hour window runs out.

That is a real gap in the moment when a user believes they have secured their account. The fix they would reasonably expect, asking for a fresh link and ignoring the old one, does not actually cancel the old one.

The researcher is explicit that this is a narrower finding than others from the same hunt. It needs a specific precondition, namely that an attacker already holds an old, valid, unused link from some earlier point, rather than being exploitable from a cold start.

The suggested fix

When a new password-reset token is issued for an account, cancel every other outstanding, unused reset token for that same account at that moment, not only when one of them is used.

If tokens are tracked with an issued_for_user_id field plus a used or invalidated flag, this is usually a one-line change: on issuing a new token, mark all earlier unused tokens for that user as invalidated in the same transaction. "In the same transaction" means the two changes happen together, so there is no moment where the new token exists but the old ones are still live.

Other places to look for the same pattern

Glossary

  • Bearer credential: a secret that grants access to whoever holds it, with no extra check on who that is.
  • Brute-forceable: guessable by trying many possibilities until one works.
  • Bug bounty: a programme where a company pays researchers for reporting security flaws.
  • Cache: a stored copy of something, kept so it can be served again quickly.
  • Cookie: a small piece of data a website stores in your browser so it can recognise you on later requests.
  • Email search index: a searchable store of past emails, kept by some mail services.
  • Entropy: a measure of how random and unpredictable a value is; more entropy means harder to guess.
  • Expiry: the point in time after which a token or link stops being accepted.
  • Flag: a simple on/off marker stored alongside a record, such as "used" or "invalidated".
  • Forgot password flow: the sequence of pages and emails a site uses to let you reset a forgotten password.
  • Hex-encoded: written using only the characters 0 to 9 and a to f.
  • Invalidate: to mark something as no longer usable.
  • Link-prefetching bot: an automated program that opens links in emails before a person does, for example to scan for malware.
  • Mail scanner: a service that inspects incoming email, sometimes by opening the links inside it.
  • Parameter: a named value attached to a web address, such as prq=<token>.
  • Password reset token: a long random string issued by a site that allows one password reset when presented.
  • Precondition: something that must already be true before an attack can work.
  • Query parameter: the part of a web address after the ?, made of name and value pairs.
  • Root cause: the underlying reason a flaw exists, as opposed to its visible symptoms.
  • Token: a long random string used as proof of permission, like a temporary ticket.
  • Transaction: a group of database changes that all succeed or all fail together.
  • Vulnerability class: a category of security flaw, such as "old tokens not cancelled".
  • Window: the period of time during which something is possible.

More by Joko Purwanto

View all

3 more disclosed reports, best first.

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.