1---2name: cloud-security3description: Use when attacking AWS/Azure/GCP cloud — IAM/identity privilege escalation, IMDS/metadata SSRF, Entra device-code & PRT theft, GCP impersonation chains, Kubernetes/container escape, IaC/CI-CD federation abuse4metadata:5 source: https://skillmd.com/skills/hypnguyen1209/cloud-security6 type: offensive7 phase: exploitation8 tools: pacu, cloudfox, scoutsuite, prowler, trivy, kubectl, aws-cli, az-cli, gcloud, peirates, mkat, azurehound, roadtools, stratus-red-team, kube-bench9 mitre: [T1078.004, T1552.005, T1098.001, T1528, T1611, T1548]10kill_chain:11 phase: [recon, exploit]12 step: [1, 4]13 attck_tactics: [TA0043, TA0001, TA0004, TA0008, TA0006]14 attck_techniques: [T1078.004, T1552.005, T1552.007, T1098.001, T1098.003, T1528, T1606.002, T1611, T1610, T1134.001, T1548, T1538]15depends_on: [recon-osint]16feeds_into: [exploit-development, active-directory-attack, advanced-redteam]17inputs: [cloud_config, iam_policies, kubeconfig, ci_cd_config]18outputs: [cloud_misconfig_list, finding_record, attack_path, stolen_credentials]19references:20 - references/aws-iam-privesc.md21 - references/imds-metadata-ssrf.md22 - references/azure-entra-attacks.md23 - references/gcp-attacks.md24 - references/kubernetes-container-escape.md25 - references/iac-secrets-ci-cd.md26scripts:27 - scripts/aws_privesc_enum.py28 - scripts/imds_harvester.py29 - scripts/entra_device_code_phish.py30 - scripts/gcp_impersonation_mapper.py31 - scripts/k8s_can_i_abuse.py32 - scripts/oidc_trust_auditor.py33---3435# Cloud Security & Attack3637## When to Activate3839- Cloud penetration test / red team against AWS, Azure (Entra ID), or GCP40- IAM / identity privilege escalation and cross-account or cross-tenant pivoting41- Compromised web app or SSRF reachable from cloud compute — harvest metadata credentials42- Kubernetes / container assessment, node breakout, cluster takeover43- CI/CD and IaC review: Terraform state, OIDC federation trust policies, pipeline secrets44- Post-exploitation: secret extraction, lateral movement, persistence in cloud control plane4546## Technique Map4748| Technique | ATT&CK | CWE | Reference | Script |49|-----------|--------|-----|-----------|--------|50| AWS IAM privesc (CreatePolicyVersion, PassRole, AttachPolicy) | T1098.001 | CWE-269 | references/aws-iam-privesc.md | scripts/aws_privesc_enum.py |51| AWS `sts:AssumeRoot` member-account escalation | T1078.004 | CWE-269 | references/aws-iam-privesc.md | scripts/aws_privesc_enum.py |52| Cross-account confused deputy / missing ExternalId | T1078.004 | CWE-441 | references/aws-iam-privesc.md | scripts/oidc_trust_auditor.py |53| IMDS / metadata SSRF credential theft (AWS/Azure/GCP) | T1552.005 | CWE-918 | references/imds-metadata-ssrf.md | scripts/imds_harvester.py |54| EKS node creds → IRSA / Pod Identity pivot | T1552.007 | CWE-668 | references/imds-metadata-ssrf.md | scripts/imds_harvester.py |55| Entra device-code phishing → PRT / device join | T1528 | CWE-287 | references/azure-entra-attacks.md | scripts/entra_device_code_phish.py |56| FOCI refresh-token family abuse | T1550.001 | CWE-613 | references/azure-entra-attacks.md | scripts/entra_device_code_phish.py |57| Azure Managed Identity / App-Admin → SP escalation | T1098.001 | CWE-269 | references/azure-entra-attacks.md | scripts/imds_harvester.py |58| GCP `actAs` + resource create impersonation chain | T1078.004 | CWE-269 | references/gcp-attacks.md | scripts/gcp_impersonation_mapper.py |59| GCP `serviceAccountTokenCreator` token chains | T1528 | CWE-269 | references/gcp-attacks.md | scripts/gcp_impersonation_mapper.py |60| Vertex AI P4SA / Ray head-node escalation | T1078.004 | CWE-732 | references/gcp-attacks.md | scripts/gcp_impersonation_mapper.py |61| Container escape (runc Leaky Vessels CVE-2024-21626) | T1611 | CWE-668 | references/kubernetes-container-escape.md | - |62| IngressNightmare (CVE-2025-1974) cluster takeover | T1190 | CWE-94 | references/kubernetes-container-escape.md | scripts/k8s_can_i_abuse.py |63| K8s RBAC privesc (pods/exec, token mount, node proxy) | T1078 | CWE-269 | references/kubernetes-container-escape.md | scripts/k8s_can_i_abuse.py |64| Terraform state secret extraction | T1552.001 | CWE-312 | references/iac-secrets-ci-cd.md | scripts/oidc_trust_auditor.py |65| OIDC federation trust-policy abuse (GitHub/TF Cloud) | T1199 | CWE-441 | references/iac-secrets-ci-cd.md | scripts/oidc_trust_auditor.py |6667## Quick Start6869```bash70# --- 0. Identify where you are ---71aws sts get-caller-identity # AWS72az account show && az ad signed-in-user show # Azure73gcloud auth list && gcloud config get-value project # GCP7475# --- 1. AWS: enumerate then map privesc paths ---76python3 scripts/aws_privesc_enum.py --profile compromised --json paths.json77cloudfox aws --profile compromised all-checks # alt: broad inventory78pacu # > run iam__enum_permissions ; run iam__privesc_scan7980# --- 2. SSRF / metadata: harvest creds from a reachable compute target ---81python3 scripts/imds_harvester.py --ssrf "https://app/fetch?url=" --provider aws82python3 scripts/imds_harvester.py --local --provider azure --resource https://vault.azure.net/8384# --- 3. Azure Entra: device-code phish for tokens (authorized phishing only) ---85python3 scripts/entra_device_code_phish.py --resource https://graph.microsoft.com \86 --client-id 29d9ed98-a469-4536-ade2-f981bc1d605e # Auth Broker -> PRT path8788# --- 4. GCP: build the service-account impersonation graph ---89python3 scripts/gcp_impersonation_mapper.py --project TARGET --out gcp_graph.json9091# --- 5. Kubernetes: what can this token do, and can we break out? ---92python3 scripts/k8s_can_i_abuse.py --kubeconfig ./kubeconfig93kubectl auth can-i --list ; peirates9495# --- 6. CI/CD + IaC: audit federation trust + dump state secrets ---96python3 scripts/oidc_trust_auditor.py --profile compromised97aws s3 cp s3://tf-state/prod/terraform.tfstate - | jq '.. | .password? // empty'98```99100## OPSEC & Detection (summary)101102| Technique | Telemetry / IOC | Detection (Sigma / EDR / cloud) | OPSEC note |103|-----------|-----------------|---------------------------------|------------|104| IAM privesc API calls | CloudTrail `CreatePolicyVersion`, `AttachUserPolicy`, `CreateLoginProfile` | Alert on IAM write by non-IAM-admin principal; GuardDuty `PrivilegeEscalation:IAMUser/*` | Use existing admin sessions; avoid bulk enum that trips anomaly detection |105| `sts:AssumeRoot` | CloudTrail `AssumeRoot` (regional only) | Elastic "AssumeRoot by Rare User and Member Account" (new-terms rule) | Rare-event detection fires on first use per (principal, member account) |106| IMDS SSRF | VPC flow to 169.254.169.254 from web tier; STS use from new ASN | GuardDuty `UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration*` (creds used off-instance) | Use creds from same egress IP where possible; creds expire — refresh fast |107| Entra device-code phish | Sign-in logs `authenticationProtocol=deviceCode`; Auth Broker client `29d9ed98-...`; new device registration | Sentinel device-code anomaly; CA "block device code flow" | Tokens valid even after password reset; device-join = MFA-resistant persistence |108| GCP impersonation | `GenerateAccessToken` / `generateAccessToken` in Admin Activity + Data Access logs | Alert on impersonation by principal lacking a documented chain | Requires Data Access (`DATA_READ`) audit logs enabled to see token minting |109| Container escape (runc) | New process from `/proc/self/fd/*` cwd; host binary writes; `nsenter` in container | Falco `Container escape`/`Drop and execute new binary`; runc ≤1.1.11 inventory | Overwrites host runc → noisy; prefer read-only host FS read for stealth |110| IngressNightmare | NGINX ingress pod loads `.so` from `/proc`; outbound from controller | Falco/Sysdig "IngressNightmare" shared-lib load; ingress-nginx < 1.11.5/1.12.1 | Exploit hits admission webhook (often internal-only) — low external noise |111| OIDC trust abuse | CloudTrail `AssumeRoleWithWebIdentity` from unexpected `sub`/repo | Alert on web-identity assume with mismatched `aud`/`sub`; RCP block | Wildcard `sub` (`org:foo*`) still exploitable; no creds needed |112113## Deep Dives114115- **references/aws-iam-privesc.md** — Classic + 2024 IAM escalation chains, `sts:AssumeRoot`, cross-account confused deputy / ExternalId, Cognito, secrets harvesting; detection per API.116- **references/imds-metadata-ssrf.md** — IMDSv1/v2 mechanics, SSRF bypasses, Azure & GCP metadata token theft, EKS node-cred → IRSA/Pod Identity lateral movement.117- **references/azure-entra-attacks.md** — Storm-2372 device-code → PRT → device-join chain, FOCI token families, Managed Identity abuse, Application Administrator → service principal → Global Admin.118- **references/gcp-attacks.md** — `actAs` + resource-create impersonation, `serviceAccountTokenCreator` chains, Cloud Functions takeover, Vertex AI ModeLeak/P4SA/Ray escalation.119- **references/kubernetes-container-escape.md** — runc Leaky Vessels (CVE-2024-21626), privileged/hostPID/Docker-socket escapes, IngressNightmare (CVE-2025-1974), RBAC primitives, kubelet/etcd.120- **references/iac-secrets-ci-cd.md** — Terraform state secret extraction, OIDC federation trust-policy abuse (GitHub Actions / Terraform Cloud), pipeline secret theft, RCP/SCP defenses.