- Real API tokens, keys, or passwords
- Database connection strings with credentials
- SSH private keys
- AWS access keys
- JWT tokens
- Bearer tokens
- Any production credentials
- Internal environment names (e.g., specific console names, internal hostnames)
- Private development environment files
your-token-hereREPLACE_WITH_ACTUAL_TOKEN<your-api-key>${API_TOKEN}[TOKEN_PLACEHOLDER]demo-console,prod-console,console-a(for environment names)your-hostname,example-server(for internal systems)
Install pre-commit hooks to automatically detect secrets:
# Install pre-commit
pip install pre-commit
# Install hooks
pre-commit install
# Test hooks
pre-commit run --all-files# Use environment variables
export SAFEBREACH_API_TOKEN="actual-token"
# Use .env files (but don't commit them)
echo "API_TOKEN=real-token" >> .env
# Use template files
cp .env.template .env
# Edit .env with real values# DON'T hardcode in source
API_TOKEN = "2OJBRQBdICUDLNg8pVYlOG_-8SlBlzNvCYoh8kGEQso"
# DON'T put in documentation
"Authorization": "Bearer real-token-here"{
"mcpServers": {
"safebreach": {
"command": "npx",
"args": [
"mcp-remote",
"http://server:port/sse",
"--headers",
"{\"Authorization\": \"Bearer ${SAFEBREACH_TOKEN}\"}"
]
}
}
}${TOKEN}for shell examplesyour-token-herefor JSON examples<TOKEN>for XML/HTML examples- Always include instructions to replace placeholders
If secrets are accidentally committed:
- IMMEDIATE: Revoke the exposed credentials
- ASAP: Generate new credentials
- Remove from git:
git filter-branchor BFG Repo-Cleaner - Force push: Update remote history
- Notify team: Alert all developers
- Monitor: Check for unauthorized access
- GitLeaks: Detect secrets in git repos
- detect-secrets: Pre-commit hook for secret detection
- GitGuardian: Real-time secret scanning
- TruffleHog: Find secrets in git history
- git-secrets: AWS git secrets scanner
Before merging any PR:
- No hardcoded credentials
- Environment variables used properly
- Documentation uses placeholders only
- .env files not committed
- Pre-commit hooks passing
- Secret detection tools run clean
- Rotate API tokens
- Review git history for secrets
- Update .gitignore patterns
- Test pre-commit hooks
- Security training for team
- Review access permissions
- Update security tools
- Audit authentication logs
If you discover exposed secrets:
- Revoke immediately in the source system
- Contact security team: security@company.com
- File incident report: Include timeline and impact
- Update affected systems: Deploy new credentials
Remember: Prevention is better than remediation. When in doubt, ask the security team!