Hunt: Cloud (AWS / Azure / GCP) (golden-image rework)
Turn a cloud surface into evidence-carrying CANDIDATES: metadata credential theft, exposed-key validation, IAM privesc paths, service loot. This skill produces candidates, never verdicts - findings leave ONLY through the G1 proof gate (triage).
Current emphasis (update on wiki harvest): instance-metadata credential theft (IMDS / managed identity) and over-privileged role assumption over public-bucket enumeration - the newest harvested technique leads until superseded.
Assumes hunt-core for the scope gate, two-account rule,
confirmation gate, enumeration limits, stop conditions, wiki protocol,
FIND output, and Deadends. Do not re-derive any of that here.
Wiki
Hub: [[cloud-moc]] - Primary page: [[cloud-iam-attacks]] - Payload
arsenal: wiki/payloads/imds-cloud-metadata.md
Anchors: [[aws-metadata-ssrf]], [[azure-ad-iam]]
REFS: [[cloud-iam-attacks]], wiki/payloads/imds-cloud-metadata.md
Depth: references/presigned-url-escalation.md (the lens matrix for escalating a
presigned-URL finding: ACL/HeadersNotSigned, read-path inventory, render-sink
tracing, STS-rotation analysis)
mcp__wiki-search__query (lex) "cloud AWS Azure GCP metadata SSRF IAM privilege escalation credential discovery persistence" via wiki-search MCP - ONLY on a concrete hint the map above does not cover; not a blanket first step.
Paths (binding - define once at the top of the run notes)
# seat side (wsl) - engagement tree is DOUBLE-NESTED in VMshare:
ENG_DIR=/mnt/c/Users/Lenovo/Desktop/VMshare/<eng>/<eng>
RUN=$ENG_DIR/hunt/cloud/<account-or-host>
# VM side (WHERE provider CLIs run, same tree through the share):
ENG_DIR=/mnt/VMshare/<eng>/<eng>
RUN=$ENG_DIR/hunt/cloud/<account-or-host>
Corpus and probes live in the VMshare tree; the VM runs tools against the /mnt/VMshare spelling as user tz; the seat reads the same bytes at the /mnt/c/Users/Lenovo/Desktop/VMshare spelling. The repo tree targets/ is admin/ingest only - probe artifacts NEVER land there.
Transport
Every VM-native command block ships through ONE documented transport:
cd /mnt/c/Users/Lenovo/Documents/ObisidianVaults/ZTorch/ZTorch && bash scripts/vm-ssh.sh '<command>'
- vm-ssh lands as user tz (NOT root): no root-only paths, no sudo.
- vm-ssh.sh takes the command as ONE argument; quotes ship as base64
(
echo <b64> | base64 -d | bashinside the vm-ssh argument). - Non-login shells do NOT source profile.d: target-facing fetches MUST use /opt/scope-shim/bin/{curl,httpx} by absolute path.
- Shim verdict semantics (verified live): out-of-scope dies rc 126 (never work around); in-scope passes; UNKNOWN gets an ADVISORY - not approval; verify against scope.md and self-deny.
- az cli on Kali gotcha: the deb repo rejects Kali's dist codename.
Install with
curl -sL https://aka.ms/InstallAzureCLIDeb | DIST_CODE=bookworm bash, or run az on the target Ubuntu VM.
Billing and safety (cloud-specific, on top of hunt-core)
- Scope is account / subscription / project IDs, not just hostnames. Confirm the ID is in scope before the first authenticated call.
- Every call is billed and logged (CloudTrail / Azure Activity / GCP Audit Logs). Enumeration is loud, costs the client, and mass API calls trip provider abuse detection (GuardDuty / Defender). Prefer read-only enumeration, keep call volume low, create/delete NOTHING without RoE sign-off.
- Never spray IAM users (lockout + GuardDuty). Reuse keys from loot.md first.
Entry gate
All four must pass; each is falsifiable:
Active engagement exists (repo tree targets//active.md) and the cloud account/subscription/project ID (or the host reaching metadata) is on targets//scope.md in-scope. Scope-guard is the deny. (targets/ is the repo admin tree; $ENG_DIR holds corpus and run artifacts only - see Paths.)
hunt-core loaded (skills/exploit/hunt/hunt-core/SKILL.md).
Producer verified - at least ONE of: (a) hunt-secrets validated a key (validation.jsonl row with verdict=verified) and the handoff is recorded;
(b) hunt-ssrf confirmed a metadata reach (candidates.jsonl row or HIT);
(c) $ENG_DIR/state.md asset table has a cloud row (bucket, metadata endpoint, IAM surface);
(d) kickoff seeded $RUN/raw/cloud-map.md. None = dispatch the producing lane first.Toolchain preflight (fails LOUD; provider CLIs probed per the branch actually taken - absent CLI constrains that provider's branch, it does not stop the run):
for t in /usr/bin/jq /usr/bin/python3 \ /opt/scope-shim/bin/curl; do [ -x "$t" ] || { echo "MISSING TOOL: $t"; exit 1; } done # install-on-demand (operator rule): install what the branch needs command -v aws >/dev/null || pip3 install --user --break-system-packages -q awscli || echo "N/A: aws CLI absent on VM (install failed)" command -v az >/dev/null || { curl -skL https://aka.ms/InstallAzureCLIDeb | bash >/dev/null; } || echo "N/A: az CLI absent on VM (install failed)" command -v gcloud >/dev/null || { pip3 install --user --break-system-packages -q gsutil && echo "gcloud-py fallback: gsutil namespace"; } || echo "N/A: gcloud CLI absent on VM (install failed)"
Checklist (mandatory)
Copy checklist.md (this skill's dir) to
$ENG_DIR/hunt/cloud/<account-or-host>/cloud-checklist.md at run
start. Unchecked at stop = UNCHECKED lane, re-run from the first
unchecked step. The SKILL.md text and the checklist header agree
byte-for-byte on that copy target.
Nudge
Review-skill re-injection text (pinned; NOTE: completion-gate emits its own generic nudge - both mean: resume at the first unchecked box):
Your work was just reviewed by the review skill and it was found
that you either missed a step of analysis, or didn't generate an
artifact of sufficient proof. Look at the markdown based checklist
and the output for each step, find what you missed, and complete
that step.
Confirmation gate
NOT confirmation: an enumerated bucket/blob/GCS name; a role ARN or service-account email listed but never assumed; a metadata endpoint that merely responds; AKIA* / AccountKey= / service-account JSON found but never exercised; a 200 from a permissions enumerator that only reads policy, not access.
IS confirmation: credentials actually retrieved AND validated with a SINGLE benign read-only call naming the principal (sts get-caller-identity / az account show / gcloud auth list), or a resource actually read cross-account/cross-tenant - reproduced in a clean session. One benign call proves control: STOP there. Do not spin up resources or mass-enumerate to "prove more" - that only adds billing, audit noise, and abuse-detection risk without changing the finding.
Cloud CLI quick reference (use this, don't hand-roll)
Every command is a real, tested CLI invocation - the SAME primitive a hand-rolled curl/urllib call against Graph/ARM/REST would reimplement worse (weaker, no paging, easy to misquote):
| Operation | Command | Step |
|---|---|---|
| Azure creds in hand, ROPC login | az login -u <upn> -p <pass> |
Tooling-first |
| Compromised Azure compute resource, login as its managed identity | az login --identity |
Tooling-first |
| Entra ID dump via stolen refresh token (FOCI, no password) | roadrecon auth -r <refresh-token> && roadrecon dump |
Tooling-first |
| Azure resource/VM/role enumeration once logged in | az account list; az resource list -o table; az vm list -d -o table; az role assignment list --all |
Tooling-first |
| AWS whoami | aws sts get-caller-identity |
1 |
| Azure whoami | az account show |
1 |
| Azure signed-in user | az ad signed-in-user show |
1 |
| GCP auth list | gcloud auth list |
1 |
| GCP config list | gcloud config list |
1 |
| AWS IMDSv1 role creds (app-side SSRF) | curl http://169.254.169.254/latest/meta-data/iam/security-credentials/<role> |
2 |
| Azure IMDS managed-identity token | curl -H "Metadata:true" "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/" |
2 |
| GCP metadata service-account token | curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token" |
2 |
| AWS IAM authorization details (full policy dump) | aws iam get-account-authorization-details |
3 |
| AWS IAM privesc-path enumeration | enumerate-iam --access-key ... --secret-key ... |
3 |
| Azure role assignments for a principal | az role assignment list --assignee <id> |
3 |
| Azure config-review enumeration | ScoutSuite azure |
3 |
| GCP IAM policy | gcloud projects get-iam-policy <proj> |
3 |
| Azure VM extension public settings leak (Reader-only) | az vm extension show ... -n CustomScriptExtension |
5 |
Tooling-first: install the CLI, do NOT hand-roll REST (Azure
especially)
The provider CLIs and roadrecon do enumeration + attack in one authenticated call - install them FIRST; hand-rolled curl/urllib against Graph/ARM is the drift to avoid. Reach for a script only for the rare thing the CLI cannot express.
- Azure creds in hand: az login (ROPC; works on Managed tenants when
the CLI client is not MFA-gated), then the enumeration table rows.
Entra dump = roadrecon (auth -r reuses a token cross-client via
FOCI, no password quoting; then dump). AzureHound for attack paths;
MicroBurst Get-AzPasswords (pwsh) to sweep KV/automation/storage secrets. - Compromised an Azure compute resource (VM/App Service/Container)? Do not parse IMDS JSON by hand - az login --identity authenticates AS that resource's managed identity straight from IMDS; az account show confirms user.type=servicePrincipal / systemAssignedIdentity.
Methodology
Rank before testing: metadata SSRF first (an app-side SSRF reaching 169.254.169.254 / metadata.google.internal hands you instance/managed-identity creds - highest-value chain); exposed keys (.env, ~/.aws/credentials, CI/CD vars, JS bundles, git history: AKIA*/ ASIA* AWS, AccountKey= Azure, "type":"service_account" JSON GCP); over-privileged roles (creds whose IAM grants a privesc primitive); public storage last (frequently non-sensitive, easy to over-claim).
Step 1 - Identify + whoami
aws sts get-caller-identity
az account show; az ad signed-in-user show
gcloud auth list; gcloud config list
One benign call per held credential; record the principal. @ $RUN/probes/whoami.jsonl.
Step 2 - Metadata SSRF (if app-side SSRF; hunt-ssrf owns reaching)
# AWS IMDSv1
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/<role>
# Azure (Metadata:true header)
curl -H "Metadata:true" "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/"
# GCP (Metadata-Flavor: Google)
curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token"
IMDSv2 needs a session token first (PUT /latest/api/token with X-aws-ec2-metadata-token-ttl-seconds, then X-aws-ec2-metadata-token on the GET) - an SSRF that cannot set headers only reaches IMDSv1. @ $RUN/probes/metadata.jsonl.
Step 3 - Permission enumeration (read-only, tightly scoped)
Each of these fans out into many billed, logged API calls - scope tightly, never loop them:
aws iam get-account-authorization-details
enumerate-iam --access-key ... --secret-key ... # or pacu
az role assignment list --assignee <id>; ScoutSuite azure
gcloud projects get-iam-policy <proj>
@ $RUN/probes/iam-enum.jsonl.
Step 4 - IAM privesc paths
AWS (iam:PassRole+lambda/ec2, sts:AssumeRole, policy version, iam:CreateAccessKey); Azure (Owner/Contributor on subscription, Microsoft.Authorization/*, managed identity abuse, Automation runbooks); GCP (iam.serviceAccounts.actAs, setIamPolicy, deployment manager, actAs chains). RoE-gated: IDENTIFY the path, do not execute it. @ $RUN/probes/privesc.jsonl.
Step 5 - Service loot (read-only)
S3/blob/GCS objects, Secrets Manager / Key Vault / Secret Manager, SSM parameters, Lambda/Function env, snapshots, EBS, Storage Account keys. Azure: even plain READER reads a VM extension's public settings - az vm extension show ... -n CustomScriptExtension leaks commandToExecute/fileUris (secrets, SAS URLs), no Contributor/ RunCommand needed [[azure-services-virtual-machine]]. @ $RUN/probes/loot.jsonl.
Step 6 - Lateral / persistence (RoE-GATED, plan-only)
Assume cross-account role, new access key, SSH key to instance metadata, service-account key creation, Automation runbook. Recorded as PLAN rows only unless the operator signs off. @ $RUN/probes/persistence-plan.md.
Step 7 - Exit artifact (candidates)
candidates.md every class section present; pointer $ENG_DIR/hunt-cloud-.md:
CLOUD-HUNT-DONE whoami=<n> metadata=<n> iam-enum=<n>
privesc=<n> loot=<n>
Plus _requests.md rows (lane = hunt-cloud), state.md asset rows, Deadends rows with the WHY. Every probe JSONL row: {class, host, endpoint, method, evidence, observed, confidence}; pairs under probes/raw/ (sha256 filenames). Key VALUES never enter candidates files - principal IDs + verdicts only (leak hygiene).
Evasion
AWS IMDSv2 token dance (above). Enumeration is logged: prefer a compromised in-account principal over external calls, and read-only actions over anything that writes an audit event you cannot explain.
Validation
- Proof = the assumed identity ACTING: sts get-caller-identity (AWS), az account show, gcloud ... list with data returned. Metadata SSRF proof = the v2 token step completed, not a bare 200 on /latest/meta-data/.
- Counterevidence: a recovered key may be a canary/decoy (check last-used, alerting); a "permissive" policy usually has an explicit Deny you have not read.
False Positives
- IMDSv2 hop-limit block read as open metadata (the v1 path is dead).
- Public-by-design bucket (static site, public dataset).
- Policy JSON skimming that missed the Deny statement.
- Console role assumed via your OWN test account scope.
- Fake region/endpoint responding 200 to everything.
Cross-routing
- hunt-ssrf first when metadata is reached through an app-side SSRF (that skill owns reaching the endpoint; this one owns what the creds unlock).
- hunt-m365 for the Entra/identity half of the tenant.
- hunt-ad for hybrid setups (AD Connect sync bridges both).
- Not this skill: app vulns on cloud-HOSTED apps (route by class).
Severity
CRITICAL = creds to admin/owner, cross-account/tenant takeover, metadata role creds. HIGH = sensitive data read (secrets/buckets), IAM privesc path. MEDIUM = enumeration / public bucket with non-sensitive data.
Deadends
Append: - [ ] cloud <account/host> -- whoami principal read-only,
no privesc path in IAM dump, metadata v2-enforced, buckets private
Record what was enumerated and what the Deny statements blocked.
N/A escapes
- "N/A: aws CLI absent on VM (install failed)" (branch constrained, noted)
- "N/A: az CLI absent on VM (install failed)"
- "N/A: gcloud CLI absent on VM (install failed)"
- "N/A: no cloud surface in scope" An N/A tick is a claim with a reason, never a silent pass. Identical strings in SKILL.md and checklist.md.
Bitter-pill variant
Freehand run: skip checklist + numbered steps, one freehand pass over the cloud map, output ONLY $RUN/analysis/bitter-pill.md (tried/found/ dismissed, every claim carries evidence). The one-benign-call gate and billing discipline survive freehand. Declare with a _requests.md row (lane = hunt-cloud-bitterpill).
Depth walk (mandatory)
Walk EVERY applicable row of the payload arsenal page cited above.
Record each row in $RUN/coverage-depth.md as a table
| row | state | evidence | where state is probed, blocked, or
N/A, and evidence is a probe-pair path or a Deadends.md line. A bare
probed with no evidence reference fails the completion gate
(NEEDS-REVIEW). N/A rows cite why (surface shape forbids it).
Blocked implies research: before any Deadend is claimable on a blocked
row, (a) walk the arsenal page's bypass-ladder rows for that control
class, and (b) run one wiki query AND one mcp__wigolo__search for the
specific tech-plus-control bypass. Results, or a genuine null, land in
coverage-depth.md. "No research tried" is not a claimable state.
Exit artifact + handoff
ONE exit artifact set: $RUN/candidates.jsonl + candidates.md + $ENG_DIR/hunt-cloud-.md (pointer with CLOUD-HUNT-DONE
- counts). Consumer (triage) finds at $RUN: raw/cloud-map.md,
probes/*.jsonl, probes/raw/, candidates.{jsonl,md}. Findings leave
ONLY through G1. Distill:
python3 scripts/wiki-stage.py --kind technique --slug <slug> --target-page techniques/cloud/aws-attacks.md.
Stop conditions
Terminal states complete; ONE-benign-call rule enforced; no resource creation/deletion without RoE sign-off; nothing written into skill dirs; no unchecked boxes above REVIEW; hunt-core stop conditions fire unchanged.
Attack surface
APPROACH: Rank metadata SSRF (IMDS creds) first, then exposed keys, over-privileged roles, and public storage; whoami the principal and use the provider CLI (not hand-rolled REST), keeping calls read-only and low-volume (every call is billed and logged) and reusing loot before new keys.
AVOID: An enumerated bucket/role name, a metadata endpoint that merely responds, or a key found but never exercised is NOT confirmation - creds must be retrieved AND validated with one benign whoami call (sts get-caller-identity / az account show).