How I discovered an interesting account takeover flaw?
The password reset token was generated predictably: the first three characters were derived from the email address, the last characters were a timestamp, and only two middle characters were random. An attacker could brute-force those two characters to obtain a valid reset token for another user's account and take it over.
Published on medium.com
{{media:0}}
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.
Context
The target is an application the author refers to as program.com. It is a normal web application with a password reset (forgot password) feature. When a user requests a reset, the application emails a link that contains a token, and the token is placed in the URL path:
https://program.com/forgot_password/<TOKEN-HERE>
The whole flaw lives in how that token is generated. The author found it around a year before writing the post, and the report was published on 14 January 2020. It was marked as P1/Critical.
Setup
The author used their own account and one more test account, with access to the inboxes of both. The second account used an email address whose username part was identical to the first, on a different domain ([redacted] and [redacted] in the author's example). Burp's Intruder was used to run the brute force. No special role or privilege was required, only the ability to request password reset links.
Finding it
The author forgot the password of their own account and requested a reset link. Something looked wrong straight away: every time a reset link was requested for that account, the first three characters of the token stayed the same.
After a few minutes of looking at it, the pattern became clear. Those three characters were derived from the email address: the fourth letter of the email, then the third, then the second, that is, the fourth letter down to the second letter in reverse order. For [redacted], the first three characters of the token were always nho: the fourth letter is n, the third is h, the second is o, read backwards.

If the first three characters were not random, the rest probably had meaning too. The author requested tokens multiple times, for the original account and for one more test account, and found that the last few characters were the timestamp.
That left two characters in the middle, between the nho prefix and the timestamp. The author tried a lot of things and analysed patterns across all the tokens requested so far, but could not work out what those two characters meant. They may have been random.

Exploitation
Step 1: Brute force the two unknown characters
Rather than keep guessing the meaning of the two middle characters, the author decided to brute force them. The application had no rate limiting in place, so this was feasible.
Step 2: Request two tokens at the same moment
The author requested password reset links for two email addresses with an identical username part, [redacted] and [redacted], exactly at the same time. Because the requests were sent at the same time and the username part of the email is identical, the tokens sent to both accounts would be the same except for those two random characters. The token for the second account therefore gives you everything about the first account's token apart from the two characters you are about to brute force.
Step 3: Intercept the reset link and send it to Intruder
The author checked the inbox of the second email address and, intercepting the request, clicked the reset link. That request, carrying the second account's token, was sent to Burp's Intruder, and the brute force attack on the two characters began.
Step 4: Spot the successful response
After sending a few requests, a 302 response appeared. That meant the reset token of the first account had been found, and the account could have been taken over.

Root cause
The reset token was not random. It was built from predictable pieces: three characters derived from the email address (fourth letter down to the second letter, in reverse), a timestamp at the end, and only two characters in the middle that the author could not predict. The token's effective entropy was therefore those two characters, and the application did not rate limit requests against the reset endpoint, so they could simply be enumerated. The author notes that the root cause was in the algorithm generating the password reset tokens.
Impact
In the author's test, the first account's token was found and the account could have been taken over. In the author's test the two-character space was small enough that a few Intruder requests produced a 302, meaning the first account's token had been found and the account could have been taken over. The author describes the issue as an account takeover and reports that it was marked P1/Critical.
Fix
The report does not describe any fix that was applied. A sensible fix would be to generate reset tokens from a cryptographically secure random value and to rate limit the reset endpoint.
Variants to test
- Request several reset links for the same account and compare the tokens character by character. A positive result is any position that stays constant across requests.
- Compare tokens for two accounts whose email addresses differ only after the
@. A positive result is a shared prefix or suffix that tracks the username part of the address. - Request tokens seconds apart and look at the tail. A positive result is a tail that changes in step with the request time, indicating a timestamp.
- Register two addresses with the same username part on different domains, request resets at the same moment, and diff the two tokens. A positive result is tokens that differ in only a small number of characters.
- Send a burst of requests to the reset endpoint and watch for throttling. A positive result for the tester is no lockout, no CAPTCHA and no delay after many attempts, which makes brute forcing the remaining unknown characters viable.
- Feed the intercepted reset request to Intruder over the unknown positions and look for a different status code or response length. A positive result is a 302 or any response that differs from the failures, as in this report.
What happened, in plain words
A security researcher found a way to take over other people's accounts on a website, by looking closely at the links the site emails you when you forget your password. The site is called program.com in the write-up. When you click "forgot password", the site sends you an email with a link. That link contains a long string of characters called a token. The token is the site's proof that the person clicking the link is really you. If someone else can guess your token, they can reset your password and get into your account.
The researcher noticed that part of the token was not random at all. The first three characters were always built from the email address you signed up with. The last few characters were a timestamp, meaning the date and time the link was made. Only two characters in the middle were unknown. The site also had no limit on how many times you could try a reset link, so the researcher could simply try every possible pair of characters until one worked. That is called brute forcing. With the right pair, the researcher had a working reset link for another account, which means the account could be taken over.
The report was published on 14 January 2020 and the issue was marked as P1/Critical.
Background: what a password reset link is
Almost every website with user accounts has a "forgot password" button. You type your email address, the site sends you an email, and inside is a link. Clicking the link lets you set a new password without knowing the old one.
That link has to be unique to you, otherwise anyone could reset anyone's password. So the site puts a long random-looking string in the link, the token. The idea is that only the real owner of the email address ever sees the token, because only they can open the inbox. A good token is long and completely random, so that guessing it is impossible in practice. Think of it like a cloakroom ticket: the number on your ticket is the only thing that gets your coat back, so the numbers must not follow a pattern anyone could work out.
In this case the token was placed directly in the address of the page, like this:
https://program.com/forgot_password/<TOKEN-HERE>
Line by line:
https://is the secure version of the protocol browsers use to talk to websites.program.comis the site's name (a stand-in name used in the write-up)./forgot_password/is the page on the site that handles password resets.<TOKEN-HERE>is where the secret string goes. The angle brackets are just a placeholder, not part of the real link.
That is normal for many sites, but it means the token must be unguessable.
How the researcher found it
The researcher genuinely forgot the password to their own account and asked for a reset link. Something looked odd immediately: every time they asked for a new link for the same account, the first three characters of the token were identical.
Random strings do not behave like that. If you roll a die three times, you do not get the same three numbers every time. So the researcher started digging, and after a few minutes worked out the rule. The three characters came from the email address: the fourth letter, then the third, then the second, read backwards. For an address like [redacted], the fourth letter is n, the third is h, the second is o, so the token always started with nho.

If the beginning of the token was not random, the rest probably was not either. The researcher requested tokens several times, for the original account and for one more test account, and found that the last few characters were a timestamp: the moment the link was created.
That left two characters in the middle, sitting between the nho part and the timestamp. The researcher tried many things and compared all the tokens collected so far, but could not work out what those two characters meant. They may have been random.

At this point the token was almost fully predictable. Only two characters were unknown, which is a very small number of possibilities. A single character from a typical alphabet has dozens of options, so two characters is a few thousand combinations at most, something a computer can try in seconds.
Taking it further
Step 1: Try every possibility for the two unknown characters
Instead of continuing to guess what the two middle characters meant, the researcher decided to try every possible pair. This only works if the site lets you make many attempts, and this one did: there was no rate limiting, meaning nothing slowed down or blocked repeated requests. Rate limiting is like a shop assistant who stops serving you after you have asked for the same thing twenty times; without it, a computer can ask thousands of times a minute.
Step 2: Ask for two reset links at the same moment
The researcher needed a way to know everything about the victim's token except the two unknown characters. The trick was to use two email addresses that share the same username part, [redacted] and [redacted], and request reset links for both at exactly the same time. Because the requests arrived together and the part before the @ is identical, the two tokens would be the same apart from those two random characters. The token sent to the second address therefore reveals the victim's token except for the two characters about to be guessed.
Step 3: Catch the reset link and automate the guessing
The researcher opened the inbox of the second email address and clicked the reset link while intercepting the request. Intercepting means using a tool that pauses the browser's request before it reaches the site, so you can look at it and change it. That request, carrying the second account's token, was sent to Burp's Intruder. Burp Suite is a tool for testing websites, and Intruder is the part of it that repeats a request many times, swapping in a different value each time. The researcher pointed it at the two unknown characters and started the attack.
Step 4: Notice the response that means success
After a few requests, a 302 response appeared. A 302 is a standard web response meaning "the thing you asked for is somewhere else, go there instead". In this context it meant the reset link was valid: the token of the first account had been found, and the account could have been taken over.

Why it worked
The reset token was not random. It was assembled from pieces anyone could work out: three characters taken from the email address, a timestamp at the end, and only two characters in the middle that the researcher could not predict. So the real strength of the token was just those two characters. Combined with the absence of rate limiting on the reset page, guessing them was simply a matter of sending enough requests. The researcher points to the algorithm that generated the tokens as the root cause.
What an attacker could do
In the researcher's test, the first account's token was found and the account could have been taken over. In the researcher's test the two-character space was small enough that a few Intruder requests produced a 302, meaning the first account's token had been found and the account could have been taken over. The researcher describes the issue as an account takeover and reports that it was marked P1/Critical.
How to fix it
The report does not describe any fix that was applied. A sensible fix would be to generate reset tokens from a cryptographically secure random value and to rate limit the reset page.
Things to try on your own targets
- Request several reset links for the same account and compare the tokens character by character. Anything that stays the same across requests is a finding.
- Compare tokens for two accounts whose email addresses differ only after the
@. A shared beginning or ending that follows the username part is a finding. - Request tokens a few seconds apart and look at the end. An ending that changes with the request time suggests a timestamp.
- Register two addresses with the same username part on different domains, request resets at the same moment, and compare the two tokens. Tokens that differ in only a few characters are a finding.
- Send a burst of requests to the reset page and watch for throttling. No lockout, no CAPTCHA and no delay after many attempts makes brute forcing the remaining unknown characters viable.
- Feed the intercepted reset request to Intruder over the unknown positions and look for a different status code or response length. A 302, or any response that differs from the failures, is the signal, as in this report.
Glossary
- Account takeover: when someone else gains control of your account, usually by resetting your password or stealing your login.
- Brute force: trying every possible value until one works, instead of working out the answer.
- Burp Suite: a tool for testing websites, used to pause, inspect and repeat requests.
- CAPTCHA: a puzzle that is easy for a person and hard for a program, used to slow down automated attempts.
- Cryptographically secure random: randomness produced in a way that cannot be predicted, even by someone who knows how the generator works.
- Entropy: a measure of how unpredictable something is. More entropy means more guessing needed.
- Intruder: the part of Burp Suite that repeats one request many times with different values in chosen positions.
- Rate limiting: a limit on how many requests a client may make in a period of time.
- Response code (302): a three-digit number a web server sends back to describe the result. 302 means a redirect to another address.
- Root cause: the underlying reason a flaw exists, as opposed to its visible symptom.
- Timestamp: the date and time something happened, often stored as a number.
- Token: a long string used as proof of identity or permission, here the secret part of a password reset link.
- Username part: the portion of an email address before the
@symbol.