Pre-Account Takeover using OAuth Misconfiguration
An account created via Google OAuth could have its email changed to another person's address without verification, and the OAuth login link remained active even after being unlinked. An attacker could therefore log into an account that a victim later created or recovered using that email address.
Published on vijetareigns.medium.com
Today I am going to share one of my interesting findings on the private program of Bugcrowd. Since this is on a private program so I will be using target.com as the website name.
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 finding comes from a private Bugcrowd program, so the write-up refers to the target only as target.com. Only two subdomains were in scope, and the researcher picked one of them, a.target.com. That subdomain hosts a registration page where a new account can be created either with an email and password or by signing up with Google OAuth. The feature under examination is the account profile: it lets a user change the account email address and link or unlink a Google OAuth identity.
Setup
No special tooling is described. The researcher registered a normal account on a.target.com through Google OAuth and then explored the profile settings. The only precondition is a working account on the in-scope subdomain and the ability to sign in both with Google OAuth and with an email and password.
Finding it
The researcher went looking for OAuth misconfigurations, which the write-up names as a favourite area. The first round of tests covered CSRF on linking and unlinking Google OAuth, unvalidated redirects after signup with OAuth, and other well-known OAuth issues. A state parameter was present throughout the flow, so CSRF was not possible, and attempts to bypass the state check did not succeed.

The next idea came from the change email functionality in the profile settings. The researcher changed the OAuth account email from [redacted] to [redacted]. The application states that after changing the email, logging in with Google OAuth is no longer possible.

The researcher then used the unlink option. The email change went through successfully, and notably the new email address was not verified. With the account now on the email and password method, the researcher logged in again that way. Then came the observation that mattered: logging in with the old Google OAuth account, the one that had already been unlinked, still succeeded and landed in the same old account. In other words, the OAuth link had been removed from the profile, yet the OAuth login still resolved to that account.
Exploitation
The researcher turned this into an account takeover scenario, built on the fact that the email change is not verified. Because no verification of the new address takes place, an attacker can set the account email to somebody else's address. The scenario as described:
Step 1: create an account with OAuth
The attacker creates an account on a.target.com using Google OAuth.
Step 2: change the email to the victim's address
The attacker changes the account email to the victim's email address.
Step 3: the victim registers or resets
When the victim tries to create an account on a.target.com, the application reports that the email already exists. The victim then resets the password and logs in with the email and password method.
Step 4: the attacker logs in through OAuth
The attacker is also able to log in to the victim's account using OAuth.


The write-up closes by noting that the bug does not carry much severity, but that some companies paid well for it, and that some paid nothing.

Root cause
The report describes the behaviour rather than the code, so the underlying mistake is inferred. Two weaknesses combine. First, the email change is applied without verifying the new address, which lets an attacker claim an address they do not control. Second, unlinking Google OAuth does not invalidate the association used at login: the old OAuth identity still authenticates into the same account after the unlink. The state parameter protected the flows against CSRF, but it does nothing about either of these two problems.
Impact
An attacker can take over an account belonging to a victim who registers or resets a password on the subdomain after the attacker has claimed their email address. The attacker can also log in to the victim's account through OAuth while the victim uses the email and password method. The researcher is explicit that the severity is not high, and the scenario depends on the victim subsequently creating an account or resetting a password on the same subdomain.
Fix
The report does not say what was changed. Based on the behaviour described, the email change should require verification of the new address before it takes effect, and unlinking an OAuth identity should invalidate that identity so it can no longer authenticate into the account.
Variants to test
- Change the account email to an address you do not control and check whether the application lets you log in or receive mail at it before verification. A positive result is an active session or delivered mail on an unverified address.
- Unlink an OAuth provider and then attempt to log in with that same provider identity. A positive result is landing back in the original account.
- Link a second OAuth identity, unlink the first, and check which identity still resolves to the account.
- Register with OAuth, change the email to a victim's address, and observe whether registration for that address reports it as already taken.
- Repeat the email change and unlink sequence on other subdomains in scope to see whether the behaviour is shared across the application.
What happened, in plain words
A security researcher found a way to take over someone else's account on a website. The website let people sign up either with an email and password, or by using their Google account (this is called OAuth). The researcher discovered two problems that, when combined, allowed an attacker to log in as another person. First, the website allowed changing the email address on an account without verifying that the new address actually belongs to you. Second, even after you unlink your Google account from the profile, the website still allowed logging in with that same Google account. By exploiting these two flaws, an attacker could set their account's email to the victim's email, and then log in as the victim using Google OAuth. The researcher reported this to a private bug bounty program on Bugcrowd.
Context
This finding comes from a private program on Bugcrowd, so the actual website name is hidden and referred to as target.com. Only two subdomains were in scope for testing. The researcher chose one of them, a.target.com. A subdomain is a part of a larger website, like mail.google.com is a subdomain of google.com. On a.target.com, there is a registration page where you can create a new account. You can sign up either by providing an email address and a password, or by using your Google account (this is called "sign up with Google" or OAuth). The feature being examined is the account profile page, which lets you change your email address and link or unlink your Google account.
Setup
No special tools are mentioned. The researcher simply created a normal account on a.target.com using Google OAuth, and then explored the profile settings. The only requirement is to have a working account on the in-scope subdomain and to be able to sign in both with Google OAuth and with an email and password.
Finding it
The researcher was specifically looking for OAuth misconfigurations, which is a favourite area of theirs. OAuth is a way for a website to let you log in using another service (like Google) without giving the website your Google password. The first round of tests covered:
- CSRF on linking and unlinking Google OAuth. CSRF (Cross-Site Request Forgery) is an attack where a malicious site tricks your browser into performing an action on another site where you are logged in, without your knowledge.
- Unvalidated redirects after signup with OAuth. This is when a website redirects you to another page after signup without checking if the destination is safe, which can be abused to send you to a malicious site.
- Other well-known OAuth issues.
A state parameter was present throughout the OAuth flow. The state parameter is a random value that the website sends to Google and expects back, to ensure that the response is not forged. Because of this, CSRF was not possible, and attempts to bypass the state check did not succeed.

The next idea came from the change email functionality in the profile settings. The researcher changed the OAuth account email from [redacted] to [redacted]. The application states that after changing the email, logging in with Google OAuth is no longer possible.

The researcher then used the unlink option. The email change went through successfully, and notably the new email address was not verified. With the account now on the email and password method, the researcher logged in again that way. Then came the observation that mattered: logging in with the old Google OAuth account, the one that had already been unlinked, still succeeded and landed in the same old account. In other words, the OAuth link had been removed from the profile, yet the OAuth login still resolved to that account.
Exploitation
The researcher turned this into an account takeover scenario, built on the fact that the email change is not verified. Because no verification of the new address takes place, an attacker can set the account email to somebody else's address. The scenario as described:
Step 1: create an account with OAuth
The attacker creates an account on a.target.com using Google OAuth.
Step 2: change the email to the victim's address
The attacker changes the account email to the victim's email address.
Step 3: the victim registers or resets
When the victim tries to create an account on a.target.com, the application reports that the email already exists. The victim then resets the password and logs in with the email and password method.
Step 4: the attacker logs in through OAuth
The attacker is also able to log in to the victim's account using OAuth.


The write-up closes by noting that the bug does not carry much severity, but that some companies paid well for it, and that some paid nothing.

Root cause
The report describes the behaviour rather than the code, so the underlying mistake is inferred. Two weaknesses combine. First, the email change is applied without verifying the new address, which lets an attacker claim an address they do not control. Second, unlinking Google OAuth does not invalidate the association used at login: the old OAuth identity still authenticates into the same account after the unlink. The state parameter protected the flows against CSRF, but it does nothing about either of these two problems.
Impact
An attacker can take over an account belonging to a victim who registers or resets a password on the subdomain after the attacker has claimed their email address. The attacker can also log in to the victim's account through OAuth while the victim uses the email and password method. The researcher is explicit that the severity is not high, and the scenario depends on the victim subsequently creating an account or resetting a password on the same subdomain.
Fix
The report does not say what was changed. Based on the behaviour described, the email change should require verification of the new address before it takes effect, and unlinking an OAuth identity should invalidate that identity so it can no longer authenticate into the account.
Variants to test
- Change the account email to an address you do not control and check whether the application lets you log in or receive mail at it before verification. A positive result is an active session or delivered mail on an unverified address.
- Unlink an OAuth provider and then attempt to log in with that same provider identity. A positive result is landing back in the original account.
- Link a second OAuth identity, unlink the first, and check which identity still resolves to the account.
- Register with OAuth, change the email to a victim's address, and observe whether registration for that address reports it as already taken.
- Repeat the email change and unlink sequence on other subdomains in scope to see whether the behaviour is shared across the application.
Glossary
- OAuth: An open standard for access delegation, commonly used as a way for users to grant websites or applications access to their information on other websites without giving them passwords. For example, "Log in with Google".
- CSRF (Cross-Site Request Forgery): An attack that forces an end user to execute unwanted actions on a web application in which they are currently authenticated. It tricks the victim's browser into sending a request to a vulnerable site, using the victim's existing session.
- State parameter: A parameter used in OAuth to maintain state between the request and callback. It is used to prevent CSRF attacks by ensuring that the response matches the request.
- Subdomain: A domain that is part of a larger domain. For example,
mail.example.comis a subdomain ofexample.com. - Bug bounty program: A program where organizations reward individuals for finding and reporting security vulnerabilities in their systems.
- Private program: A bug bounty program that is not open to the public; only invited researchers can participate.
- Account takeover: A type of attack where an attacker gains unauthorized access to a user's account.
- Email verification: The process of confirming that an email address belongs to the person who claims it, typically by sending a verification link or code to that address.
- Unlink: In the context of OAuth, removing the association between a user's account on the website and their OAuth provider account (e.g. Google).
- Severity: A measure of the potential impact of a vulnerability, often rated as low, medium, high, or critical.
- Redirect: A response from a web server that instructs the browser to navigate to a different URL.
- Session: A period of interaction between a user and a website, during which the user's identity is remembered, often using cookies.
- Cookie: A small piece of data stored on the user's computer by the web browser while browsing a website, used to remember stateful information or to record the user's browsing activity.
- Token: A piece of data that represents the user's authentication or authorization, often used in OAuth to grant access to resources.
- API: Application Programming Interface, a set of rules that allows different software applications to communicate with each other.
- Endpoint: A specific URL or URI where an API or web service can be accessed.
- Parameter: A variable in a request that can be used to pass data to the server.
- Header: Part of an HTTP request or response that contains metadata, such as content type or authentication information.
- Payload: The part of a request that carries the actual data, such as form fields or JSON body.
- Vulnerability: A weakness in a system that can be exploited to compromise its security.
- Exploit: A piece of software, a chunk of data, or a sequence of commands that takes advantage of a vulnerability to cause unintended or unanticipated behaviour.
- Impact: The potential damage that could result from exploiting a vulnerability.
- Root cause: The fundamental reason why a vulnerability exists.
- Fix: A change made to a system to remove a vulnerability.
- Variants: Different ways or scenarios in which a vulnerability might be exploited or tested.