Skip to content
Account takeover Write-up Intermediate

Google OAuth Account Takeover via Expired Domains

Apps that use Google Sign-In trusted the email and hosted-domain claims, so when a defunct company's domain expired and was bought by someone else, that person could recreate old staff addresses and log into the former employees' SaaS accounts. The researcher demonstrated access to Slack, Notion, Zoom, ChatGPT and HR systems holding sensitive documents.

Muhammad Asim Shahzad Follow

Published on masimshahzad.medium.com

Bug Bounty

Muhammad Asim Shahzad, on masimshahzad.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. 5 min read.

Context

This is an analytical case study of a public disclosure, not a first-hand bug hunt. The subject is the "Sign in with Google" flow and the claims a relying party receives from Google when a user authenticates. Two claims are central: email, the address of the Google account, and hd, the hosted Workspace domain the account belongs to. Many SaaS applications use one or both of these values to decide who the user is, or to let them join a company workspace.

The scenario the disclosure describes is a startup that shuts down and lets its domain expire. A new owner registers the domain, recreates the old staff email addresses in Google Workspace, and then clicks "Sign in with Google" on the SaaS tools the defunct company used. Because Google issues the same email and hd claims for the recreated addresses, the relying party cannot tell the buyer from the original employee.

AI-generated illustration From the original on masimshahzad.medium.com

The illustration above is AI-generated and accompanies the write-up.

Setup

The demonstration was carried out by Dylan Ayrey of Truffle Security in 2024. The precondition is a domain that has changed owner: the original organisation is gone, the domain has lapsed, and the new owner can register it and stand up Google Workspace on it. No specific domain is named in the write-up.

The targets are third-party SaaS applications that trust the email and hd claims from Google. The accounts Ayrey opened in the demonstration were ex-employees' Slack, Notion, Zoom, ChatGPT and HR accounts.

Finding it

The observation is that neither email nor hd proves continuity of ownership. If a new owner registers the old domain in Google Workspace and recreates an address, Google issues the same email and hd claims as before. The relying party sees no difference between the original employee and the buyer, so any login or workspace-join decision based on those two values alone is made on behalf of the wrong person.

Ayrey bought one defunct domain and got in. The HR systems he reached held tax documents, pay stubs, insurance details and Social Security numbers. He also notes a compounding effect: some tools list every workspace member, which gives an attacker more names to recreate and more accounts to open.

To size the problem, he searched Crunchbase data and found more than 100,000 failed-startup domains for sale. Truffle's own back-of-envelope estimate put potential exposure above 10 million accounts.

Exploitation

Step 1: Acquire a lapsed domain

Buy a domain belonging to a defunct startup. The write-up does not name the domain used.

Step 2: Recreate the identity

Register the domain in Google Workspace and recreate the former staff email addresses. Google then issues the same email and hd claims for those addresses as it did for the original employees.

Step 3: Sign in with Google

Click "Sign in with Google" on the SaaS tools the company used. The relying party receives the claims and, because it trusts email and hd, logs the new owner in as the former employee or admits them to the company workspace.

Step 4: Enumerate and expand

Where a tool lists every workspace member, use those names to recreate further addresses and open further accounts. In the demonstration this reached Slack, Notion, Zoom, ChatGPT and HR accounts, with the HR systems exposing tax documents, pay stubs, insurance details and Social Security numbers.

Root cause

The flaw is a design issue across the identity provider and the relying parties, mapped analytically to CWE-287 (Improper Authentication) and CWE-672 (Operation on a Resource after Expiration or Release). There is no CVE.

Relying parties treat email and hd as stable identifiers. They are not: they describe who controls a domain now, not who owned the account before. Google's documented answer is the sub claim, a per-account identifier, and Google updated its guidance to say email must not be used as a unique ID. Ayrey argues sub is unreliable in practice, citing an engineer who saw it change for a small share of logins; Google disputed that to reporters. Ayrey proposed two immutable claims, one for the user and one for the workspace. As of his January 2025 write-up, no platform fix had shipped.

Google first marked the report "won't fix", then reopened it and paid $1,337 through its vulnerability programme.

Impact

An attacker who acquires a lapsed domain can take over accounts at every SaaS tool that trusts the old email and domain claims, without a password. The victims are former employees, who cannot protect accounts they no longer control, and founders, who often forget the SaaS tools left behind. The data reached in the demonstration included tax documents, pay stubs, insurance details and Social Security numbers. The exposure estimate is above 10 million accounts, based on more than 100,000 failed-startup domains found for sale in Crunchbase data; that figure is a back-of-envelope estimate, not a measured count.

Fix

No platform fix had shipped as of the January 2025 write-up. The defensive measures below are the author's own analysis of what relying parties should do.

  1. Key accounts on (iss, sub). Treat email and hd as profile hints, never as the lookup key.
  2. Never auto-merge on email. If a known email arrives with a different sub, route to recovery instead of logging in.
  3. Do not let dormant domains auto-join. Domain-based workspace joining should stop when the customer organisation is closed.

The author's own reference implementation:

Python
def on_google_login(claims):            ident = (claims["iss"], claims["sub"])    acct = accounts.by_identity(ident)    if acct:        return login(acct)    acct = accounts.by_email(claims.get("email", ""))    if acct and acct.identity and acct.identity != ident:        audit("same_email_new_sub", acct.id)                return require_recovery(acct)                   if acct and acct.identity is None:        return require_existing_login_to_link(acct)     org = orgs.by_domain(claims.get("hd"))    if org and org.status != "active":        return deny("workspace_closed")                 return start_signup(ident, org)

The function looks the account up by (iss, sub) first. If an account exists for that identity, it logs in. If an account exists for the email but with a different identity, it audits the event and forces recovery rather than logging in. If the account has no identity yet, it requires an existing login to link. Finally, it refuses to start a signup into a workspace whose organisation is not active.

Variants to test

  • Email-keyed account linking. Create an account with one identity, then present the same email from a different identity. A positive result is being logged into the existing account instead of being sent to recovery.
  • Domain-based workspace auto-join. Present an hd value for an organisation that is closed or dormant. A positive result is being admitted to the workspace.
  • sub stability. Track the sub claim for the same account across logins. A positive result is the value changing, which would break identity keying even after the fix above.
  • Member enumeration. Check whether a tool lists every workspace member. A positive result is a full member list that supplies names for further address recreation.

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

Imagine a company that goes out of business. Its website address, its domain, stops being paid for and eventually becomes available for anyone to buy. A security researcher named Dylan Ayrey, from a company called Truffle Security, bought one of these dead domains. He then set up Google email addresses on it that matched the old employees' addresses, and used the "Sign in with Google" button on the online tools the dead company used to sign in. He got into former employees' Slack, Notion, Zoom, ChatGPT and HR accounts, without ever knowing a password.

This article is a case study of that public disclosure, written for someone who has never studied security. It is not a first-hand bug hunt. The write-up it is based on is analytical, and the defensive code at the end is the author's own analysis.

AI-generated illustration From the original on masimshahzad.medium.com

The illustration above is AI-generated and accompanies the write-up.

The pieces you need to know first

Before the story makes sense, a few everyday ideas need explaining.

A domain is the part of a web address after the @ in an email or after www in a website, like example.com. Someone has to pay a registrar every year to keep it. If the payment stops, the domain eventually expires and anyone can register it.

Google Workspace is Google's paid product for companies. A company can attach its own domain to it, so staff get addresses like [redacted] instead of [redacted]. The company's IT administrator creates and deletes those addresses.

OAuth is a way for one website to ask another website to confirm who you are, without sharing your password. When you click "Sign in with Google" on a shopping site, the shopping site sends you to Google, Google checks your login, and Google sends a short message back to the shopping site saying "this person is who they say they are". The shopping site is called the relying party, because it relies on Google's answer. Google is called the identity provider.

Claims are the pieces of information in that message from Google. Two matter here:

  • email: the address of the Google account, for example [redacted].
  • hd: short for hosted domain, the company domain the account belongs to, for example company.com.

SaaS stands for software as a service: online tools you use through a browser and pay for monthly, such as Slack for chat, Notion for notes, Zoom for video calls, or an HR system for payroll. Each of these is a separate relying party with its own "Sign in with Google" button.

Account takeover is the security term for logging into someone else's account. It is the harm in this story.

CWE is a catalogue of common weakness types, like a library index for security bugs. CVE is a catalogue of specific, individually numbered vulnerabilities in specific products. This case has no CVE because it is not a bug in one product; it is a design problem shared by many products.

The setup

The demonstration was carried out by Dylan Ayrey of Truffle Security in 2024. The precondition is a domain that has changed owner: the original organisation is gone, the domain has lapsed, and the new owner can register it and stand up Google Workspace on it. The write-up does not name the specific domain used.

The targets are third-party SaaS applications that trust the email and hd claims from Google. The accounts Ayrey opened in the demonstration were ex-employees' Slack, Notion, Zoom, ChatGPT and HR accounts.

Finding it

The core observation is simple: neither email nor hd proves that the same person, or the same company, is still behind the address. If a new owner registers the old domain in Google Workspace and recreates an address, Google issues the same email and hd claims as before. The relying party sees no difference between the original employee and the buyer, so any login or workspace-join decision based on those two values alone is made on behalf of the wrong person.

A useful comparison: a bouncer at a club checks that your name is on the guest list. If someone else can legally change their name to match a name on the list, the bouncer has no way to tell them apart. The list says "Jane", the new person says "Jane", and the bouncer lets them in. The email address is the name on the list; the domain is who is allowed to hand out that name.

Ayrey bought one defunct domain and got in. The HR systems he reached held tax documents, pay stubs, insurance details and Social Security numbers. He also notes a compounding effect: some tools list every workspace member, which gives an attacker more names to recreate and more accounts to open.

To size the problem, he searched Crunchbase data, a public database of companies and funding, and found more than 100,000 failed-startup domains for sale. Truffle's own back-of-envelope estimate put potential exposure above 10 million accounts. That figure is a rough estimate, not a measured count.

Exploitation, step by step

Step 1: Acquire a lapsed domain

Buy a domain belonging to a defunct startup. The write-up does not name the domain used.

Step 2: Recreate the identity

Register the domain in Google Workspace and recreate the former staff email addresses. Google then issues the same email and hd claims for those addresses as it did for the original employees. The reason for this step is that the relying party cannot tell the buyer from the original employee.

Step 3: Sign in with Google

Click "Sign in with Google" on the SaaS tools the company used. The relying party receives the claims and, because it trusts email and hd, logs the new owner in as the former employee or admits them to the company workspace. The reason this works is that the tool trusts the email and domain claims from Google.

Step 4: Enumerate and expand

Where a tool lists every workspace member, use those names to recreate further addresses and open further accounts. In the demonstration this reached Slack, Notion, Zoom, ChatGPT and HR accounts, with the HR systems exposing tax documents, pay stubs, insurance details and Social Security numbers. The reason for this step is that some tools list every workspace member, and each name is another address you can recreate.

Why it works

The flaw is a design issue across the identity provider and the relying parties, mapped analytically to CWE-287 (Improper Authentication) and CWE-672 (Operation on a Resource after Expiration or Release). There is no CVE.

Relying parties treat email and hd as stable identifiers. They are not: they describe who controls a domain now, not who owned the account before. Google's documented answer is the sub claim, a per-account identifier, and Google updated its guidance to say email must not be used as a unique ID. Ayrey argues sub is unreliable in practice, citing an engineer who saw it change for a small share of logins; Google disputed that to reporters. Ayrey proposed two immutable claims, one for the user and one for the workspace. As of his January 2025 write-up, no platform fix had shipped.

Google first marked the report "won't fix", then reopened it and paid $1,337 through its vulnerability programme.

What it means for real people

An attacker who acquires a lapsed domain can take over accounts at every SaaS tool that trusts the old email and domain claims, without a password. The victims are former employees, who cannot protect accounts they no longer control, and founders, who often forget the SaaS tools left behind. The data reached in the demonstration included tax documents, pay stubs, insurance details and Social Security numbers. The exposure estimate is above 10 million accounts, based on more than 100,000 failed-startup domains found for sale in Crunchbase data; that figure is a back-of-envelope estimate, not a measured count.

How to defend against it

No platform fix had shipped as of the January 2025 write-up. The defensive measures below are the author's own analysis of what relying parties should do.

  1. Key accounts on (iss, sub). Treat email and hd as profile hints, never as the lookup key.
  2. Never auto-merge on email. If a known email arrives with a different sub, route to recovery instead of logging in.
  3. Do not let dormant domains auto-join. Domain-based workspace joining should stop when the customer organisation is closed.

The author's own reference implementation:

Python
def on_google_login(claims):            ident = (claims["iss"], claims["sub"])    acct = accounts.by_identity(ident)    if acct:        return login(acct)    acct = accounts.by_email(claims.get("email", ""))    if acct and acct.identity and acct.identity != ident:        audit("same_email_new_sub", acct.id)                return require_recovery(acct)                   if acct and acct.identity is None:        return require_existing_login_to_link(acct)     org = orgs.by_domain(claims.get("hd"))    if org and org.status != "active":        return deny("workspace_closed")                 return start_signup(ident, org)

Line by line, in plain words:

  • def on_google_login(claims): defines a function that runs whenever someone clicks "Sign in with Google". It receives the claims, the message from Google.
  • ident = (claims["iss"], claims["sub"]) builds the real identity from two values: iss, the issuer (which identity provider said this), and sub, the subject (the per-account identifier). Together they are the reliable key.
  • acct = accounts.by_identity(ident) looks up an existing account using that reliable key.
  • if acct: return login(acct) if an account is found, log the person in. This is the normal, safe path.
  • acct = accounts.by_email(claims.get("email", "")) if no account matched the identity, look one up by email instead, as a fallback.
  • if acct and acct.identity and acct.identity != ident: if an account exists for that email but it is already tied to a different identity, something is wrong: the same email is arriving from a new identity.
  • audit("same_email_new_sub", acct.id) record the event in the audit log so someone can investigate later.
  • return require_recovery(acct) do not log in. Send the person through account recovery instead.
  • if acct and acct.identity is None: if an account exists for the email but has never been tied to an identity, it is an old account created before this check existed.
  • return require_existing_login_to_link(acct) require the person to log in the old way before linking the new identity, so a stranger cannot claim it.
  • org = orgs.by_domain(claims.get("hd")) look up the organisation that owns the hd domain.
  • if org and org.status != "active": if that organisation exists but is not active, for example because it closed down,
  • return deny("workspace_closed") refuse the login with a clear reason.
  • return start_signup(ident, org) otherwise, start a normal signup using the reliable identity and the organisation.

Things to test if you build one of these

  • Email-keyed account linking. Create an account with one identity, then present the same email from a different identity. A positive result is being logged into the existing account instead of being sent to recovery.
  • Domain-based workspace auto-join. Present an hd value for an organisation that is closed or dormant. A positive result is being admitted to the workspace.
  • sub stability. Track the sub claim for the same account across logins. A positive result is the value changing, which would break identity keying even after the fix above.
  • Member enumeration. Check whether a tool lists every workspace member. A positive result is a full member list that supplies names for further address recreation.

Glossary

  • Account takeover: logging into someone else's account without their permission.
  • Claim: a piece of information about you that an identity provider sends to a relying party, such as your email or your company domain.
  • Crunchbase: a public database of companies, funding and founders.
  • CVE: a numbered entry in a public catalogue of specific vulnerabilities in specific products.
  • CWE: a catalogue of common weakness types, used to classify kinds of security bugs.
  • Domain: the part of a web or email address after the @ or www, such as example.com, which someone pays to keep registered.
  • email claim: the Google account address sent to a relying party.
  • hd claim: the hosted domain, meaning the company domain a Google Workspace account belongs to.
  • Identity provider: the service that confirms who you are, here Google.
  • iss claim: the issuer, meaning which identity provider produced the claims.
  • OAuth: a system that lets one website ask another to confirm your identity without sharing your password.
  • Relying party: the website or app that trusts the identity provider's answer, such as Slack or Notion.
  • SaaS: software as a service, online tools you use in a browser and pay for monthly.
  • sub claim: the subject, a per-account identifier that Google documents as the stable identifier.
  • Vulnerability programme: a scheme where a company pays researchers who report security problems to it.
  • Workspace: a company's shared space inside a SaaS tool, where its staff accounts live.
  • Google Workspace: Google's paid product that lets a company use its own domain for staff email addresses.

More by Muhammad Asim Shahzad

View all

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