detecting-aws-credential-exposure-with-trufflehog
できること
このツールは、コードやファイルの履歴、自動化システムに誤って公開されてしまったAWSの認証情報(パスワードやシークレットキーなど)を探します。悪用される前に、この機密情報を見つけて通知するのに役立ちます。
使う場面
- ✓CI/CD(自動化された開発プロセス)にセキュリティチェックを組み込むとき。
- ✓古いリポジトリでセキュリティ監査を行い、漏えいしたAWSキーを見つけるとき。
- ✓予期しない場所からの認証情報の使用について、AWSからセキュリティアラートを受け取ったとき。
スキルのリンク
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-aws-credential-exposure-with-trufflehog/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のコードリポジトリで、公開されてしまったAWSキーを探してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このツールは、TruffleHogやgit-secretsなどのプログラムを使って、コードとファイルの履歴を分析します。AWSの認証情報に似たパターンを探し、それらがまだ有効かどうかを確認します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Detecting AWS Credential Exposure with TruffleHog
When to Use
- When integrating secrets detection into CI/CD pipelines to prevent credential commits reaching production
- When performing a security audit of existing repositories for historically committed AWS credentials
- When responding to an AWS GuardDuty alert about credential usage from an unexpected IP or region
- When onboarding repositories from acquired companies or third-party vendors
- When validating that credential rotation processes have removed all references to old access keys
Do not use for real-time credential monitoring (use AWS GuardDuty or Amazon Macie), for managing secrets (use AWS Secrets Manager or HashiCorp Vault), or for detecting non-credential sensitive data like PII (use Amazon Macie or DLP tools).
Prerequisites
- TruffleHog v3 installed (
brew install trufflehogorpip install trufflehog) - git-secrets installed for pre-commit hook integration (
brew install git-secrets) - Access to source code repositories (GitHub, GitLab, Bitbucket, or local git repos)
- AWS CLI configured with permissions to check key status (
iam:ListAccessKeys,iam:GetAccessKeyLastUsed) - GitHub or GitLab API token for scanning organization-wide repositories
Workflow
Step 1: Install and Configure TruffleHog
Install TruffleHog v3 and verify it can detect the AWS credential patterns.
# Install TruffleHog v3
pip install trufflehog
# Or install from binary release
curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -b /usr/local/bin
# Verify installation
trufflehog --version
# Test with a known test repository
trufflehog git https://github.com/trufflesecurity/test_keys --only-verified
Step 2: Scan Git Repositories for Exposed Credentials
Scan entire git history including all branches and commits for AWS access keys, secret keys, and session tokens.
# Scan a local git repository (full history)
trufflehog git file:///path/to/repo --only-verified --json > trufflehog-results.json
# Scan a GitHub organization's repositories
trufflehog github --org=your-organization --token=$GITHUB_TOKEN --only-verified
# Scan a specific GitHub repository with all branches
trufflehog git https://github.com/org/repo.git --only-verified --branch=main
# Scan a GitLab group
trufflehog gitlab --group=your-group --token=$GITLAB_TOKEN --only-verified
# Scan filesystem paths for credentials in config files
trufflehog filesystem /path/to/project --only-verified
Step 3: Analyze and Validate Detected Credentials
Parse TruffleHog results to identify verified (still-active) credentials versus rotated or test keys.
# Parse TruffleHog JSON output for AWS findings
cat trufflehog-results.json | python3 -c "
import json, sys
for line in sys.stdin:
finding = json.loads(line)
if 'AWS' in finding.get('DetectorName', ''):
print(f\"Detector: {finding['DetectorName']}\")
print(f\"Verified: {finding.get('Verified', False)}\")
print(f\"Source: {finding.get('SourceMetadata', {})}\")
print(f\"Commit: {finding.get('SourceMetadata', {}).get('Data', {}).get('Git', {}).get('commit', 'N/A')}\")
print(f\"File: {finding.get('SourceMetadata', {}).get('Data', {}).get('Git', {}).get('file', 'N/A')}\")
print('---')
"
# Check if a detected access key is still active
aws iam get-access-key-last-used --access-key-id AKIAIOSFODNN7EXAMPLE
# List all access keys for a user to find active keys
aws iam list-access-keys --user-name target-user \
--query 'AccessKeyMetadata[*].[AccessKeyId,Status,CreateDate]' --output table
Step 4: Set Up Pre-Commit Hooks with git-secrets
Prevent credentials from being committed in the first place using git-secrets as a pre-commit hook.
# Install git-secrets
git secrets --install # In each repository
# Register AWS credential patterns
git secrets --register-aws
# Add custom patterns for internal credential formats
git secrets --add 'AKIA[0-9A-Z]{16}'
git secrets --add 'aws_secret_access_key\s*=\s*.{40}'
git secrets --add 'aws_session_token\s*=\s*.+'
# Scan entire repository history
git secrets --scan-history
# Add to global git template for all new repos
git secrets --install ~/.git-templates/git-secrets
git config --global init.templateDir ~/.git-templates/git-secrets
Step 5: Integrate TruffleHog into CI/CD Pipeline
…
よくある質問
AWSの認証情報とは何ですか?
ユーザー名とパスワード、またはアクセスキーのように、人やプログラムがAWSのサービスにアクセスするためのログイン情報です。
公開された認証情報を見つけることが重要なのはなぜですか?
公開された認証情報は攻撃者に悪用され、AWSのリソースに不正アクセスされる可能性があります。その結果、予期しない料金の発生、データの盗難、サービスの停止につながるおそれがあります。
このツールで秘密情報を管理できますか?
いいえ。このツールは公開された秘密情報を見つけるためのもので、管理するためのものではありません。安全な秘密情報の管理には、AWS Secrets Managerのようなサービスを利用してください。
詳細
作者による元の説明
Scan source code repositories, CI/CD pipelines, and configuration files for exposed AWS credentials using TruffleHog, git-secrets, and AWS-native detection. Use when integrating secrets scanning into CI/CD, auditing repositories (including git history) for historically committed AWS keys, responding to a GuardDuty alert about credential use from an unexpected location, or verifying credential rota
人気
- GitHubのスター
- 35k
- ランキング
- #7798
- ライセンス
- Apache-2.0
- 更新日
- 2026/8/31
コメント
- …
このリポジトリの他のスキル
abusing-dpapi-for-credential-access
35k特定のタスク向けに用意された指示をAIエージェントに与え、より良く、より速く作業できるようにします。
abusing-shadow-credentials-for-privesc
35kAIエージェントに、明確で構成のしっかりした文章の書き方を教えます。
achieving-cmmc-level-2-compliance
35kエージェントがCMMC Level 2への準拠に向けた環境を整えられるようにします。セキュリティ要件を実装し、必要なドキュメントを管理します。
acquiring-disk-image-with-dd-and-dcfldd
35kエージェントがハードディスクの完全なコピーを作成できるようにします。調査中に情報が失われたり改変されたりしないようにするのに役立ちます。
似ているスキル
add-model-provider
394k安全なセットアップコマンドで新しいAIモデルプロバイダーをOpenClawに接続し、APIキーを平文で残さず、ライブテストを行うようエージェントを支援します。
acp-router
394kClaude CodeやCursorなどのコーディングアシスタントに、OpenClaw経由でタスクを渡し、その作業がそのツール内で行われるようエージェントを支援します。
browser-automation
394kログイン、タブ、応答しなくなったページからの復旧を含め、Webページを段階的に操作するようエージェントに教えます。