detecting-aws-credential-exposure-with-trufflehog
Skill này làm gì
Công cụ này tìm thông tin xác thực AWS (như mật khẩu và khóa bí mật) bị lộ ngoài ý muốn trong mã, lịch sử tệp hoặc hệ thống tự động hóa. Nó giúp tìm và cảnh báo về thông tin nhạy cảm này trước khi bị lạm dụng.
Khi nào nên dùng
- ✓Khi tích hợp kiểm tra bảo mật vào quy trình phát triển tự động (CI/CD).
- ✓Khi thực hiện kiểm toán bảo mật trên các kho mã cũ để tìm khóa AWS đã bị xâm phạm.
- ✓Khi phản hồi cảnh báo bảo mật AWS về việc sử dụng thông tin xác thực từ vị trí bất thường.
Liên kết skill
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-aws-credential-exposure-with-trufflehog/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Quét kho mã của tôi để tìm khóa AWS bị lộ.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Công cụ dùng các chương trình như TruffleHog và git-secrets để phân tích mã và lịch sử tệp của bạn. Nó tìm các mẫu giống thông tin xác thực AWS và kiểm tra xem chúng có còn hoạt động không.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
…
Câu hỏi thường gặp
Thông tin xác thực AWS là gì?
Đó là thông tin đăng nhập (như tên người dùng và mật khẩu, hoặc khóa truy cập) cho phép người và chương trình truy cập dịch vụ AWS.
Vì sao cần tìm thông tin xác thực bị lộ?
Kẻ tấn công có thể dùng thông tin bị lộ để truy cập tài nguyên AWS của bạn, dẫn đến chi phí bất ngờ, mất dữ liệu hoặc gián đoạn dịch vụ.
Công cụ này có quản lý bí mật của tôi không?
Không, công cụ này dùng để tìm bí mật bị lộ, không phải để quản lý chúng. Để quản lý bí mật an toàn, hãy dùng các dịch vụ như AWS Secrets Manager.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 35k
- Vị trí xếp hạng
- #7798
- Giấy phép
- Apache-2.0
- Cập nhật
- 31/8/2026
Bình luận
- …
Thêm skill từ kho mã này
abusing-dpapi-for-credential-access
35kCung cấp cho agent AI của bạn hướng dẫn có sẵn cho một tác vụ cụ thể, giúp nó làm việc tốt hơn và nhanh hơn.
abusing-shadow-credentials-for-privesc
35kDạy agent AI của bạn viết văn bản rõ ràng và có cấu trúc tốt.
achieving-cmmc-level-2-compliance
35kGiúp agent của bạn chuẩn bị môi trường để tuân thủ CMMC Level 2. Triển khai các yêu cầu bảo mật và quản lý tài liệu cần thiết.
acquiring-disk-image-with-dd-and-dcfldd
35kGiúp agent của bạn tạo bản sao chính xác của ổ đĩa. Cách này đảm bảo không mất hay thay đổi thông tin trong quá trình điều tra.
Skill tương tự
add-model-provider
394kGiúp agent của bạn kết nối nhà cung cấp mô hình AI mới với OpenClaw bằng lệnh an toàn, giữ API key khỏi văn bản thuần và chạy thử.
acp-router
394kGiúp agent của bạn gửi một tác vụ đến trợ lý lập trình như Claude Code hoặc Cursor qua OpenClaw, để công việc chạy ngay trong công cụ đó.
browser-automation
394kHướng dẫn agent của bạn điều khiển trang web từng bước, gồm đăng nhập, tab và cách khôi phục khi trang ngừng phản hồi.