Skip to content
Account takeover Write-up Intermediate

How Token Misconfiguration can lead to takeover account

The password reset and account activation endpoints used the same token value, so a token issued for one purpose could be swapped into the other. An attacker who received an activation token for an email address that was later removed from the account could reuse that token on the password reset endpoint to take over the account.

cryptographer Follow

Published on cryptograph3r.blogspot.com

March 24, 2022

Cryptographer (@justluthra), on cryptograph3r.blogspot.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. 5 min read.

Context

This write-up describes an account takeover that came from a token misconfiguration in an account activation and password reset flow. The target is referred to only as redacted.com. The feature involved is the standard pair of email-driven flows: a new or changed email address receives an activation link, and a user who has forgotten their password receives a reset link. Both links carry a token in the URL path, and the two flows use the same token value for the same account.

The weakness is a logic flaw: the token issued for one purpose (activating an email address) is accepted for another purpose (resetting the password). The report was disclosed on 24 March 2022 and is credited to Cryptographer (@justluthra).

Setup

The researcher needed only a normal account and control of two email addresses. The steps in the report are:

  1. Visit redacted.com.
  2. Create account X and verify the email address.
  3. Request a password reset for account A.
  4. Change the email address on the account.

No special tools, versions or privileged roles are mentioned. The precondition for the attack is that the victim changes their account email to an address the attacker controls, even briefly, and then changes it again.

Finding it

The first observation was that the activation link and the reset link share the same token format and the same token value for a given account:

Text
redacted.com/activate-account/Token1111
redacted.com/password-reset/Token1111

The only difference between the two URLs is the path segment. That suggested the token itself is not bound to the action it was issued for, so swapping the path might make the server accept an activation token as a reset token.

The researcher tested this by changing the account email from A to B, taking the confirmation link sent to B, and replacing the path:

Text
BEFORE - redacted.com/activate-account/Token2222
AFTER  - redacted.com/password-reset/Token2222

With the modified link the researcher was able to change the password of account X. The report was submitted, but the program closed it as informative. The internal team's statement was:

As you state, this requires the victim to add the attacker's email to their account. There's no reason they would intentionally do that. We are not interested in social engineering reports

The objection was that the attack depended on the victim adding the attacker's address, which the team treated as requiring social engineering.

Exploitation

The researcher went back to the target and found a variation that removed the need for the victim to keep the attacker's address on the account. The change was in step 4: instead of changing the email once, from A to B, the address is changed repeatedly, from A to B to C to X and onward to any number of addresses.

Text
Before :- I changed my email from A to B
Now    :- I changed my email from A to B to C to X to ...n

After this sequence, B no longer belongs to account X, yet the token that was sent to B still works for a password reset. The token is not invalidated when the email address is changed again.

The researcher then set out the scenario in full:

  1. The victim logs in to redacted.com.
  2. The victim wants to change their email from [redacted] to [redacted] but mistypes it as [redacted].
  3. Within a few seconds the victim notices that the confirmation email has not arrived and realises the address was mistyped.
  4. The victim immediately changes the email back to [redacted].
  5. The victim receives the confirmation email for [redacted] and confirms it.
  6. Meanwhile [redacted] is an attacker, and they already received the confirmation email from step 2.
  7. The attacker uses the confirmation link, which does not work, as expected.
  8. The attacker changes the URL from /activate-account/ to /password-reset/ and lands on the reset password page.
  9. The attacker changes the password and takes over the account.
From the original on cryptograph3r.blogspot.com

The screenshot shows the point where the URL was changed from /activate-account/ to /password-reset/ and the reset password page was reached, followed by the password change and the takeover.

With this information the report was reopened. The researcher states that a bounty was awarded two days after triage.

Root cause

The same token value is accepted by both the activation and the reset flow, so it is not tied to the action it was issued for. The activation flow and the reset flow both look up the same token value, so a token delivered in an activation email is accepted by the reset endpoint.

The second part of the flaw is that the token sent to B still worked after the account email had been changed on to C, X and beyond. When the victim corrects the address, the token that was sent to the mistyped address is not revoked, so it remains valid for the account even though that address is no longer associated with it. The first report was dismissed because the team said the victim would have to add the attacker's email; the repeated-change sequence shows the attacker's address does not need to remain on the account.

Impact

An attacker who controls an address that a victim mistypes into the email change form can take over the account. The attacker has to act on the activation email sent to the mistyped address; the report shows the token still worked after the victim corrected the address and confirmed the new one. The report does not state whether the token expires, so the length of that window is not established here. The attack requires the victim to mistype an address that the attacker controls, which the researcher frames as a realistic typo scenario rather than deliberate social engineering.

Fix

The report does not describe what the program changed. A fix would be to bind each token to its purpose, so that an activation token cannot be used on the reset endpoint and vice versa, and to invalidate outstanding tokens when the account email address changes.

Variants to test

  1. Swap the path segment on any tokenised link (activation, reset, invitation, unsubscribe) and see whether the other flow accepts it. A positive result is a page that processes the token instead of rejecting it.
  2. Change the account email twice in quick succession and replay the token sent to the first address. A positive result is the token still being accepted after the address is no longer on the account.
  3. Request a reset, then change the email, then use the old reset token. A positive result is a successful reset after the address change.
  4. Compare tokens issued for the same account across flows. Identical values, as in this report, indicate the token is not purpose-bound.

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. 10 min read.

What happened, in plain words

A website sent people two kinds of email links: one to switch on (activate) a new email address, and one to reset a forgotten password. Both links contained a long random-looking string called a token. The researcher noticed that the same token was used for both jobs, and that the website did not check which job a token was meant for. So a link meant to activate an email address could be turned into a link that resets the password. If an attacker could get one of those activation emails sent to an address they control, they could take over the account.

The first version of the report was closed as "informative" because the security team said the victim would have to deliberately add the attacker's email address, which they called social engineering. The researcher then found a variation: the victim only has to mistype their own email address once, and the attacker's address does not need to stay on the account at all. The report was reopened and a bounty was paid.

This is a beginner-friendly walkthrough of that report. It assumes you can use a browser and nothing else.

The pieces you need to know

Before the steps make sense, here are the ideas involved, explained from zero.

  • Account: your personal space on a website, protected by an email address and a password.
  • Email verification / activation: when you sign up or change your email address, the site sends a message to that address with a link. Clicking the link proves you really own that address. The link usually contains a long random string so nobody can guess it.
  • Password reset: when you forget your password, the site sends a similar link to your email address. Opening it lets you set a new password.
  • Token: the long random string inside those links. Think of it as a cloakroom ticket: it stands in for your identity so you do not have to type your password into a link. If someone else gets your ticket, they can collect your coat.
  • URL path: the part of a web address after the site name, for example /activate-account/ or /password-reset/. It tells the server which page or action you want.
  • Logic flaw: a bug not in the code's syntax but in its reasoning. The code runs fine, but it allows a sequence of actions the designer did not intend. Here, the flaw is that a token issued for one purpose is accepted for another.
  • Account takeover: an attacker gains control of someone else's account, usually by changing its password or email address.
  • Social engineering: tricking a person into doing something, rather than breaking the technology. The security team argued the attack needed the victim to be tricked into adding the attacker's email address.

The setup

The researcher needed only a normal account and control of two email addresses. The steps in the report are:

  1. Visit redacted.com.
  2. Create account X and verify the email address.
  3. Request a password reset for account A.
  4. Change the email address on the account.

No special tools, versions or privileged roles are mentioned. The precondition for the attack is that the victim changes their account email to an address the attacker controls, even briefly, and then changes it again.

Finding it

The first observation was that the activation link and the reset link share the same token format and the same token value for a given account:

Text
redacted.com/activate-account/Token1111
redacted.com/password-reset/Token1111

Line by line: the first line is the link sent to activate an email address. The second line is the link sent to reset a password. Both end in the same string, Token1111. The only difference between the two URLs is the path segment. That suggested the token itself is not bound to the action it was issued for, so swapping the path might make the server accept an activation token as a reset token.

Why this matters: if the token were properly tied to its purpose, the reset page would look at Token1111 and say "this token was issued for activation, not for resetting a password", and refuse. The researcher suspected it would not refuse.

The researcher tested this by changing the account email from A to B, taking the confirmation link sent to B, and replacing the path:

Text
BEFORE - redacted.com/activate-account/Token2222
AFTER  - redacted.com/password-reset/Token2222

Line by line: the BEFORE line is the link as it arrived in the email sent to address B. The AFTER line is the same link with only the middle part changed, from activate-account to password-reset. The token Token2222 is untouched. The researcher is asking the server: "here is a token you gave me for activation, please treat it as a password reset token."

With the modified link the researcher was able to change the password of account X. That is the whole bug in one move: the server accepted a token for a job it was not issued for.

The report was submitted, but the program closed it as informative. The internal team's statement was:

As you state, this requires the victim to add the attacker's email to their account. There's no reason they would intentionally do that. We are not interested in social engineering reports

The objection was that the attack depended on the victim adding the attacker's address, which the team treated as requiring social engineering. In other words: why would anyone voluntarily put a stranger's email address on their own account?

Exploitation

The researcher went back to the target and found a variation that removed the need for the victim to keep the attacker's address on the account. The change was in step 4: instead of changing the email once, from A to B, the address is changed repeatedly, from A to B to C to X and onward to any number of addresses.

Text
Before :- I changed my email from A to B
Now    :- I changed my email from A to B to C to X to ...n

Line by line: the Before line is the original test, one email change. The Now line is the new test, a chain of email changes. The point is that the token sent to B is still valid even after the account has moved on to C, X and beyond. The server does not cancel old tokens when the email address changes.

After this sequence, B no longer belongs to account X, yet the token that was sent to B still works for a password reset. The token is not invalidated when the email address is changed again. This is the answer to the security team's objection: the attacker's address does not have to stay on the account. It only has to be on the account for a moment, long enough for the activation email to be sent.

The researcher then set out the scenario in full:

  1. The victim logs in to redacted.com.
  2. The victim wants to change their email from [redacted] to [redacted] but mistypes it as [redacted].
  3. Within a few seconds the victim notices that the confirmation email has not arrived and realises the address was mistyped.
  4. The victim immediately changes the email back to [redacted].
  5. The victim receives the confirmation email for [redacted] and confirms it.
  6. Meanwhile [redacted] is an attacker, and they already received the confirmation email from step 2.
  7. The attacker uses the confirmation link, which does not work, as expected.
  8. The attacker changes the URL from /activate-account/ to /password-reset/ and lands on the reset password page.
  9. The attacker changes the password and takes over the account.

Step by step in plain words: the victim makes a small typing mistake, one digit off in their own email address. That mistaken address happens to belong to the attacker. The site sends an activation email to it, and the attacker now holds a token for the victim's account. The victim corrects the mistake and confirms their real address, so the attacker's address is no longer on the account. But the token the attacker received is still valid. The attacker first tries the link as it arrived, which does not work. Then the attacker swaps the path from activation to password reset, and the site accepts the token and lets them set a new password.

From the original on cryptograph3r.blogspot.com

The screenshot shows the point where the URL was changed from /activate-account/ to /password-reset/ and the reset password page was reached, followed by the password change and the takeover.

With this information the report was reopened. The researcher states that a bounty was awarded two days after triage.

Root cause

The same token value is accepted by both the activation and the reset flow, so it is not tied to the action it was issued for. The activation flow and the reset flow both look up the same token value, so a token delivered in an activation email is accepted by the reset endpoint.

The second part of the flaw is that the token sent to B still worked after the account email had been changed on to C, X and beyond. When the victim corrects the address, the token that was sent to the mistyped address is not revoked, so it remains valid for the account even though that address is no longer associated with it. The first report was dismissed because the team said the victim would have to add the attacker's email; the repeated-change sequence shows the attacker's address does not need to remain on the account.

Impact

An attacker who controls an address that a victim mistypes into the email change form can take over the account. The attacker has to act on the activation email sent to the mistyped address; the report shows the token still worked after the victim corrected the address and confirmed the new one. The report does not state whether the token expires, so the length of that window is not established here. The attack requires the victim to mistype an address that the attacker controls, which the researcher frames as a realistic typo scenario rather than deliberate social engineering.

Fix

The report does not describe what the program changed. A fix would be to bind each token to its purpose, so that an activation token cannot be used on the reset endpoint and vice versa, and to invalidate outstanding tokens when the account email address changes.

Variants to test

  1. Swap the path segment on any tokenised link (activation, reset, invitation, unsubscribe) and see whether the other flow accepts it. A positive result is a page that processes the token instead of rejecting it.
  2. Change the account email twice in quick succession and replay the token sent to the first address. A positive result is the token still being accepted after the address is no longer on the account.
  3. Request a reset, then change the email, then use the old reset token. A positive result is a successful reset after the address change.
  4. Compare tokens issued for the same account across flows. Identical values, as in this report, indicate the token is not purpose-bound.

Glossary

  • Account: a user's personal space on a website, identified by an email address and protected by a password.
  • Account takeover: an attacker gaining control of someone else's account, typically by changing its password or email address.
  • Activation link: an email link that proves the recipient owns an email address, usually containing a random token.
  • Bounty: a reward paid by a company to someone who reports a security bug to it.
  • Endpoint: the specific address on a server that handles a particular action, such as resetting a password.
  • Informative: a report status meaning the program decided the finding was not a security issue worth acting on.
  • Invalidate: to make a token stop working, for example when the email address it was sent to is no longer on the account.
  • Logic flaw: a bug in the reasoning of a feature rather than in its syntax, allowing an unintended sequence of actions.
  • Password reset: the feature that lets a user set a new password after receiving a link by email.
  • Path segment: the part of a URL after the site name, such as /activate-account/ or /password-reset/.
  • Token: a long random string in a link that stands in for the user's identity, so they do not have to type a password.
  • Triage: the process a security team uses to review a report and decide whether it is valid.
  • URL: the address of a page on the web, such as redacted.com/password-reset/Token1111.
  • Verification email: a message sent to an email address to confirm that the person who entered it really owns it.

More by cryptographer

View all

1 more disclosed report, 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.