| name | leak-check |
| description | Scan codebase and git history for leaked secrets — API keys, tokens, passwords, private keys. Uses whispers-style regex patterns + gitleaks. Run as /leak-check before any git push. Alerts on Claude API keys, GitHub tokens, AWS credentials, and generic high-entropy strings. |
| origin | Skyscanner/whispers + gitleaks/gitleaks (MIT) + marionevra/awesome-ai-agents-security patterns |
| license | MIT |
| version | 1.0.0 |
| compatibility | bash, git, any project type |
leak-check
When to Use
- Before every
git push (add to pre-push hook)
- After adding new config files, .env samples, or API integration code
- When onboarding a new developer — scan the full history
- Whenever the CI pipeline flags a suspicious commit
- Triggered by:
/leak-check, "scan for leaked secrets", "check for exposed tokens", "are there any API keys in the repo"
Do NOT use for
- Runtime secret rotation (use vault/SSM for that)
- Encrypting secrets — this is detection only, not remediation
- Replacing a proper secrets manager (see
supply-chain-security skill for full supply-chain hardening)
Quick Scan (regex-based, no install required)
#!/usr/bin/env bash
PATTERNS=(
"sk-ant-[a-zA-Z0-9_-]{20,}"
"sk-[a-zA-Z0-9]{48}"
"gh[pos]_[A-Za-z0-9_]{36}"
"github_pat_[A-Za-z0-9_]{82}"
"AKIA[0-9A-Z]{16}"
"aws_secret_access_key\s*=\s*[A-Za-z0-9/+=]{40}"
"-----BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY-----"
"(api_key|apikey|secret|password|token|passwd)\s*[=:]\s*['\"][A-Za-z0-9+/=_-]{20,}['\"]"
)
FOUND=0
for pattern in "${PATTERNS[@]}"; do
matches=$(git grep -rniE "$pattern" -- ':!*.lock' ':!node_modules' ':!vendor' 2>/dev/null || true)
if [[ -n "$matches" ]]; then
echo "LEAK DETECTED — pattern: $pattern"
echo "$matches"
FOUND=$((FOUND+1))
fi
done
git log --all --oneline | grep -iE "(api.?key|secret|password|token)" | head -5 && \
echo "WARNING: suspicious words found in commit messages — review above"
[[ -eq 0 ]] && || 1
Full Scan with gitleaks
brew install gitleaks
gitleaks detect --source . --verbose
gitleaks detect --source . --log-opts="--all" --verbose
gitleaks detect --source . --report-format sarif --report-path gitleaks-report.sarif
Pre-Push Hook Integration
echo "[yamtam/leak-check] Scanning for secrets before push..."
FOUND=0
for pattern in \
"sk-ant-[a-zA-Z0-9_-]{20,}" \
"AKIA[0-9A-Z]{16}" \
"gh[pos]_[A-Za-z0-9_]{36}" \
"-----BEGIN.*PRIVATE KEY-----"; do
if git grep -rqiE "$pattern" -- ':!*.lock' ':!node_modules' 2>/dev/null; then
echo "BLOCKED: secret pattern detected ($pattern)"
FOUND=$((FOUND+1))
fi
done
[[ $FOUND -gt 0 ]] && exit 1
echo "[leak-check] CLEAN — push allowed"
exit 0
Remediation Steps (If Leak Found)
echo "SECRET_KEY=" > .env
java -jar bfg.jar --replace-text patterns.txt .git
git filter-repo --path-glob '**/.env' --invert-paths
git push --force-with-lease
bash core/scripts/secure-logger.sh "incident" "secret leaked: <type>, revoked, history rewritten at $(git rev-parse HEAD)"
CI Integration (GitHub Actions)
name: Secret Scan
on: [push, pull_request]
jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Anti-Fake-Pass Checklist