Skip to content
Info disclosure Write-up Intermediate

Gsuite Domain Takeover Through Delegation

An API endpoint that updates company settings returned Google service account credentials in its response, even though the GET method on the same route did not. An attacker who could read that response, for example through an XSS payload, could obtain the credentials and use domain-wide delegation to act as any user in the GSuite domain.

Pavel Shabarkin Follow

Published on infosecwriteups.com

It is not rare for a modern web application to have OAuth integrations, each of them requires specific set of security policies to be implemented. By exploiting a broken business logic of a web app, it can be possible to retrieve even Google service account credentials integrated through the OAuth flow and compromise…

Pavel Shabarkin, on infosecwriteups.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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the settings update endpoint returned the full company object, including the stored Google service account credentials, instead of filtering sensitive fields from the response.

Impact

An attacker with the credentials could read and send email, read and write Drive files and view Docs and Sheets as domain users, and could reach further GCP permissions if least privilege was not applied.

What the attacker needed

Admin-level access to company settings; victim runs attacker script (XSS); domain-wide delegation enabled

The fix

The endpoint should be changed so it never returns service account credentials, and credentials should follow least privilege.

How it was found

  1. Send a settings update request to the company settings API endpoint
  2. Observe that the response contains a google_service_account field with credentials
  3. Use an XSS payload to make the same request on a victim's behalf and forward the response to an attacker host
  4. Use the stolen credentials with domain-wide delegation to access GSuite services as a chosen user

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A service account is a robot account that an app uses to talk to Google on a company's behalf. If someone steals its key file, and the company has allowed that robot to act for every user (called domain-wide delegation), the thief can read mail and files as anyone in the company. Here the key was handed back in the reply to a settings update request.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.