How I was able to take over any account via the Password Reset Functionality.
The password reset tokens were predictable because tokens generated close in time shared most characters, differing only in the last few. An attacker could request a reset for their own account and the victim's account in quick succession, then brute-force the last character to take over the victim's account.
Published on medium.com
Firas Fatnassi
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
In May 2020 I found an account takeover in the password reset functionality of a vulnerability disclosure program. The program does not allow public disclosure, so the target is referred to here as https://target.com. The affected feature is the standard password reset flow: a user requests a reset, receives a link containing a token, and the application shows a form to set a new password only when the token is valid.
Setup
- One or more accounts on
https://target.comthat I controlled, used to request reset links and collect tokens. - Burp Suite, used to capture the reset request and to run a Burp Intruder attack.
- A notes file (the write-up calls it a bloc note) to store tokens and observations between sessions.
No special role or privilege was needed: the only precondition was the ability to request a password reset for an account.
Finding it
My first step on a new target is to navigate the whole application to understand what it does, its main functionality and the technologies it uses. After that I test the password reset functionality. My checklist for password reset bugs is:
- Change the host when sending the request.
- Look for the token in the response.
- Tamper with id/email parameters if available, and add them if not.
- Collect a good number of tokens and analyse them, asking:
- Can it be decoded?
- Is it brute-forceable?
- Is it predictable?
- What part of the token remains the same?
On target.com the first three tests failed: there was no host header injection, no token leakage, and there were no ID or email parameters. After collecting about 8 tokens, however, I saw that two parts of the token stayed the same and the other two parts changed every time.
In the annotated tokens, green marks the parts that remain the same and orange the parts that change every time. The changing part was smaller than the static part, but it still contained random letters and numbers, so brute force was not practical. I saved the tokens, took notes and moved on to other functionality.
Three to five days later, while reading my notes, I wanted to give it another shot. I opened https://target.com, made another account, and manually sent two reset requests, one for my first account and one for my second. I copied the two tokens into my notes and found that they differed only in the last 3 characters.
The pattern suggested that the shorter the interval between the requests, the more similar the tokens are. This also explained the earlier observation: when I first collected tokens I saw 5 different characters because I was sending one request at a time, saving the token and repeating.
Two tokens differing only in the last 3 characters are still random in those characters, which makes brute force hard if not impossible by hand. The idea was to let Burp Intruder send the requests faster than I could.
Exploitation
Step 1: Capture the reset request and configure Intruder
I captured the password reset request in Burp Suite and sent it to Intruder with the following configuration:
- Payloads: my 2 accounts' emails.
- Threads: 20.
- URL-Encode: OFF.

The screenshot shows the Intruder attack payloads, that is, the two email addresses used as payloads.
Step 2: Launch the attack and compare tokens
After launching the attack I got 2 tokens that differ only in the last character.
Step 3: Guess the victim's token
With Burp Intruder I send two password reset links, one for me and one for the victim. The password reset link looks like this:
https://exmaple.com/reset/5ec6ea8d546ca610758297e*2
By design, if I visit a password reset link with an invalid token the application does not display the form to change the password. So I only have to change the last number and check whether the form is there.

The screenshot relates to this check: an invalid token gives no form.
Step 4: Enumerate victim email addresses
I also found an API endpoint from which I can enumerate email addresses, which makes it easier for an attacker to obtain the address to target.
Root cause
The reset tokens were not generated with sufficient randomness relative to the time of generation: tokens issued close together shared a long static prefix and differed only in their final characters. The report does not show the token generation code, so the exact mechanism is not stated; what the observations show is that the entropy of a token is effectively reduced to the few trailing characters when an attacker can trigger a reset for the victim at nearly the same moment as their own. The application did validate tokens (an invalid token produced no form), but validation alone does not help when the valid value can be guessed from a small search space.
Impact
An attacker who can trigger a password reset for a victim account and obtain a reset token for an account they control at almost the same time can narrow the victim's token down to a small number of candidates and try them until the change-password form appears, then set a new password. That is a full account takeover of any account. The email enumeration endpoint found during the work lowers that last barrier. The attack depends on the timing condition described above: the closer the two requests, the fewer characters differ.
I reported the bug. Although it was a VDP, I was rewarded with a bounty.
Fix
The report does not describe the fix that was applied. What the behaviour calls for is reset tokens generated from a cryptographically secure random source with enough entropy that no part of the token is predictable from another token, and tokens that are independent of each other regardless of when they are issued.
Variants to test
- Request two resets in quick succession for accounts you control and compare the tokens character by character. A positive result is a shared prefix with only a few trailing characters differing.
- Repeat the same comparison with Burp Intruder using multiple threads and URL-encoding off, as above. A positive result is tokens differing in a single final character.
- Take a token you own, change its last character, and request the reset link. A positive result is the change-password form appearing for a token you did not receive.
- Test whether the reset flow leaks the token in the response, as in the first checklist item. A positive result is the token visible in a response body or header.
- Try host header changes on the reset request. A positive result is a reset link pointing at a host you control.
- Look for an endpoint that enumerates email addresses, as found here. A positive result is a response that confirms whether a given address exists.
What happened, in plain words
In May 2020 I found a way to take over any account on a website by abusing its password reset feature. The website was part of a vulnerability disclosure program, which is a scheme where a company invites outside people to look for security problems and report them. That program did not allow public disclosure, so I call the site https://target.com throughout this article.
"Account takeover" means logging in as somebody else without their permission. "Password reset" is the feature you have used a thousand times: you click "forgot my password", the site emails you a link, you open the link, and the site shows you a form where you type a new password. The link contains a long random-looking string called a token. The site uses that token to check that the person opening the link is really the owner of the email address. If an attacker can guess or steal a valid token, they can set a new password on someone else's account and walk in.
That is exactly what happened here. The tokens were not random enough. When two reset requests were sent at almost the same moment, the two tokens came out nearly identical, differing only in their last few characters. That turned an impossible guessing problem into a tiny one: try a handful of last characters and one of them opens the victim's reset form.
This article walks through the whole story from zero. You only need to know how to use a browser. Every technical word is explained the first time it appears, and there is a glossary at the end.
The target and the feature
The affected feature is the standard password reset flow. In detail:
- A user asks the site to reset their password, usually by typing their email address into a form.
- The site creates a token, a long string of letters and numbers, and emails a link containing it.
- The user opens the link. The site reads the token from the link and checks it against its records.
- If the token is valid, the site shows a form to set a new password. If it is not valid, no form appears.
That last point matters a lot later. The site does check tokens. The problem was not that it skipped the check; the problem was that the tokens were guessable.
A token, in this context, is like a cloakroom ticket. You hand in your coat, you get a ticket with a number, and the cloakroom gives the coat back only to whoever holds the matching ticket. If the ticket numbers were handed out in a predictable order, anyone could guess the next one and walk off with somebody else's coat. Here the "coat" is the ability to set a new password.
Setup
To reproduce this I needed very little:
- One or more accounts on
https://target.comthat I controlled, used to request reset links and collect tokens. - Burp Suite, a tool used to capture and modify the requests a browser sends to a website, and to send many requests automatically.
- A notes file (the write-up calls it a bloc note) to store tokens and observations between sessions.
No special role or privilege was needed. The only precondition was the ability to request a password reset for an account, which every visitor can do.
A quick word on Burp Suite, since it appears throughout. When you fill in a form and press submit, your browser sends a request to the server. Burp Suite sits between your browser and the server like a recording machine on a phone line: it shows you the exact request, lets you change it, and can replay it many times. One of its components, Burp Intruder, takes a request and sends it over and over with different values in a chosen spot, very fast. That speed is the key to this whole story.
How I test password reset features
My first step on any new target is to navigate the whole application to understand what it does, what its main functionality is and which technologies it uses. You cannot spot something that does not belong until you know what normal looks like. After that I test the password reset functionality. My checklist is:
- Change the host when sending the request.
- Look for the token in the response.
- Tamper with id/email parameters if available, and add them if not.
- Collect a good number of tokens and analyse them, asking:
- Can it be decoded?
- Is it brute-forceable?
- Is it predictable?
- What part of the token remains the same?
Each item deserves a plain explanation.
Changing the host. Every request your browser sends carries a line saying which website it is for, the host. Some sites build the reset link from whatever host the request claims, so if you change that line to your own server, the email may contain a link pointing at your machine, and the token arrives in your logs. That is called host header injection. It did not work here.
Looking for the token in the response. Sometimes the site is careless and puts the token in the reply it sends back to the browser, not only in the email. If so, you can read it directly. That is token leakage. It did not happen here either.
Tampering with id/email parameters. A parameter is a named value sent with a request, like email=[redacted]. If the reset request carries an account id or an email address, you can try changing it to somebody else's and see whether the site sends you their reset link. Here there were no such parameters to play with.
Collecting and analysing tokens. This is the heart of the method. You request several resets for accounts you own, save every token, and compare them. Can it be decoded, meaning does it turn into readable text when you apply a common encoding such as base64? Is it brute-forceable, meaning is the set of possible values small enough to try them all? Is it predictable, meaning can you work out the next one from the previous ones? And what part of the token remains the same across tokens?
Brute force means trying every possibility until one works, like working through all combinations of a suitcase lock. It only succeeds when the number of possibilities is small. A truly random token of, say, twenty characters has so many possibilities that trying them all would take longer than the age of the universe. A token that differs from another only in its last character has ten or thirty-six possibilities, which a computer can try in a blink.
On target.com the first three tests failed: there was no host header injection, no token leakage, and there were no ID or email parameters. After collecting about 8 tokens, however, I saw that two parts of the token stayed the same and the other two parts changed every time.
In the annotated tokens, green marks the parts that remain the same and orange the parts that change every time. The changing part was smaller than the static part, but it still contained random letters and numbers, so brute force was not practical. I saved the tokens, took notes and moved on to other functionality.
This is a normal part of the work. You find a hint, you cannot yet turn it into an attack, you write it down, and you come back later with fresh eyes.
The second look
Three to five days later, while reading my notes, I wanted to give it another shot. I opened https://target.com, made another account, and manually sent two reset requests, one for my first account and one for my second. I copied the two tokens into my notes and found that they differed only in the last 3 characters.
The pattern suggested that the shorter the interval between the requests, the more similar the tokens are. This also explained the earlier observation: when I first collected tokens I saw 5 different characters because I was sending one request at a time, saving the token and repeating. Each request was seconds or minutes apart, so the tokens drifted further apart. Two requests sent back to back produced tokens that were almost twins.
Two tokens differing only in the last 3 characters are still random in those characters, which makes brute force hard if not impossible by hand. Three characters is still random, which makes brute force hard if not impossible by hand. The idea was to let Burp Intruder send the requests faster than I could.
Exploitation
Step 1: Capture the reset request and configure Intruder
I captured the password reset request in Burp Suite and sent it to Intruder with the following configuration:
- Payloads: my 2 accounts' emails.
- Threads: 20.
- URL-Encode: OFF.

The screenshot shows the Intruder attack payloads, that is, the two email addresses used as payloads.
Line by line, in plain words:
- Payloads: my 2 accounts' emails. A payload is the value that changes from one request to the next. Intruder takes the captured request, finds the spot you marked, and puts each payload there in turn. Here the marked spot is the email address in the reset form, and the two payloads are the two addresses I control. So Intruder sends the same reset request twice, once for each account, as fast as it can.
- Threads: 20. A thread is one line of execution. With 20 threads, Intruder sends up to 20 requests at the same time instead of waiting for each one to finish. This is what makes the two requests land on the server almost simultaneously, which is the condition that makes the tokens nearly identical.
- URL-Encode: OFF. Some characters cannot travel in a URL as they are, so tools normally replace them with codes such as
%40for@. Turning encoding off means the email addresses are sent exactly as typed. It keeps the request clean and avoids surprises when comparing what was sent with what the server received.
Step 2: Launch the attack and compare tokens
After launching the attack I got 2 tokens that differ only in the last character.
One character. That is the whole vulnerability in one line. Instead of a token with a huge, unguessable value, the victim's token was now one of a small handful of candidates: take your own token, keep everything except the last character, and try the possible final characters one by one.
Step 3: Guess the victim's token
With Burp Intruder I send two password reset links, one for me and one for the victim. The password reset link looks like this:
https://exmaple.com/reset/5ec6ea8d546ca610758297e*2
Line by line:
https://is the protocol, the set of rules browsers and servers use to exchange pages securely.exmaple.comis the site's address as written in the report. The report uses this spelling in the example link; the target itself is referred to astarget.com./reset/is the path, the part of the site that handles password resets.5ec6ea8d546ca610758297e*2is the token. The*2at the end is the report's way of marking the final characters that differ between tokens; it is not part of a real token.
By design, if I visit a password reset link with an invalid token the application does not display the form to change the password. So I only have to change the last number and check whether the form is there.

The screenshot illustrates this check: an invalid token gives no form, and the correct final character brings the form back.
This is why the site's own good behaviour worked against it. Because an invalid token produces no form, the presence of the form is a clear signal that you have hit the right token. You do not need to read any error message or compare hidden values; you just look at the page. Change the last character, reload, look. Change it again, reload, look. With only a few candidates, this takes seconds.
Once the form appears, the change-password form is available for that token.
Step 4: Enumerate victim email addresses
I also found an API endpoint from which I can enumerate email addresses, which makes it easier for an attacker to obtain the address to target.
An API is a way for one piece of software to talk to another, usually over the same kind of request your browser makes, but returning data instead of a web page. An endpoint is one specific address on the server that answers such requests. To enumerate means to go through a list and learn which entries exist. An endpoint that enumerates email addresses answers the question "does this address have an account here?" for any address you ask about. That matters because the endpoint makes it easier for an attacker to obtain the address to target. With such an endpoint, an attacker can confirm addresses instead of guessing them.
Root cause
The reset tokens were not generated with sufficient randomness relative to the time of generation: tokens issued close together shared a long static prefix and differed only in their final characters. The report does not show the token generation code, so the exact mechanism is not stated. What the observations show is that the entropy of a token is effectively reduced to the few trailing characters when an attacker can trigger a reset for the victim at nearly the same moment as their own.
Entropy, in security, means unpredictability. A good token is like a well-shuffled deck: knowing one card tells you nothing about the next. These tokens were more like a page of a book: knowing one line tells you almost the whole next line, and only the last word changes. The application did validate tokens, since an invalid token produced no form, but validation alone does not help when the valid value can be guessed from a small search space.
Impact
An attacker who can trigger a password reset for a victim account and obtain a reset token for an account they control at almost the same time can narrow the victim's token down to a small number of candidates and try them until the change-password form appears, then set a new password. That is a full account takeover of any account. The email enumeration endpoint found during the work lowers that last barrier. The attack depends on the timing condition described above: the closer the two requests, the fewer characters differ.
I reported the bug. Although it was a VDP, I was rewarded with a bounty.
A VDP, vulnerability disclosure program, is a scheme where a company accepts security reports but does not promise payment. A bounty is a reward, usually money, paid for a valid report. Getting paid by a VDP is not guaranteed, so it was a pleasant surprise.
Fix
The report does not describe the fix that was applied. What the behaviour calls for is reset tokens generated from a cryptographically secure random source with enough entropy that no part of the token is predictable from another token, and tokens that are independent of each other regardless of when they are issued.
A cryptographically secure random source is a generator designed so that its output cannot be predicted even by someone who has seen a lot of previous output. Ordinary random functions in programming languages are often fine for games and simulations but not for secrets, because their patterns can be worked out. For tokens, you want the secure kind, and you want enough of it that guessing is hopeless.
Variants to test
If you want to try this kind of testing yourself, on sites that allow it, here is the same checklist in practical form:
- Request two resets in quick succession for accounts you control and compare the tokens character by character. A positive result is a shared prefix with only a few trailing characters differing.
- Repeat the same comparison with Burp Intruder using multiple threads and URL-encoding off, as above. A positive result is tokens differing in a single final character.
- Take a token you own, change its last character, and request the reset link. A positive result is the change-password form appearing for a token you did not receive.
- Test whether the reset flow leaks the token in the response, as in the first checklist item. A positive result is the token visible in a response body or header.
- Try host header changes on the reset request. A positive result is a reset link pointing at a host you control.
- Look for an endpoint that enumerates email addresses, as found here. A positive result is a response that confirms whether a given address exists.
Takeaways
- Take notes so when you learn something new or you get new ideas you can test them. The breakthrough here came days after the first hint, from a notes file.
- Always think outside the box, ask good questions. "What part of the token stays the same?" is a simple question that led straight to the bug.
Glossary
- Account takeover: logging in as another person without their permission, usually by changing their password or session.
- API: a way for software to talk to software, returning data rather than a web page.
- API endpoint: one specific address on a server that answers API requests.
- Base64: a common encoding that turns data into letters and digits; it is not encryption and anyone can reverse it.
- Bounty: a reward, usually money, paid for a valid security report.
- Brute force: trying every possible value until one works; practical only when the number of possibilities is small.
- Burp Intruder: the part of Burp Suite that sends a request many times with different values in a chosen spot.
- Burp Suite: a tool that sits between your browser and a server to capture, inspect, change and replay requests.
- Cryptographically secure random source: a random generator whose output cannot be predicted from earlier output, suitable for secrets.
- Email enumeration: learning which email addresses have accounts by asking the site about them one by one.
- Endpoint: a specific address on a server that handles a particular kind of request.
- Entropy: the amount of unpredictability in a value; more entropy means harder to guess.
- Host: the part of a request that says which website it is for.
- Host header injection: making a site use an attacker-chosen host, for example in a generated link.
- Parameter: a named value sent with a request, such as an email address or an account id.
- Password reset: the feature that emails a link allowing a user to set a new password.
- Payload: in Intruder, the value that changes from one request to the next.
- Protocol: the rules two computers follow to exchange data, such as HTTPS.
- Response: what a server sends back after a request.
- Root cause: the underlying reason a vulnerability exists, as opposed to its visible symptom.
- Thread: one line of execution; more threads let a tool send several requests at the same time.
- Token: a long random string used to prove that whoever holds it is entitled to something, here the right to reset a password.
- Token leakage: a token appearing somewhere it should not, such as in a response to the browser.
- URL-encode: replacing characters that cannot travel in a URL with codes such as
%40for@. - VDP (vulnerability disclosure program): a scheme where a company accepts security reports, without promising payment.
- Vulnerability: a weakness in software that someone can abuse to do something the owner did not intend.