Skip to content
Account takeover Write-up Intermediate

Weak Cryptography in Password Reset to Full Account Takeover

The password reset token was generated by reversing the user's email address and applying a Caesar cipher with a fixed key, making it predictable. An attacker could compute the token for any known email address and reset that user's password, leading to full account takeover.

Harsh Bothra Follow

Published on medium.com

{{media:0}}

Harsh Bothra, 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 was a web application in a private bug bounty program, referred to in the write-up as www.target.com for demonstration purposes. The feature in question is the standard password reset flow that most applications offer: a user requests a reset, receives a unique reset link by email, and uses that link to set a new password. The write-up describes the flow in three steps:

Request New Pass. → Receive Unique Reset Link → Resets the Pass

Password reset has long been a favourite area for bug bounty hunters and security researchers, because it sits between unauthenticated input and authenticated account control. The write-up frames the usual attacks on it as rate limiting issues, host header injection, and, at the far end, account takeover.

Setup

The researcher used two test accounts on the private program, registered with plus-aliased email addresses:

  • <bugcrowd_alias>[redacted]
  • <bugcrowd_alias>[redacted]

The plus trick matters here. Appending +sometext to an email address creates an alias, and all mail sent to the alias is delivered to the real mailbox. Most applications do not block this, so two distinct accounts can be driven from one inbox. The write-up gives the example of an actual address [redacted] with aliases such as [redacted] or [redacted], all forwarded to the actual address. The researcher notes that this finding was figured out purely because of that trick.

No tools or versions are named in the write-up. The precondition is simply the ability to request a password reset for two accounts whose email addresses differ only by the +1 and +2 suffix.

Finding it

The researcher returned to the target after a few weeks and had forgotten the credentials for the test accounts, so a Forget Password request was made for both of them. Comparing the two reset links, the only difference between them was the digit 1 versus 2.

Reset Link of Account 1:

HTTP
https://target.com/reset_password?[redacted]

Reset Link of Account 2:

HTTP
https://target.com/reset_password?[redacted]

Two things stood out. First, the tokens differed only where the email addresses differed. Second, the length of the reset token equalled the number of characters in the email address, with %40 standing in for @. That strongly suggested a weak cryptographic mechanism, but the exact encoding was still unknown. After a few more minutes of analysis, the researcher derived the formula the application used to generate the token:

Ceaser_Cipher_Key13(reverse(email)) == Password Reset Token

Exploitation

Step 1: Take the victim email

Start from the victim's email address, for example:

Text
[redacted]

Step 2: Reverse the email

Reverse the string character by character:

Text
moc.liamg@22arhtobh

Step 3: Apply a Caesar cipher with key 13

Encrypt the reversed email with a Caesar cipher using key 13 (a ROT13 shift):

Text
zbp.yvnzt@22neugbou

Step 4: Encode the @ sign

Change @ to %40, and the reset token is complete:

Text
zbp.yvnzt%4022neugbou

With this formula, a reset token can be produced for any user, so the password of any account can be reset. The application also allowed enumeration of valid email addresses on the forget password form, which made the task easier: an attacker does not need to guess whether an address exists before computing its token.

Root cause

The reset token is not a random, server-side secret. It is a deterministic transformation of the user's email address: reverse the string, apply a Caesar cipher with key 13, and URL-encode the @. Because the input (the email address) is known or guessable, the output (the token) is fully predictable. The write-up states plainly that the application had a weak cryptographic mechanism in place; the exact code is not shown, so how the token was validated server-side is not described.

Two design choices made the weakness easy to spot and to exploit. The token length matched the email length, which leaked the construction, and the forget password form allowed enumeration of valid emails, removing the need to guess addresses. The write-up does not discuss rate limiting, token expiry, single-use enforcement or session binding.

Impact

An attacker who knows a user's email address can compute that user's password reset token and reset the password, taking over the account. Because valid emails could be enumerated on the forget password form, the attacker can first confirm which addresses exist and then target them. The researcher classifies the finding as a P1 (critical) bug. The write-up does not state the number of affected users or any further conditions beyond the private program context.

Fix

The write-up does not describe what was changed in the application. The fix implied by the finding is to generate reset tokens from a cryptographically secure random source rather than deriving them from the email address, and to stop leaking valid addresses through the forget password form.

Variants to test

  1. Request resets for two plus-aliased addresses and diff the tokens. A positive result is that the tokens differ only where the addresses differ, or share a long common prefix or suffix.
  2. Compare token length with email length. A positive result is a token whose length tracks the address length, with %40 or @ appearing in the token.
  3. Try reversing the email and applying ROT13, then URL-encoding @ as %40, and submit the result as a token. A positive result is a successful reset for an account whose token you never received.
  4. Check whether the forget password form reveals which addresses are registered. A positive result is a different response for valid and invalid addresses, which makes token prediction practical at scale.
  5. Look for other public encodings or weak transformations in reset tokens, such as base64 of the email, hex of the email, or a hash of the email without a secret. A positive result is a token you can reproduce offline from the address alone.

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 let people reset a forgotten password by email. When you ask for a reset, the site sends you a link containing a long code called a token. Clicking the link with the right token lets you set a new password. The token is supposed to be a secret that only the real owner of the account receives.

On this site, the token was not secret at all. It was just the user's email address, written backwards and scrambled with a simple letter-shifting trick that anyone can undo. So if an attacker knew your email address, they could work out your reset token on paper, open the reset link themselves, and set a new password. That gives them your account. The researcher who found this rated it P1 (critical).

This article walks through the finding from the beginning, explaining each idea as it comes up.

Background: what a password reset is

Almost every website with logins offers a "forgot password" feature. The usual flow has three steps, and the write-up describes it like this:

Request New Pass. → Receive Unique Reset Link → Resets the Pass

In plain words:

  1. You type your email address into a form and ask for a reset.
  2. The site sends an email to that address containing a link with a unique code in it.
  3. You open the link, and the site lets you choose a new password.

The code in the link is called a token. Think of it like a cloakroom ticket: whoever holds the ticket can collect the coat. The site cannot see who is clicking, so the ticket itself is the proof of identity. That is why the ticket must be impossible to guess. If someone else can produce the same ticket, they get the coat.

Password reset is a favourite area for security researchers because it sits in a sensitive spot: the form is open to anyone on the internet (no login needed), yet a successful reset ends in full control of an account. The write-up lists the usual attacks people try on this feature: rate limiting problems (sending too many requests too fast), host header injection (tricking the site into putting a different web address into the reset link), and at the far end, account takeover.

Account takeover means an attacker gains control of someone else's account, here by setting a new password so the real owner is locked out.

Setting up two test accounts

The researcher was testing a web application that belonged to a private bug bounty program. A bug bounty program is an arrangement where a company invites outside researchers to look for security flaws and report them, sometimes for a reward. "Private" means only invited researchers can take part. The write-up calls the site www.target.com as a stand-in name so the real one is not revealed.

To compare reset links, the researcher needed two accounts. They registered two, using email addresses built with a trick called plus aliasing:

  • <bugcrowd_alias>[redacted]
  • <bugcrowd_alias>[redacted]

Here is how the trick works. Many email providers treat everything after a + in the part before the @ as a label and ignore it when delivering. So [redacted] and [redacted] both arrive in the same inbox as [redacted], but a website sees them as two different addresses. The write-up gives this example:

Actual Email: [redacted]

Alias: [redacted] OR [redacted]

All the emails of Aliases will be forwarded to Actual Email.

Why does this matter? Because it lets one person run two separate accounts from a single inbox, and most sites do not block the + form. The researcher says this finding was figured out purely because of that trick: with two accounts whose addresses differ only by one character, the two reset tokens could be placed side by side and compared.

No tools or software versions are named in the write-up. The only precondition was being able to request a password reset for two accounts whose addresses differ by the +1 and +2 suffix.

Finding the weakness

The researcher came back to the target after a few weeks and had forgotten the passwords for the test accounts. So they used the Forget Password form for both accounts.

When they compared the two reset links, the only difference was the digit 1 versus 2.

Reset Link of Account 1:

HTTP
https://target.com/reset_password?[redacted]

Reset Link of Account 2:

HTTP
https://target.com/reset_password?[redacted]

Line by line, in plain words:

  • https://target.com/reset_password is the page on the site that handles password resets.
  • The ? starts the query string, the part of a web address that carries extra information to the page.
  • token= names the piece of information being passed: the reset token.
  • zbp.nwavaqjbeptho%401+neugboufenu is the token itself. %40 is how a web address writes the @ symbol, because @ has a special meaning in addresses. So the token really reads zbp.nwavaqjbeptho@1+neugboufenu.

The two tokens are identical except for the 1 and the 2, which are exactly the characters that differ between the two email addresses. That is a strong hint: a properly random token would look completely different every time, with no shared structure.

The second observation was about length. The write-up says the length of the reset token equalled the number of characters in the email address, with %40 standing in for @. In other words, the token was exactly as long as the address it belonged to. A random token has a fixed length chosen by the site, not a length that follows the user's email.

Together, these two clues suggested the site was using a weak cryptographic mechanism: the token was derived from the email address rather than generated randomly. But the exact recipe was still unknown. After a few more minutes of analysis, the researcher worked out the formula:

Ceaser_Cipher_Key13(reverse(email)) == Password Reset Token

Let us unpack that formula, because every part of it is simple:

  • reverse(email) means writing the email address backwards, character by character.
  • Caesar cipher is one of the oldest scrambling tricks. You shift every letter of the alphabet forward by a fixed number of places. With a shift of 13, a becomes n, b becomes o, and so on, wrapping around at the end of the alphabet. Because the alphabet has 26 letters, shifting by 13 twice brings you back to where you started, so the same operation both scrambles and unscrambles. This particular shift of 13 is often called ROT13.
  • Key13 just means the shift amount is 13.
  • The == means the left side produces exactly the token on the right side.

A Caesar cipher is not real encryption in any meaningful sense. It is like hiding a note by swapping every letter for the one 13 places later in the alphabet: anyone who knows the rule can read it instantly, and the rule is public knowledge.

Exploitation, step by step

The researcher then showed how to build a valid token for any user, in four steps.

Step 1: Take the victim email

Start from the victim's email address, for example:

Text
[redacted]

This is the only input needed. Email addresses are not secret: they are shared on websites, in mailing lists, in address books. The attacker does not need access to the victim's inbox.

Step 2: Reverse the email

Reverse the string character by character:

Text
moc.liamg@22arhtobh

Read it right to left and you get the original address back. This step hides the address from a casual glance but changes nothing about how guessable it is.

Step 3: Apply a Caesar cipher with key 13

Encrypt the reversed email with a Caesar cipher using key 13 (a ROT13 shift):

Text
zbp.yvnzt@22neugbou

Each letter has been moved 13 places along the alphabet: m becomes z, o becomes b, c becomes p, and so on. Digits and the @ are left alone. The result still contains the @ symbol.

Step 4: Encode the @ sign

Change @ to %40, and the reset token is complete:

Text
zbp.yvnzt%4022neugbou

This is the same %40 seen in the real links. Web addresses cannot carry a bare @ inside a value without confusion, so it is written in its encoded form. The token is now ready to be placed into the reset link and opened in a browser.

With this formula, a reset token can be produced for any user, so the password of any account can be reset. The application also allowed enumeration of valid email addresses on the forget password form, which made the task easier.

Enumeration here means the site's responses let you tell which email addresses have accounts. For example, the form's response might differ depending on whether the address has an account. That removes the need to guess whether an address exists before computing its token: the attacker can first confirm the address is real, then build the token for it.

Why it worked

The reset token was not a random, server-side secret. It was a deterministic transformation of the user's email address: reverse the string, apply a Caesar cipher with key 13, and URL-encode the @. Deterministic means the same input always produces the same output, with no randomness involved. Because the input (the email address) is known or guessable, the output (the token) is fully predictable.

The write-up states plainly that the application had a weak cryptographic mechanism in place. The exact code is not shown, so how the token was checked on the server side is not described.

Two design choices made the weakness easy to spot and to exploit. The token length matched the email length, which leaked the construction, and the forget password form allowed enumeration of valid emails, removing the need to guess addresses. The write-up does not discuss rate limiting, token expiry, single-use enforcement or session binding.

Impact

An attacker who knows a user's email address can compute that user's password reset token and reset the password, taking over the account. Because valid emails could be enumerated on the forget password form, the attacker can first confirm which addresses exist and then target them. The researcher classifies the finding as a P1 (critical) bug. The write-up does not state the number of affected users or any further conditions beyond the private program context.

Fix

The write-up does not describe what was changed in the application. The fix implied by the finding is to generate reset tokens from a cryptographically secure random source rather than deriving them from the email address, and to stop leaking valid addresses through the forget password form. A cryptographically secure random source is a generator whose output cannot be predicted even if you know everything else about the system, unlike a formula that always gives the same answer for the same input.

Things to try on your own targets

  1. Request resets for two plus-aliased addresses and diff the tokens. A positive result is that the tokens differ only where the addresses differ, or share a long common prefix or suffix.
  2. Compare token length with email length. A positive result is a token whose length tracks the address length, with %40 or @ appearing in the token.
  3. Try reversing the email and applying ROT13, then URL-encoding @ as %40, and submit the result as a token. A positive result is a successful reset for an account whose token you never received.
  4. Check whether the forget password form reveals which addresses are registered. A positive result is a different response for valid and invalid addresses, which makes token prediction practical at scale.
  5. Look for other public encodings or weak transformations in reset tokens, such as base64 of the email, hex of the email, or a hash of the email without a secret. A positive result is a token you can reproduce offline from the address alone.

Glossary

  • Account takeover: gaining control of someone else's account, here by resetting their password so the real owner is locked out.
  • Alias (plus alias): an email address with a +label added before the @; mail still arrives in the main inbox, but websites see a different address.
  • Bug bounty program: an arrangement where a company invites outside researchers to find and report security flaws, sometimes for a reward.
  • Caesar cipher: a scrambling method that shifts every letter of the alphabet forward by a fixed number of places.
  • Cryptographically secure random source: a generator whose output cannot be predicted, even with full knowledge of the system.
  • Deterministic: always producing the same output for the same input, with no randomness.
  • Enumeration: learning which accounts or addresses exist by observing differences in a site's responses.
  • Forget Password form: the page where a user asks the site to send a password reset email.
  • Host header injection: an attack that manipulates the web address a site believes it is serving, sometimes to change links it generates.
  • Password reset token: the unique code inside a reset link that proves the holder is allowed to set a new password.
  • P1 (critical): the most severe rating a bug bounty program gives a finding.
  • Private program: a bug bounty program open only to invited researchers.
  • Query string: the part of a web address after the ?, carrying extra values to the page.
  • Rate limiting: a control that limits how many requests can be made in a period of time.
  • ROT13: a Caesar cipher with a shift of 13, which is its own reverse.
  • Token: a code that acts as proof of permission, like a cloakroom ticket.
  • URL encoding: writing special characters in a web address in a safe form, such as %40 for @.

More by Harsh Bothra

View all

7 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.