GCP

This playbook outlines offensive security techniques in Google Cloud Platform (GCP). It is structured around the red teaming lifecycle: reconnaissance, exploitation, privilege escalation, lateral move

1. GCP Cloud Overview

Core Components

  • Google Cloud IAM – Identity and Access Management (users, service accounts, roles, policies).

  • Projects – Organizational units that contain resources.

  • Service Accounts – Identities for workloads (VMs, functions, apps).

  • Cloud Resource Hierarchy – Org → Folders → Projects → Resources.

Planes of Access

  • Control Plane – Google Cloud Console, Cloud SDK (gcloud), REST APIs.

  • Data Plane – Actual workloads (VMs, buckets, databases).

🔑 Security Insight:

  • Compromise of Control Plane creds = full takeover.

  • Compromise of Service Account = privilege within project scope (but often escalatable).


2. Authentication & Credential Types

2.1 User Accounts

2.2 Service Accounts

  • Non-human principals for apps/VMs.

  • Auth via JSON key files or Metadata Server.

2.3 Access Tokens

  • OAuth2 bearer tokens (short-lived).

  • Commonly abused via SSRF → metadata server.

Get token inside VM


3. Enumeration

3.1 Identity Enumeration

Check current active account:

Get project ID:

List IAM policy for a project:

Find specific service account roles:


3.2 Service Account Enumeration

List all service accounts in a project:

Get details about a service account:

List keys associated with a service account:


3.3 Storage Enumeration

List storage buckets:

List objects in a bucket:

Download file from bucket:


4. Exploitation

4.1 Metadata Service Abuse (IMDS Equivalent)

Inside a VM, access metadata endpoint:

Use the token to authenticate:


4.2 Using Leaked Tokens

If attacker has a token (e.g., from logs, SSRF):

Example (from CTF-like scenario):


4.3 Privilege Escalation via Service Accounts

If SA has roles like roles/iam.serviceAccountUser or roles/editor, attacker can impersonate or escalate:


5. Post-Exploitation

5.1 Key Vaults / Secrets

If Cloud KMS or Secret Manager accessible:

5.2 BigQuery Data Dumping


6. Lateral Movement

  • Use compromised service account to pivot into other projects.

  • Enumerate organization-level roles:

  • Abuse roles like roles/resourcemanager.folderViewer, roles/resourcemanager.projectMover for movement.


7. Persistence

  • Create new service account and assign roles:

  • Add SSH key to compromised VM instance:


8. Detection & Mitigation

  • Monitor IAM policy changes (Cloud Audit Logs).

  • Restrict service account privileges (principle of least privilege).

  • Restrict metadata access (firewall, no public SSRF exposure).

  • Rotate keys/tokens frequently.

  • Enable VPC Service Controls to limit lateral movement.

Last updated