Skip to content

Commit d319c52

Browse files
authored
Merge pull request #254 from HackTricks-wiki/update_GatewayToHeaven__Finding_a_Cross-Tenant_Vulnerabil_20260203_185749
GatewayToHeaven Finding a Cross-Tenant Vulnerability in GCP'...
2 parents 6d8fa0c + 9b92359 commit d319c52

3 files changed

Lines changed: 76 additions & 1 deletion

File tree

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
- [GCP - Federation Abuse](pentesting-cloud/gcp-security/gcp-basic-information/gcp-federation-abuse.md)
8686
- [GCP - Permissions for a Pentest](pentesting-cloud/gcp-security/gcp-permissions-for-a-pentest.md)
8787
- [GCP - Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/README.md)
88+
- [GCP - Apigee Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-apigee-post-exploitation.md)
8889
- [GCP - App Engine Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-app-engine-post-exploitation.md)
8990
- [GCP - Artifact Registry Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-artifact-registry-post-exploitation.md)
9091
- [GCP - Bigtable Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-bigtable-post-exploitation.md)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# GCP - Post Exploitation
22

33
{{#include ../../../banners/hacktricks-training.md}}
4-
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# GCP - Apigee Post Exploitation
2+
3+
{{#include ../../../banners/hacktricks-training.md}}
4+
5+
## Apigee metadata SSRF -> Dataflow cross-tenant pivot
6+
7+
A single Apigee tenant project can be abused to reach the Message Processor metadata server, steal its service account, and pivot into a shared Dataflow analytics pipeline that reads/writes cross-tenant buckets.
8+
9+
### Expose the metadata server through Apigee
10+
11+
- Set an Apigee proxy target to `http://169.254.169.254` and request tokens from `/computeMetadata/v1/instance/service-accounts/default/token` with `Metadata-Flavor: Google`.
12+
- GCP metadata rejects requests containing `X-Forwarded-For`; Apigee adds it by default. Strip it with `AssignMessage` before proxying:
13+
14+
```xml
15+
<AssignMessage name="strip-xff">
16+
<Remove>
17+
<Headers>
18+
<Header name="X-Forwarded-For"/>
19+
</Headers>
20+
</Remove>
21+
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
22+
</AssignMessage>
23+
```
24+
25+
### Enumerate the stolen Apigee service account
26+
27+
- The leaked SA (Google-managed under `gcp-sa-apigee`) can be enumerated with tools like [gcpwn](https://github.com/NetSPI/gcpwn) to quickly test permissions.
28+
- Observed powerful permissions included **Compute disk/snapshot admin**, **GCS read/write across tenant buckets**, and **Pub/Sub topic publish**. Basic discovery:
29+
30+
```bash
31+
gcloud compute disks list --project <tenant-project>
32+
```
33+
34+
### Snapshot exfiltration for opaque managed services
35+
36+
With disk/snapshot rights you can inspect managed runtimes offline even if you cannot log into the tenant project:
37+
38+
1. Create a snapshot of a target disk in the tenant project.
39+
2. Copy/migrate the snapshot to your project.
40+
3. Recreate a disk from the snapshot and attach it to your VM.
41+
4. Mount and inspect logs/configs to recover internal bucket names, service accounts, and pipeline options.
42+
43+
### Dataflow dependency replacement via writable staging bucket
44+
45+
- Analytics workers pulled JARs from a GCS staging bucket on startup. Because the Apigee SA had bucket write, download and patch the JAR (e.g., with Recaf) to call `http://169.254.169.254/computeMetadata/v1/instance/service-accounts/default/token` and steal the **Dataflow worker** token.
46+
- Dataflow workers lacked internet egress; exfiltrate by writing the token into an attacker-controlled GCS bucket using the in-cluster GCP APIs.
47+
48+
### Force malicious JAR execution by abusing autoscaling
49+
50+
Existing workers will not reload replaced artifacts. Flood the pipeline input to trigger new workers:
51+
52+
```bash
53+
for i in {1..5000}; do
54+
gcloud pubsub topics publish apigee-analytics-notifications \
55+
--message "flood-$i" --project <tenant-project>
56+
done
57+
```
58+
59+
Newly provisioned instances fetch the patched JARs and leak the Dataflow SA token.
60+
61+
### Cross-tenant bucket design flaw
62+
63+
Decompiled Dataflow code showed cache paths like `revenue/edge/<api|mint>/tenant2TenantGroupCacheDir` under a shared metadata bucket, without any tenant-specific component. With the Dataflow token you can read/write:
64+
65+
- `tenantToTenantGroup` caches exposing other tenants' project+environment names.
66+
- `customFields` and `datastores` folders holding per-request analytics (including end-user IPs and plaintext access tokens) across all tenants.
67+
- Write access implies potential analytics tampering/poisoning.
68+
69+
## References
70+
71+
- [GatewayToHeaven: Finding a Cross-Tenant Vulnerability in GCP's Apigee](https://omeramiad.com/posts/gatewaytoheaven-gcp-cross-tenant-vulnerability/)
72+
- [AssignMessage policy - header removal](https://cloud.google.com/apigee/docs/api-platform/reference/policies/assign-message-policy)
73+
74+
{{#include ../../../banners/hacktricks-training.md}}
75+

0 commit comments

Comments
 (0)