P5 to P1: Interesting Account Takeover
The application allowed signing up with dotted variants of an existing Gmail address, and password reset tokens were not invalidated after an email change. An attacker could register with a dotted variant of a victim's email, request a reset token, change their account email to the victim's address, then use the old token to reset the victim's password and take over the account.
Published on medium.com
This is my second write-up. You can check out my first writeup which is on Account Takeover through Stored XSS.
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
This is a write-up about an account takeover that started from a small email normalisation quirk and ended with a password reset token that survived an email change. The target is described only as a program that had been launched a few days before the researcher started, found on a private RDP. The report does not name the application, its endpoints, parameters or headers.
The two features involved are ordinary ones. Sign-up accepts an email address and creates an account. Password reset sends a token to the address on the account, and that token lets the holder set a new password. Email change lets a logged-in user move the account to a different address. The report also mentions that the platform's VRT rates "token does not invalidate after email change" as P5 on its own.
Setup
The researcher was hunting on private RDPs found through self-made Google dorks, published at:
https://github.com/tushar-arch/Bug-Bounty-Dorks/blob/main/Bug-Bounty-Dorks.txt
After picking the freshly launched program, subdomain enumeration was started and nuclei was fired in the background while the target was walked manually. Burp was used for the manual testing. Two Gmail-style addresses were used for the duplicate sign-up test, and a temporary email address was used later for the reset-token test. No tool versions are given.
Finding it
The first thing tested was the signup functionality: duplicate sign-up and rate limits. Neither produced anything. The researcher then recalled a case highlighted by https://twitter.com/Virdoex_hunter in his POC, which is the dotted-Gmail idea.
The reasoning is that Gmail ignores dots in the local part, so if you own [redacted] you also receive mail for [redacted], and nobody else can register the dotted form. An application that treats the two strings as different accounts is therefore wrong.
Signing up with [redacted] succeeded, and signing up again with [redacted] also succeeded. The application should have refused the second registration.
With both accounts created, requesting a password token for [redacted] delivered it to the inbox of [redacted]. Changing the password through that token changed the password for both accounts, because of backend logic the report does not describe further.
The researcher judged this too low impact to report on its own, having no attacking scenario to show the security team, and kept looking. The email change functionality then caught their eye.
Exploitation
The scenario combines the dotted-address weakness with the reset token that is not invalidated when the email changes. The researcher signed up with a temporary email, requested a password reset, then changed the email on the account. The reset token sent to the temporary address could still be used to change the password.
On its own that is P5 according to the Bugcrowd VRT, but in this chain it is not. The steps as written in the report:
Step 1: Create an account
Sign up with any email address. In the chain this is the temporary address the attacker controls.
Step 2: Request a password reset token
Request a password reset token to that email. The token arrives in the attacker's inbox and is kept, not used yet.
Step 3: Change the email to the victim's address
Log in and change the email to the victim's email, for example [redacted], given that the victim has an account with [redacted]. The application allows this because it treats the dotted version as a separate address, the same weakness seen at sign-up.
Step 4: Use the old token
Go to the inbox of the previous email, the temporary one, and use the reset token to change the password.
Step 5: Log in as the victim
The password change succeeds, and logging in to [redacted] with the new password works. The account has been taken over.
What happened, in the researcher's words: when the email was changed to the dotted victim address, which the application allowed even though the undotted victim address was already registered, the password token got chained to both accounts.
A good report with a video POC was submitted. It was triaged and fixed after a few days, and a bounty was paid.
Root cause
The application does not normalise email addresses before comparing them. Dots in the local part are treated as significant, so [redacted] and [redacted] are two accounts even though Gmail delivers both to the same inbox. The same comparison lets an attacker move an account onto the dotted form of a victim's address.
On top of that, a password reset token is not tied to the email address it was issued for, or invalidated when the email changes. The token issued to the temporary address remains valid after the account is pointed at the victim's address, and the backend then applies the password change to the victim's account as well. The report describes the chaining as backend logic without detailing it.
Duplicate sign-up checks and rate limits were tested and found nothing.
Impact
An attacker who controls any email address can take over an account whose address has a dotted variant, provided the victim's undotted address is already registered and the application accepts the dotted form as a new address. The attacker registers, requests a reset, changes the email, uses the token and logs in with the new password. The report shows this against a Gmail-style address; the same reasoning applies wherever the mail provider ignores dots, but the report only demonstrates the Gmail case.
Fix
The report says the issue was fixed and a bounty of $1000 was awarded, without describing the change.
Variants to test
- Register
[redacted]and then[redacted]on the same target. A positive result is two accounts where the provider delivers both to one inbox. - Request a reset, change the email, then use the old token. A positive result is a successful password change after the address has moved.
- Change the email to the dotted form of an address that is already registered. A positive result is the change being accepted.
- Try the same chain with other provider-specific normalisations, such as plus addressing, if the target treats them as distinct. A positive result is two accounts for one mailbox.
- Check whether other tokens, such as email verification or invitation links, survive an email change in the same way. A positive result is a token issued for the old address still being accepted.
Timeline
| Date | Event |
|---|---|
| 01 November, 2021 | Reported |
| 09 November, 2021 | Triaged |
| 11 November, 2021 | Fixed and bounty awarded $1000 |
What happened, in plain words
A security researcher found a way to take over someone else's account on a website, using two small mistakes that the website made. Neither mistake was very serious on its own, but together they let an attacker log in as another person.
The first mistake is about email addresses with dots in them. On Gmail, [redacted] and [redacted] are the same mailbox: Gmail ignores the dots, so both addresses deliver mail to the same inbox, and nobody else can register the dotted version. A website that treats those two strings as two separate accounts is wrong. The target website did exactly that: it let the researcher create two accounts for what is really one mailbox.
The second mistake is about password reset links. When you forget your password, a website emails you a special code (a token) that lets you set a new password. That code should stop working once the email address on the account changes. On the target, the code kept working after the email address was changed.
Put together, the attacker can create an account with an email they control, ask for a reset code, then change the account's email to the victim's address (using the dotted form, which the site wrongly accepts as a new address). The old reset code still works, and using it changes the password on the victim's account. The attacker then logs in as the victim.
The researcher reported it, the site fixed it, and a bounty of $1000 was paid.
The pieces you need to know
Before the steps make sense, here are the everyday ideas behind them.
- Account: the record a website keeps for one user, usually identified by an email address and protected by a password.
- Sign-up: the form where you give an email and a password to create an account.
- Password reset: the "forgot my password" feature. The site emails you a token, a long random string that acts like a temporary key. Whoever holds the token can set a new password.
- Email change: a setting inside your account that lets you move the account to a different email address.
- Token: a short secret string a server gives you so it can recognise you later. Think of a cloakroom ticket: show the ticket, get the coat. If the ticket still works after you have handed the coat to someone else, that is a problem.
- Session: the period during which the site remembers you are logged in, usually tracked with a cookie in your browser.
- Account takeover: when an attacker gains control of someone else's account, usually by getting in as that user.
- Vulnerability: a weakness in how a site is built that an attacker can abuse.
- Bug bounty: a programme where a company pays researchers for finding and reporting vulnerabilities in its systems.
- VRT: Bugcrowd's Vulnerability Rating Taxonomy, a public list that rates how serious each kind of bug usually is. P5 is the lowest severity, P1 the highest.
- RDP: a remote desktop, a Windows machine you can log into over the internet and use as if it were in front of you.
- Subdomain enumeration: finding the smaller names under a domain (like
shop.example.comoradmin.example.com) so you know what to test. - Nuclei: a tool that automatically checks a list of known issues against a target.
- Burp: short for Burp Suite, a tool that sits between your browser and the website so you can see and edit every request.
- Request: the message your browser sends to a server, for example "please give me this page" or "please change my password".
- Backend: the part of the website that runs on the server, out of sight, and does the actual work.
- Normalisation: cleaning up a value into a standard form before comparing it. For emails, that would mean treating
[redacted]and[redacted]as the same mailbox. - Rate limit: a cap on how many times you can do something in a period, for example how many sign-ups you can make per minute.
- POC: proof of concept, a recording or set of steps that shows the bug really works.
Setting up
The researcher was working on private RDPs, remote Windows machines they found by writing their own Google search queries (called dorks) and publishing them here:
https://github.com/tushar-arch/Bug-Bounty-Dorks/blob/main/Bug-Bounty-Dorks.txt
That link is a list of search queries. The idea is that a search engine can be used to find pages and machines that were not meant to be public, and the list collects such queries so other researchers can reuse them.
On one of those machines, the researcher picked a bug bounty programme that had only been launched a few days earlier. New programmes are attractive because fewer people have tested them yet. They started subdomain enumeration and ran nuclei in the background, while they walked through the target by hand. Burp was used for the manual testing. No tool versions are given in the report.
Finding the first weakness
The first thing tested was the sign-up form. The researcher tried to create duplicate accounts and to hit rate limits, but found nothing. Then they remembered a case highlighted by https://twitter.com/Virdoex_hunter in his POC, which is the dotted-Gmail idea.
The reasoning is simple. Gmail ignores dots in the part of the address before the @. So if you own [redacted], you also receive mail sent to [redacted], and nobody else can register the dotted form. A website that treats the two strings as different accounts is therefore wrong.
Signing up with [redacted] succeeded. Signing up again with [redacted] also succeeded. The application should have refused the second registration.
With both accounts created, the researcher requested a password token for [redacted]. The token was delivered to the inbox of [redacted], which is the same mailbox. Changing the password through that token changed the password for both accounts, because of backend logic the report does not describe further.
That alone was judged too low impact to report. There was no attacking scenario to show the security team, so the researcher kept looking. Then the email change functionality caught their eye.
The second weakness
The researcher signed up with a temporary email address and requested a password reset. Then they changed the email on the account. The reset token that had been sent to the temporary address could still be used to change the password.
On its own, that is P5 according to the Bugcrowd VRT, the lowest severity. But in this chain it is not, because it can be combined with the dotted-address weakness.
The attack, step by step
Step 1: Create an account
Sign up with any email address. In the chain this is the temporary address the attacker controls.
Step 2: Request a password reset token
Request a password reset token to that email. The token arrives in the attacker's inbox and is kept, not used yet. The point of keeping it is that it will still be valid later, after the email address has changed.
Step 3: Change the email to the victim's address
Log in and change the email to the victim's email, for example [redacted], given that the victim has an account with [redacted]. The application allows this because it treats the dotted version as a separate address, the same weakness seen at sign-up.
Step 4: Use the old token
Go to the inbox of the previous email, the temporary one, and use the reset token to change the password. The token was issued for the old address and still works.
Step 5: Log in as the victim
The password change succeeds, and logging in to [redacted] with the new password works. The account has been taken over.
In the researcher's words: when the email was changed to the dotted victim address, which the application allowed even though the undotted victim address was already registered, the password token got chained to both accounts.
A report with a video POC was submitted. It was triaged and fixed after a few days, and a bounty was paid.
Why it worked
The application does not normalise email addresses before comparing them. Dots in the part before the @ are treated as significant, so [redacted] and [redacted] are two accounts even though Gmail delivers both to the same inbox. The same comparison lets an attacker move an account onto the dotted form of a victim's address.
On top of that, a password reset token is not tied to the email address it was issued for, or invalidated when the email changes. The token issued to the temporary address remains valid after the account is pointed at the victim's address, and the backend then applies the password change to the victim's account as well. The report describes the chaining as backend logic without detailing it.
Duplicate sign-up checks and rate limits were tested and found nothing.
What an attacker could do with it
An attacker who controls any email address can take over an account whose address has a dotted variant, provided the victim's undotted address is already registered and the application accepts the dotted form as a new address. The attacker registers, requests a reset, changes the email, uses the token and logs in with the new password. The report shows this against a Gmail-style address. The same reasoning applies wherever the mail provider ignores dots, but the report only demonstrates the Gmail case.
How to fix it
The report says the issue was fixed and a bounty of $1000 was awarded, without describing the change.
Things to try on other sites
- Register
[redacted]and then[redacted]on the same target. A positive result is two accounts where the provider delivers both to one inbox. - Request a reset, change the email, then use the old token. A positive result is a successful password change after the address has moved.
- Change the email to the dotted form of an address that is already registered. A positive result is the change being accepted.
- Try the same chain with other provider-specific normalisations, such as plus addressing, if the target treats them as distinct. A positive result is two accounts for one mailbox.
- Check whether other tokens, such as email verification or invitation links, survive an email change in the same way. A positive result is a token issued for the old address still being accepted.
Timeline
| Date | Event |
|---|---|
| 01 November, 2021 | Reported |
| 09 November, 2021 | Triaged |
| 11 November, 2021 | Fixed and bounty awarded $1000 |
Glossary
- Account takeover: when an attacker gains control of someone else's account, usually by logging in as that user.
- Backend: the part of a website that runs on the server, out of sight, and does the actual work.
- Cookie: a small piece of data a website stores in your browser so it can recognise you on later visits.
- Dork: a search query written to find pages or machines that were not meant to be public.
- Normalisation: cleaning up a value into a standard form before comparing it, for example treating dotted and undotted Gmail addresses as the same mailbox.
- Password reset: the "forgot my password" feature, which emails a token that lets you set a new password.
- Session: the period during which a site remembers you are logged in, usually tracked with a cookie.
- Token: a short secret string a server gives you so it can recognise you later, like a cloakroom ticket.
- VRT: Bugcrowd's Vulnerability Rating Taxonomy, a public list that rates how serious each kind of bug usually is, from P5 (lowest) to P1 (highest).