From dc6829761c19b4082cf7f9150e5cfc39dd20e2ce Mon Sep 17 00:00:00 2001 From: Translator Date: Tue, 16 Jun 2026 13:40:18 +0000 Subject: [PATCH] Translated ['', 'src/pentesting-cloud/gcp-security/gcp-unauthenticated-e --- .../gcp-api-keys-unauthenticated-enum.md | 123 +++++++++++++++--- 1 file changed, 107 insertions(+), 16 deletions(-) diff --git a/src/pentesting-cloud/gcp-security/gcp-unauthenticated-enum-and-access/gcp-api-keys-unauthenticated-enum.md b/src/pentesting-cloud/gcp-security/gcp-unauthenticated-enum-and-access/gcp-api-keys-unauthenticated-enum.md index 1dfd4f062..ab5f7df84 100644 --- a/src/pentesting-cloud/gcp-security/gcp-unauthenticated-enum-and-access/gcp-api-keys-unauthenticated-enum.md +++ b/src/pentesting-cloud/gcp-security/gcp-unauthenticated-enum-and-access/gcp-api-keys-unauthenticated-enum.md @@ -1,30 +1,30 @@ -# GCP - Enumeryzacja kluczy API bez uwierzytelnienia +# GCP - API Keys Unauthenticated Enum {{#include ../../../banners/hacktricks-training.md}} -## Klucze API +## API Keys -Aby uzyskać więcej informacji na temat kluczy API, sprawdź: +For more information about API Keys check: {{#ref}} ../gcp-services/gcp-api-keys-enum.md {{#endref}} -### Techniki OSINT +### OSINT techniques -**Klucze API Google są szeroko stosowane przez wszelkiego rodzaju aplikacje** działające po stronie klienta. Często można je znaleźć w kodzie źródłowym stron internetowych lub w żądaniach sieciowych, w aplikacjach mobilnych lub po prostu przeszukując regexy na platformach takich jak Github. +**Google API Keys are widely used by any kind of applications** that uses from the client side. It's common to find them in for websites source code or network requests, in mobile applications or just searching for regexes in platforms like Github. -Regex to: **`AIza[0-9A-Za-z_-]{35}`** +The regex is: **`AIza[0-9A-Za-z_-]{35}`** -Szukaj go na przykład w Githubie pod tym linkiem: [https://github.com/search?q=%2FAIza%5B0-9A-Za-z\_-%5D%7B35%7D%2F\&type=code\&ref=advsearch](https://github.com/search?q=%2FAIza%5B0-9A-Za-z_-%5D%7B35%7D%2F&type=code&ref=advsearch) +Search it for example in Github following: [https://github.com/search?q=%2FAIza%5B0-9A-Za-z\_-%5D%7B35%7D%2F\&type=code\&ref=advsearch](https://github.com/search?q=%2FAIza%5B0-9A-Za-z_-%5D%7B35%7D%2F&type=code&ref=advsearch) -### Sprawdź projekt GCP +### Check origin GCP project -To jest niezwykle przydatne, aby sprawdzić, **do którego projektu GCP należy klucz API, który znalazłeś**. Mamy różne opcje: +Jest to bardzo przydatne, aby sprawdzić, do **którego projektu GCP należy API key, które znalazłeś**. Mamy różne opcje: -- Skontaktuj się z `https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=` +- Contact `https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=` -Dla zwięzłości wynik został skrócony, ale w pełnym wyniku identyfikator projektu pojawia się więcej niż 5 razy. +Dla zwięzłości wynik został skrócony, ale w pełnym wyniku identyfikator projektu pojawia się więcej niż 5 razy ```bash curl -s "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=AIzaSyD[...]uE8Y" @@ -34,9 +34,9 @@ curl -s "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectCo "message": "Identity Toolkit API has not been used in project 943955951114 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project=943955951114 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", [...] ``` -- Skontaktuj się z `https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=` +- Skontaktuj się z `https://identitytoolkit.googleapis.com/v1/projects?key=` -Dla zwięzłości wyjście zostało skrócone, ale w pełnym wyjściu identyfikator projektu pojawia się więcej niż 5 razy. +Dla zwięzłości wynik został skrócony, ale w pełnym wyniku project ID pojawia się więcej niż 5 razy ```bash curl -s "https://identitytoolkit.googleapis.com/v1/projects?key=AIzaSyD[...]uE8Y" @@ -46,7 +46,7 @@ curl -s "https://identitytoolkit.googleapis.com/v1/projects?key=AIzaSyD[...]uE8Y "message": "Identity Toolkit API has not been used in project 943955951114 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project=943955951114 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", [...] ``` -- [Ten już nie działa!] `apikeys.keys.lookup` +- [To już nie działa!] `apikeys.keys.lookup` ```bash # If you have permissions gcloud services api-keys lookup AIzaSyD[...]uE8Y @@ -69,8 +69,99 @@ resource: projects/89123452509 service: cloudresourcemanager.googleapis.com reason: AUTH_PERMISSION_DENIED ``` -### Brute Force API endspoints +### Recon API oparty na Discovery-document -Ponieważ możesz nie wiedzieć, które API są włączone w projekcie, warto uruchomić narzędzie [https://github.com/ozguralp/gmapsapiscanner](https://github.com/ozguralp/gmapsapiscanner) i sprawdzić **co możesz uzyskać z kluczem API.** +Gdy masz już poprawny key, nie testuj tylko oczywistych public APIs. W środowiskach Google, **discovery documents** mogą działać jako maszynowo czytelna mapa attack surface, ujawniająca **resources, methods, paths, HTTP verbs, parameters oraz request/response schemas**. + +Przydatne targety: +```bash +# Public / common path +curl -s 'https://serviceusage.googleapis.com/$discovery/rest?key=' + +# Hidden docs behind a visibility label +curl -s 'https://serviceusage.googleapis.com/$discovery/rest?labels=GOOGLE_INTERNAL&key=' +``` +Uwagi: + +- Porównaj rozmiar dokumentu i liczbę metod z i bez etykiet takich jak `GOOGLE_INTERNAL`. +- Prawdziwie nieistniejąca metoda zwykle zwraca **HTML 404**. **JSON 404** z `Method not found.` może wskazywać, że metoda istnieje, ale **projekt API key nie ma wymaganej etykiety widoczności**. +- Niektóre first-party APIs są łatwiejsze do osiągnięcia przez `*.clients6.google.com` albo nieudokumentowane hosty `*-pa.googleapis.com` niż przez publiczny API explorer. + +Jest to szczególnie przydatne do enumeracji **internal/admin APIs przypadkowo wystawionych do Internetu** oraz do budowania custom fuzzers na podstawie schematu zamiast ręcznego zgadywania pól JSON. + +### Key ownership filtering at scale + +Jeśli zbierasz wiele Google API keys z APKs, ruchu przeglądarki, IPAs lub binarek, możesz chcieć szybko ustalić **który projekt jest właścicielem każdego klucza** i czy należy on do docelowej firmy. + +Praktyczny trik polega na celowym wywołaniu API, które **nie jest włączone** dla klucza. Google często ujawnia powiązany **project number** w błędzie: +```bash +curl -s 'https://protos.googleapis.com/$discovery/rest?key=' +``` +Szukaj wiadomości takich jak: +```text +Protos API has not been used in project 244648151629 before or it is disabled +``` +Ten numer projektu można następnie skorelować z innymi endpointami, leaked metadata lub wewnętrzną logiką mapowania firmy, aby oddzielić **in-scope first-party keys** od projektów klienta / third-party. + +### Handle key restrictions before discarding a key + +Ograniczony key nie jest koniecznie bezużyteczny. Zachowaj kontekst, w którym key został znaleziony, i odtwarzaj żądania z pasującymi nagłówkami: +```bash +# Browser restricted +curl -H 'X-Goog-Api-Key: ' \ +-H 'Referer: https://target.google.com' \ +'https://servicemanagement.googleapis.com/v1/operations' + +# iOS restricted +curl -H 'X-Goog-Api-Key: ' \ +-H 'X-Ios-Bundle-Identifier: com.google.GoogleMobile' \ +'https://servicemanagement.clients6.google.com/v1/operations' + +# Android restricted +curl -H 'X-Goog-Api-Key: ' \ +-H 'X-Android-Package: com.google.android.settings.intelligence' \ +-H 'X-Android-Cert: ' \ +'https://servicemanagement.clients6.google.com/v1/operations' +``` +Common restriction classes: + +- **HTTP Referer** +- **iOS bundle ID** (`X-Ios-Bundle-Identifier`) +- **Android package + signing cert** (`X-Android-Package` + `X-Android-Cert`) +- **Server IP** restrictions, which generally cannot be bypassed remotely + +### First-party auth / origin whitelist hints + +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: + +- Keep `Origin` and `Referer` compatible with the product that normally uses the API. +- A `401` with `reason: SESSION_COOKIE_INVALID` can actually mean the **origin is not whitelisted**, not that the cookie is bad. +- Publicly reachable APIs that only accept internal origins such as `*.corp.google.com` are high-value candidates for broken access control review. + +### Brute force enabled APIs and fuzz documented methods + +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.** + +After you identify reachable services, prefer **schema-driven fuzzing** over blind guessing: + +- Generate requests directly from discovery docs +- Replay the same request with **all known working keys** +- Normalize errors so you can distinguish **invalid input** from **visibility-label / auth / restriction** failures +- For numeric object identifiers, try nearby values such as `ID-1`, `ID+1`, `1`, `2`, `100`, `1000` +- Only report when you confirm **cross-user data access** or another real authorization failure; plain enumeration is usually not enough by itself + +### Common vuln pattern: unauthenticated direct-object reference + +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**. +```bash +curl 'https://gfibervoice-pa.googleapis.com/v1/BssGetVoiceSettings?gaiaId=' \ +-H 'X-Goog-Api-Key: ' +``` +Jeśli endpoint zwraca numer telefonu, adres e-mail, ustawienia lub inne prywatne pola innego użytkownika, traktuj to jako klasyczny problem **IDOR / broken access control**. + +## References + +- [Hacking Google with AI: AI-Assisted Discovery-Document Fuzzing of Google APIs](https://brutecat.com/articles/hacking-google-with-ai) +- [Google APIs Explorer](https://developers.google.com/apis-explorer) {{#include ../../../banners/hacktricks-training.md}}