GCP

Three Main Components of Google Cloud are:

  • Cloud Identity

  • Google Workspace

  • Google Cloud Platform

Reminder: Add basic concepts

Attack Vectors

Attackers can obtain GCP credentials through multiple vectors:

  • Exploiting web apps hosted on GCP

    • SSRF β†’ Access metadata service

    • RCE β†’ Dump environment variables, application config files, or mounted service account keys

  • Open Source Intelligence (Leaked service account keys on GitHub, GitLab, or public repos)

  • Phishing / Social Engineering

  • Public GCS buckets containing service account keys or JSON credential files.

Stealing Service Account Tokens via SSRF

  • Send request to http://169.254.169.254 or http://metadata.google.internal/ along with header Metadata-Flavor: Google.

  • To send this header along with the request, we use gopher protocol.

  • Example: http://169.254.169.254/computeMetadata/v1/instance/service-accounts/

Some SSRF filters only allow http://metadata.google.internal/ instead of raw IP. Both resolve to the metadata service.

Stealing Service Account Tokens via RCE

  • Check environment variables:

  • Check for credential files:

  • Query the Metadata Service (VMs, GKE, some managed services):

Authentication

  • Login with Gmail account:

  • Authenticate using Service Account key file:

  • Use an access token file:

  • Send token directly with curl:

  • Authenticate with Google HMAC credentials:

By default, gsutil reuses gcloud credentials. If you want gsutil to use only HMAC creds and not your gcloud login, disable credential passing: gcloud config set pass_credentials_to_gsutil false

Check current authentication details:

Show active configuration:

Enumeration

Organization Enumeration

If you have only project-level access, you may not see org info. Try enumerating projects and their parent orgs with:

Project Enumeration

Service Accounts Enumeration

IAM Roles & Service Account Permissions

Services Enumeration

Privilege Escalation & Lateral Movement

Implicit Delegation (iam.serviceAccounts.implicitDelegation)

  • This permission allows a service account to impersonate another service account without requiring explicit roles/iam.serviceAccountTokenCreator permissions.

  • It works by letting an attacker delegate access from an account they already control to a more privileged service account.

signJWT (iam.serviceAccounts.signJwt)

  • This permission allows signing of arbitrary JWTs (JSON Web Tokens) on behalf of a service account.

  • JWTs can then be exchanged with Google’s OAuth2 endpoint for valid access tokens, essentially allowing the attacker to impersonate the service account.

Service Account Impersonation (iam.serviceAccountTokenCreator)

  • It allows a principal (user, service account, or group) to impersonate service accounts by generating tokens/credentials on their behalf.

Last updated