GCP - API Keys Enum
Reading time: 2 minutes
tip
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Support HackTricks
- Check the subscription plans!
- Join the 💬 Discord group or the telegram group or follow us on Twitter 🐦 @hacktricks_live.
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.
Basic Information
In Google Cloud Platform (GCP), API keys are a simple encrypted string that identifies an application without any principal. They are used to access Google Cloud APIs that do not require user context. This means they are often used in scenarios where the application is accessing its own data rather than user data.
Restrictions
You can apply restrictions to API keys for enhanced security. For example, you can restrict the key to be used only by certain IP addresses, webs, android apps, iOS apps, or restrict it to certain APIs or services within GCP.
Enumeration
It's possible to see the restriction of an API key (including GCP API endpoints restriction) using the verbs list or describe:
gcloud services api-keys list
gcloud services api-keys describe <key-uuid>
gcloud services api-keys list --show-deleted
note
It's possible to recover deleted keys before 30days passes, that's why you can list deleted keys.
Privilege Escalation & Post Exploitation
Unauthenticated Enum
GCP - API Keys Unauthenticated Enum
Persistence
tip
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Support HackTricks
- Check the subscription plans!
- Join the 💬 Discord group or the telegram group or follow us on Twitter 🐦 @hacktricks_live.
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.