# Simplified patterns bots scan for
AKIA[0-9A-Z]{16} # AWS Access Key ID
ghp_[A-Za-z0-9]{36} # GitHub Personal Access Token
sk_live_[A-Za-z0-9]{24,} # Stripe Secret Key
SG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43} # SendGrid API Key
xoxb-[0-9]{11,13}-[0-9]{11,13}-[a-zA-Z0-9]{24} # Slack Bot Token
# Simplified patterns bots scan for
AKIA[0-9A-Z]{16} # AWS Access Key ID
ghp_[A-Za-z0-9]{36} # GitHub Personal Access Token
sk_live_[A-Za-z0-9]{24,} # Stripe Secret Key
SG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43} # SendGrid API Key
xoxb-[0-9]{11,13}-[0-9]{11,13}-[a-zA-Z0-9]{24} # Slack Bot Token
# Simplified patterns bots scan for
AKIA[0-9A-Z]{16} # AWS Access Key ID
ghp_[A-Za-z0-9]{36} # GitHub Personal Access Token
sk_live_[A-Za-z0-9]{24,} # Stripe Secret Key
SG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43} # SendGrid API Key
xoxb-[0-9]{11,13}-[0-9]{11,13}-[a-zA-Z0-9]{24} # Slack Bot Token
# What an attacker runs against your repo
-weight: 500;">git log --all --full-history -- "*.env" # Or search every commit ever made for credential patterns
-weight: 500;">git log -p --all -S 'AKIA'
# What an attacker runs against your repo
-weight: 500;">git log --all --full-history -- "*.env" # Or search every commit ever made for credential patterns
-weight: 500;">git log -p --all -S 'AKIA'
# What an attacker runs against your repo
-weight: 500;">git log --all --full-history -- "*.env" # Or search every commit ever made for credential patterns
-weight: 500;">git log -p --all -S 'AKIA'
# Install
-weight: 500;">brew -weight: 500;">install trufflehog
# or
-weight: 500;">docker pull trufflesecurity/trufflehog:latest # Scan a local repo — checks the entire -weight: 500;">git history
trufflehog -weight: 500;">git file://. --only-verified # Scan an entire GitHub org
trufflehog github --org=your-org-name --only-verified
# Install
-weight: 500;">brew -weight: 500;">install trufflehog
# or
-weight: 500;">docker pull trufflesecurity/trufflehog:latest # Scan a local repo — checks the entire -weight: 500;">git history
trufflehog -weight: 500;">git file://. --only-verified # Scan an entire GitHub org
trufflehog github --org=your-org-name --only-verified
# Install
-weight: 500;">brew -weight: 500;">install trufflehog
# or
-weight: 500;">docker pull trufflesecurity/trufflehog:latest # Scan a local repo — checks the entire -weight: 500;">git history
trufflehog -weight: 500;">git file://. --only-verified # Scan an entire GitHub org
trufflehog github --org=your-org-name --only-verified
# Install
-weight: 500;">brew -weight: 500;">install gitleaks # Scan the current repo
gitleaks detect --source . -v # Example output:
# Finding: AKIAIOSFODNN7EXAMPLE
# Secret: AKIAIOSFODNN7EXAMPLE
# RuleID: aws-access-key-id
# Entropy: 3.684
# File: config/prod.env
# Line: 3
# Commit: a1b2c3d
# Author: [email protected]
# Date: 2024-03-15
# Install
-weight: 500;">brew -weight: 500;">install gitleaks # Scan the current repo
gitleaks detect --source . -v # Example output:
# Finding: AKIAIOSFODNN7EXAMPLE
# Secret: AKIAIOSFODNN7EXAMPLE
# RuleID: aws-access-key-id
# Entropy: 3.684
# File: config/prod.env
# Line: 3
# Commit: a1b2c3d
# Author: [email protected]
# Date: 2024-03-15
# Install
-weight: 500;">brew -weight: 500;">install gitleaks # Scan the current repo
gitleaks detect --source . -v # Example output:
# Finding: AKIAIOSFODNN7EXAMPLE
# Secret: AKIAIOSFODNN7EXAMPLE
# RuleID: aws-access-key-id
# Entropy: 3.684
# File: config/prod.env
# Line: 3
# Commit: a1b2c3d
# Author: [email protected]
# Date: 2024-03-15
# .gitignore
.env
.env.local
.env.production
.env.*.local
# .gitignore
.env
.env.local
.env.production
.env.*.local
# .gitignore
.env
.env.local
.env.production
.env.*.local
# .env.example — committed to -weight: 500;">git, contains zero real values
DATABASE_URL=postgresql://user:password@localhost:5432/myapp
STRIPE_SECRET_KEY=sk_test_replace_this
AWS_ACCESS_KEY_ID=your_key_here
AWS_SECRET_ACCESS_KEY=your_secret_here
SENDGRID_API_KEY=SG.replace_this
# .env.example — committed to -weight: 500;">git, contains zero real values
DATABASE_URL=postgresql://user:password@localhost:5432/myapp
STRIPE_SECRET_KEY=sk_test_replace_this
AWS_ACCESS_KEY_ID=your_key_here
AWS_SECRET_ACCESS_KEY=your_secret_here
SENDGRID_API_KEY=SG.replace_this
# .env.example — committed to -weight: 500;">git, contains zero real values
DATABASE_URL=postgresql://user:password@localhost:5432/myapp
STRIPE_SECRET_KEY=sk_test_replace_this
AWS_ACCESS_KEY_ID=your_key_here
AWS_SECRET_ACCESS_KEY=your_secret_here
SENDGRID_API_KEY=SG.replace_this
# .pre-commit-config.yaml
repos: - repo: https://github.com/Yelp/detect-secrets rev: v1.5.0 hooks: - id: detect-secrets args: ['--baseline', '.secrets.baseline']
# .pre-commit-config.yaml
repos: - repo: https://github.com/Yelp/detect-secrets rev: v1.5.0 hooks: - id: detect-secrets args: ['--baseline', '.secrets.baseline']
# .pre-commit-config.yaml
repos: - repo: https://github.com/Yelp/detect-secrets rev: v1.5.0 hooks: - id: detect-secrets args: ['--baseline', '.secrets.baseline']
# Setup
-weight: 500;">pip -weight: 500;">install pre-commit
detect-secrets scan > .secrets.baseline # baseline existing findings
pre-commit -weight: 500;">install
# Setup
-weight: 500;">pip -weight: 500;">install pre-commit
detect-secrets scan > .secrets.baseline # baseline existing findings
pre-commit -weight: 500;">install
# Setup
-weight: 500;">pip -weight: 500;">install pre-commit
detect-secrets scan > .secrets.baseline # baseline existing findings
pre-commit -weight: 500;">install
$ -weight: 500;">git commit -m "add config"
Detect secrets..................................................Failed
- hook id: detect-secrets
- exit code: 1 ERROR: Potential secret in config/settings.py:14 Type: AWS Access Key Line: AWS_KEY = "AKIAIOSFODNN7EXAMPLE"
$ -weight: 500;">git commit -m "add config"
Detect secrets..................................................Failed
- hook id: detect-secrets
- exit code: 1 ERROR: Potential secret in config/settings.py:14 Type: AWS Access Key Line: AWS_KEY = "AKIAIOSFODNN7EXAMPLE"
$ -weight: 500;">git commit -m "add config"
Detect secrets..................................................Failed
- hook id: detect-secrets
- exit code: 1 ERROR: Potential secret in config/settings.py:14 Type: AWS Access Key Line: AWS_KEY = "AKIAIOSFODNN7EXAMPLE"
# .pre-commit-config.yaml (alternative)
repos: - repo: https://github.com/gitleaks/gitleaks rev: v8.21.2 hooks: - id: gitleaks
# .pre-commit-config.yaml (alternative)
repos: - repo: https://github.com/gitleaks/gitleaks rev: v8.21.2 hooks: - id: gitleaks
# .pre-commit-config.yaml (alternative)
repos: - repo: https://github.com/gitleaks/gitleaks rev: v8.21.2 hooks: - id: gitleaks
eval $(op signin)
export DATABASE_URL=$(op read "op://Development/Database/url")
export STRIPE_KEY=$(op read "op://Development/Stripe/secret_key") # Or inject into a process directly
op run --env-file=.env.tpl -- -weight: 500;">npm run -weight: 500;">start
eval $(op signin)
export DATABASE_URL=$(op read "op://Development/Database/url")
export STRIPE_KEY=$(op read "op://Development/Stripe/secret_key") # Or inject into a process directly
op run --env-file=.env.tpl -- -weight: 500;">npm run -weight: 500;">start
eval $(op signin)
export DATABASE_URL=$(op read "op://Development/Database/url")
export STRIPE_KEY=$(op read "op://Development/Stripe/secret_key") # Or inject into a process directly
op run --env-file=.env.tpl -- -weight: 500;">npm run -weight: 500;">start
# Store a secret
aws secretsmanager create-secret \ --name prod/database-url \ --secret-string "postgresql://prod_user:[email protected]:5432/app" # Retrieve it (in your app startup or entrypoint script)
aws secretsmanager get-secret-value \ --secret-id prod/database-url \ --query SecretString \ --output text
# Store a secret
aws secretsmanager create-secret \ --name prod/database-url \ --secret-string "postgresql://prod_user:[email protected]:5432/app" # Retrieve it (in your app startup or entrypoint script)
aws secretsmanager get-secret-value \ --secret-id prod/database-url \ --query SecretString \ --output text
# Store a secret
aws secretsmanager create-secret \ --name prod/database-url \ --secret-string "postgresql://prod_user:[email protected]:5432/app" # Retrieve it (in your app startup or entrypoint script)
aws secretsmanager get-secret-value \ --secret-id prod/database-url \ --query SecretString \ --output text
# Pull secrets as env vars
infisical export --env=production --format=dotenv > .env # Or inject directly
infisical run --env=production -- -weight: 500;">npm -weight: 500;">start
# Pull secrets as env vars
infisical export --env=production --format=dotenv > .env # Or inject directly
infisical run --env=production -- -weight: 500;">npm -weight: 500;">start
# Pull secrets as env vars
infisical export --env=production --format=dotenv > .env # Or inject directly
infisical run --env=production -- -weight: 500;">npm -weight: 500;">start
# AWS — deactivate the key right now
aws iam -weight: 500;">update-access-key \ --access-key-id AKIAEXAMPLE \ ---weight: 500;">status Inactive \ --user-name affected-user # Then delete it
aws iam delete-access-key \ --access-key-id AKIAEXAMPLE \ --user-name affected-user
# AWS — deactivate the key right now
aws iam -weight: 500;">update-access-key \ --access-key-id AKIAEXAMPLE \ ---weight: 500;">status Inactive \ --user-name affected-user # Then delete it
aws iam delete-access-key \ --access-key-id AKIAEXAMPLE \ --user-name affected-user
# AWS — deactivate the key right now
aws iam -weight: 500;">update-access-key \ --access-key-id AKIAEXAMPLE \ ---weight: 500;">status Inactive \ --user-name affected-user # Then delete it
aws iam delete-access-key \ --access-key-id AKIAEXAMPLE \ --user-name affected-user
# Check AWS CloudTrail
aws cloudtrail lookup-events \ --lookup-attributes AttributeKey=AccessKeyId,AttributeValue=AKIAEXAMPLE \ ---weight: 500;">start-time "2024-01-01" \ --end-time "2024-12-31" \ --max-results 50
# Check AWS CloudTrail
aws cloudtrail lookup-events \ --lookup-attributes AttributeKey=AccessKeyId,AttributeValue=AKIAEXAMPLE \ ---weight: 500;">start-time "2024-01-01" \ --end-time "2024-12-31" \ --max-results 50
# Check AWS CloudTrail
aws cloudtrail lookup-events \ --lookup-attributes AttributeKey=AccessKeyId,AttributeValue=AKIAEXAMPLE \ ---weight: 500;">start-time "2024-01-01" \ --end-time "2024-12-31" \ --max-results 50
aws cloudwatch put-metric-alarm \ --alarm-name "BillingAlarm-100USD" \ --metric-name EstimatedCharges \ --namespace AWS/Billing \ --statistic Maximum \ --period 21600 \ --threshold 100 \ --comparison-operator GreaterThanThreshold \ --evaluation-periods 1 \ --alarm-actions "arn:aws:sns:us-east-1:YOUR_ACCOUNT_ID:billing-alerts" \ --dimensions Name=Currency,Value=USD
aws cloudwatch put-metric-alarm \ --alarm-name "BillingAlarm-100USD" \ --metric-name EstimatedCharges \ --namespace AWS/Billing \ --statistic Maximum \ --period 21600 \ --threshold 100 \ --comparison-operator GreaterThanThreshold \ --evaluation-periods 1 \ --alarm-actions "arn:aws:sns:us-east-1:YOUR_ACCOUNT_ID:billing-alerts" \ --dimensions Name=Currency,Value=USD
aws cloudwatch put-metric-alarm \ --alarm-name "BillingAlarm-100USD" \ --metric-name EstimatedCharges \ --namespace AWS/Billing \ --statistic Maximum \ --period 21600 \ --threshold 100 \ --comparison-operator GreaterThanThreshold \ --evaluation-periods 1 \ --alarm-actions "arn:aws:sns:us-east-1:YOUR_ACCOUNT_ID:billing-alerts" \ --dimensions Name=Currency,Value=USD
# Install -weight: 500;">git-filter-repo (preferred over the older -weight: 500;">git filter-branch)
-weight: 500;">pip -weight: 500;">install -weight: 500;">git-filter-repo # Remove a specific file from all history
-weight: 500;">git filter-repo --invert-paths --path .env --force # Force push to overwrite remote history
-weight: 500;">git push origin --force --all
# Install -weight: 500;">git-filter-repo (preferred over the older -weight: 500;">git filter-branch)
-weight: 500;">pip -weight: 500;">install -weight: 500;">git-filter-repo # Remove a specific file from all history
-weight: 500;">git filter-repo --invert-paths --path .env --force # Force push to overwrite remote history
-weight: 500;">git push origin --force --all
# Install -weight: 500;">git-filter-repo (preferred over the older -weight: 500;">git filter-branch)
-weight: 500;">pip -weight: 500;">install -weight: 500;">git-filter-repo # Remove a specific file from all history
-weight: 500;">git filter-repo --invert-paths --path .env --force # Force push to overwrite remote history
-weight: 500;">git push origin --force --all - My project: Hermes IDE | GitHub
- Me: gabrielanhaia - Run gitleaks detect --source . -v on every repo you own. Takes 30 seconds per repo.
- Add pre-commit with detect-secrets or gitleaks to your most active project. Takes 5 minutes.
- Set up an AWS billing alarm at $50 or $100. Takes 2 minutes and could save you thousands. - GitGuardian State of Secrets Sprawl — annual data on leaked credentials
- TruffleHog — secret scanner with verification
- Gitleaks — fast -weight: 500;">git secret scanning
- detect-secrets — Yelp's pre-commit hook for secrets
- -weight: 500;">git-filter-repo — rewrite -weight: 500;">git history safely