Skip to content

Commit 6a99acf

Browse files
authored
Merge pull request #306 from HackTricks-wiki/update_Hacking_Google_with_AI_AI-Assisted_Discovery-Doc_f250207268e52efb
Hacking Google with AI AI-Assisted Discovery-Document Fuzzin...
2 parents a11e2ff + 108413b commit 6a99acf

1 file changed

Lines changed: 102 additions & 1 deletion

File tree

src/pentesting-cloud/gcp-security/gcp-unauthenticated-enum-and-access/gcp-api-keys-unauthenticated-enum.md

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,111 @@ Help Token: ARD_zUaNgNilGTg9oYUnMhfa3foMvL7qspRpBJ-YZog8RLbTjCTBolt_WjQQ3myTaOqu
7575
reason: AUTH_PERMISSION_DENIED
7676
```
7777
78-
### Brute Force API endspoints
78+
### Discovery-document driven API recon
79+
80+
Once you have a valid key, don't just test the obvious public APIs. In Google environments, **discovery documents** can work as a machine-readable attack-surface map exposing **resources, methods, paths, HTTP verbs, parameters, and request/response schemas**.
81+
82+
Useful targets:
83+
84+
```bash
85+
# Public / common path
86+
curl -s 'https://serviceusage.googleapis.com/$discovery/rest?key=<api-key>'
87+
88+
# Hidden docs behind a visibility label
89+
curl -s 'https://serviceusage.googleapis.com/$discovery/rest?labels=GOOGLE_INTERNAL&key=<api-key>'
90+
```
91+
92+
Notes:
93+
94+
- Compare the document size and method count with and without labels such as `GOOGLE_INTERNAL`.
95+
- A **true nonexistent method** usually returns an **HTML 404**. A **JSON 404** with `Method not found.` can indicate that the method exists but the **API key project is missing a required visibility label**.
96+
- Some first-party APIs are easier to reach via `*.clients6.google.com` or undocumented `*-pa.googleapis.com` hosts than via the public API explorer.
97+
98+
This is specially useful to enumerate **internal/admin APIs accidentally exposed to the Internet** and to build custom fuzzers from the schema instead of guessing JSON fields manually.
99+
100+
### Key ownership filtering at scale
101+
102+
If you collect many Google API keys from APKs, browser traffic, IPAs or binaries, you may want to quickly identify **which project owns each key** and whether it belongs to the target company.
103+
104+
A practical trick is to intentionally call an API that is **not enabled** for the key. Google frequently leaks the backing **project number** in the error:
105+
106+
```bash
107+
curl -s 'https://protos.googleapis.com/$discovery/rest?key=<api-key>'
108+
```
109+
110+
Look for messages like:
111+
112+
```text
113+
Protos API has not been used in project 244648151629 before or it is disabled
114+
```
115+
116+
That project number can then be correlated with other endpoints, leaked metadata, or internal company-mapping logic to separate **in-scope first-party keys** from customer / third-party projects.
117+
118+
### Handle key restrictions before discarding a key
119+
120+
A restricted key is not necessarily useless. Preserve the context where the key was found and replay requests with the matching headers:
121+
122+
```bash
123+
# Browser restricted
124+
curl -H 'X-Goog-Api-Key: <api-key>' \
125+
-H 'Referer: https://target.google.com' \
126+
'https://servicemanagement.googleapis.com/v1/operations'
127+
128+
# iOS restricted
129+
curl -H 'X-Goog-Api-Key: <api-key>' \
130+
-H 'X-Ios-Bundle-Identifier: com.google.GoogleMobile' \
131+
'https://servicemanagement.clients6.google.com/v1/operations'
132+
133+
# Android restricted
134+
curl -H 'X-Goog-Api-Key: <api-key>' \
135+
-H 'X-Android-Package: com.google.android.settings.intelligence' \
136+
-H 'X-Android-Cert: <sha1-signing-cert>' \
137+
'https://servicemanagement.clients6.google.com/v1/operations'
138+
```
139+
140+
Common restriction classes:
141+
142+
- **HTTP Referer**
143+
- **iOS bundle ID** (`X-Ios-Bundle-Identifier`)
144+
- **Android package + signing cert** (`X-Android-Package` + `X-Android-Cert`)
145+
- **Server IP** restrictions, which generally cannot be bypassed remotely
146+
147+
### First-party auth / origin whitelist hints
148+
149+
Some Google web APIs accept a mix of **session cookie + first-party authorization headers** and are hosted on `*.clients6.google.com`. When testing these APIs:
150+
151+
- Keep `Origin` and `Referer` compatible with the product that normally uses the API.
152+
- A `401` with `reason: SESSION_COOKIE_INVALID` can actually mean the **origin is not whitelisted**, not that the cookie is bad.
153+
- Publicly reachable APIs that only accept internal origins such as `*.corp.google.com` are high-value candidates for broken access control review.
154+
155+
### Brute force enabled APIs and fuzz documented methods
79156
80157
As you might not know which APIs are enabled in the project, it would be interesting to run the tool [https://github.com/ozguralp/gmapsapiscanner](https://github.com/ozguralp/gmapsapiscanner) and check **what you can access with the API key.**
81158
159+
After you identify reachable services, prefer **schema-driven fuzzing** over blind guessing:
160+
161+
- Generate requests directly from discovery docs
162+
- Replay the same request with **all known working keys**
163+
- Normalize errors so you can distinguish **invalid input** from **visibility-label / auth / restriction** failures
164+
- For numeric object identifiers, try nearby values such as `ID-1`, `ID+1`, `1`, `2`, `100`, `1000`
165+
- Only report when you confirm **cross-user data access** or another real authorization failure; plain enumeration is usually not enough by itself
166+
167+
### Common vuln pattern: unauthenticated direct-object reference
168+
169+
A recurring bug pattern is an **internal/admin API** that accepts a victim-controlled identifier (for example `gaiaId`) and only validates that the request carries a usable API key, but **never checks whether the caller is authorized to access that specific object**.
170+
171+
```bash
172+
curl 'https://gfibervoice-pa.googleapis.com/v1/BssGetVoiceSettings?gaiaId=<victim_gaia_id>' \
173+
-H 'X-Goog-Api-Key: <api-key>'
174+
```
175+
176+
If the endpoint returns another user's phone number, email address, settings, or other private fields, treat it as a classic **IDOR / broken access control** issue.
177+
178+
## References
179+
180+
- [Hacking Google with AI: AI-Assisted Discovery-Document Fuzzing of Google APIs](https://brutecat.com/articles/hacking-google-with-ai)
181+
- [Google APIs Explorer](https://developers.google.com/apis-explorer)
182+
82183
{{#include ../../../banners/hacktricks-training.md}}
83184
84185

0 commit comments

Comments
 (0)