GCP - API Keys Unauthenticated Enum
Tip
Impara & pratica AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Impara & pratica GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Impara & pratica Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Sostieni HackTricks
- Controlla i subscription plans!
- Unisciti al 💬 Discord group o al telegram group o seguici su Twitter 🐦 @hacktricks_live.
- Condividi hacking tricks inviando PRs ai HackTricks e HackTricks Cloud github repos.
API Keys
Per ulteriori informazioni sulle API Keys controlla:
Tecniche OSINT
Le Google API Keys sono ampiamente utilizzate da qualsiasi tipo di applicazioni che utilizzano dal lato client. È comune trovarle nel codice sorgente di siti web o nelle richieste di rete, in applicazioni mobili o semplicemente cercando regex su piattaforme come Github.
La regex è: AIza[0-9A-Za-z_-]{35}
Cercala ad esempio su Github seguendo: https://github.com/search?q=%2FAIza%5B0-9A-Za-z_-%5D%7B35%7D%2F&type=code&ref=advsearch
Controlla l’origine del progetto GCP
Questo è estremamente utile per controllare a quale progetto GCP appartiene una API key che hai trovato. Abbiamo diverse opzioni:
- Contattare
https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=<api-key
Per motivi di brevità, l’output è stato troncato, ma nell’output completo l’ID del progetto appare più di 5 volte.
curl -s "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=AIzaSyD[...]uE8Y"
{
"error": {
"code": 403,
"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.",
[...]
- Contattare
https://www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=<api-key>
Per brevità, l’output è stato troncato, ma nell’output completo l’ID del progetto appare più di 5 volte.
curl -s "https://identitytoolkit.googleapis.com/v1/projects?key=AIzaSyD[...]uE8Y"
{
"error": {
"code": 403,
"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.",
[...]
- [Questo non funziona più!]
apikeys.keys.lookup
# If you have permissions
gcloud services api-keys lookup AIzaSyD[...]uE8Y
name: projects/5[...]6/locations/global/keys/28d[...]e0e
parent: projects/5[...]6/locations/global
# If you don't, you can still see the project ID in the error msg
gcloud services api-keys lookup AIzaSy[...]Qbkd_oYE
ERROR: (gcloud.services.api-keys.lookup) PERMISSION_DENIED: Permission 'apikeys.keys.lookup' denied on resource project.
Help Token: ARD_zUaNgNilGTg9oYUnMhfa3foMvL7qspRpBJ-YZog8RLbTjCTBolt_WjQQ3myTaOqu4VnPc5IbA6JrQN83CkGH6nNLum6wS4j1HF_7HiCUBHVN
- '@type': type.googleapis.com/google.rpc.PreconditionFailure
violations:
- subject: ?error_code=110002&service=cloudresourcemanager.googleapis.com&permission=serviceusage.apiKeys.getProjectForKey&resource=projects/89123452509
type: googleapis.com
- '@type': type.googleapis.com/google.rpc.ErrorInfo
domain: apikeys.googleapis.com
metadata:
permission: serviceusage.apiKeys.getProjectForKey
resource: projects/89123452509
service: cloudresourcemanager.googleapis.com
reason: AUTH_PERMISSION_DENIED
Brute Force API endspoints
Poiché potresti non sapere quali API sono abilitate nel progetto, sarebbe interessante eseguire lo strumento https://github.com/ozguralp/gmapsapiscanner e controllare cosa puoi accedere con la chiave API.
Tip
Impara & pratica AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Impara & pratica GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Impara & pratica Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Sostieni HackTricks
- Controlla i subscription plans!
- Unisciti al 💬 Discord group o al telegram group o seguici su Twitter 🐦 @hacktricks_live.
- Condividi hacking tricks inviando PRs ai HackTricks e HackTricks Cloud github repos.
HackTricks Cloud

