From cybersecurity-skills
Finds leaked secrets in source code, Git history, and build artifacts, then audits secrets-management posture to prevent future leaks. Supports manual grep patterns and gitleaks/trufflehog tooling.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cybersecurity-skills:secrets-auditThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Two halves: (1) find secrets that have already leaked into source, history, or artifacts, and (2) audit the secrets-management posture that determines whether future leaks happen.
Two halves: (1) find secrets that have already leaked into source, history, or artifacts, and (2) audit the secrets-management posture that determines whether future leaks happen.
Most secret leaks aren't "we forgot to redact" — they're "we never had a system, so every developer made up their own approach." This skill covers both the cleanup and the prevention.
Cross-references: dependency-audit (CI-related secrets risk in build-time exposure), iam-audit (workload identity federation as the alternative to long-lived keys), owasp-audit A02 (in-source secret patterns).
The most useful first sweep is grep against known provider key prefixes. False positives are low and matches are almost always real.
# Stripe
grep -rE "(sk_live_|sk_test_|rk_live_|whsec_)[A-Za-z0-9]{20,}" . \
--include="*.{js,ts,jsx,tsx,py,rb,go,java,php,sh,env,yml,yaml,json}"
# AWS access keys
grep -rE "(AKIA|ASIA)[A-Z0-9]{16}" .
# AWS secret keys (40 chars, base64-y) — high FP rate, use with caution
grep -rE "[A-Za-z0-9/+=]{40}" . --include="*.env*" --include="*.json"
# GitHub
grep -rE "gh[pousr]_[A-Za-z0-9]{36}" .
# Google Cloud API key + service-account JSON
grep -rE "AIza[A-Za-z0-9_-]{35}" .
grep -rln '"type": "service_account"' . --include="*.json"
# Slack
grep -rE "xox[baprs]-[A-Za-z0-9-]+" .
# OpenAI / Anthropic
grep -rE "sk-[A-Za-z0-9]{32,}" .
grep -rE "sk-ant-[A-Za-z0-9_-]{90,}" .
# Generic high-entropy strings in env files
grep -rE "^[A-Z_]+=[A-Za-z0-9/+=]{32,}$" . --include="*.env*"
For full repo coverage, use git ls-files to scope to tracked files and avoid node_modules:
git ls-files | xargs grep -lE 'sk_live_|ghp_|AKIA[A-Z0-9]{16}|sk-ant-|AIza[A-Za-z0-9_-]{35}' 2>/dev/null
| Tool | Use |
|---|---|
gitleaks detect | Fast, low FP, run as pre-commit and in CI; supports custom rules |
trufflehog git file://. | Verifies findings against the real API (high confidence) |
detect-secrets scan | Yelp's tool; good baseline file workflow |
| GitHub Secret Scanning | Free for public repos; covers most providers automatically; pushes get blocked at push time when enabled with push protection |
| GitLab Secret Detection | Similar, built-in to CI |
| GitGuardian / Doppler / Spectral | Commercial; add organizational dashboards and historical analysis |
A secret deleted in the latest commit is still in history — git log -p, git log -S<secret>, and any fork or local clone all have it.
# Search every commit for a pattern
git log -p -S "sk_live_" --all
# Search only deleted lines
git log -p --all | grep -E "^-.*sk_live_"
# Trufflehog historical scan
trufflehog git file://. --since-commit=<first-commit>
# Git history rewrite — destructive, coordinate first
git filter-repo --invert-paths --path config/secrets.yml
# or
bfg --delete-files secrets.yml
Critical caveat: rewriting history requires every developer to re-clone, every fork is still exposed, and the secret should be considered compromised regardless. Always rotate first, history-rewrite second.
Secrets leak in places that aren't .env files:
docker history <image> shows every ENV line; --build-arg SECRET=... ends up in layersset -x, console.log(process.env), error stack traces, debug outputNEXT_PUBLIC_* / VITE_* / REACT_APP_* env vars are shipped to the browser; grep the bundled JSprocess.env snapshotspg_dump of a table that includes user-stored API keys.env accidentally uploadedWhen you find a leaked secret:
aws sts get-caller-identity, stripe balance retrieve, curl -H "Authorization: Bearer $TOKEN" ...) — don't assume; some leaked keys are already revoked or were sandbox-onlyrepo vs admin:org| Tier | Pattern | When acceptable |
|---|---|---|
| ❌ | Hardcoded in source | Never |
| ❌ | Hardcoded in image / build artifact | Never |
| ❌ | Plaintext in shared docs / Slack | Never |
| ⚠️ | .env file in repo (even with .gitignore — easy to leak via push, backup, archive) | Bootstrap only; flagged in audit |
| ⚠️ | Environment variables (only) | Acceptable for ephemeral dev; weak for prod (visible in /proc, crash dumps, logs) |
| 🟢 | Secrets manager pulled at deploy time | Standard for most apps |
| 🟢 | Workload identity federation (no stored secret at all) | Best where supported |
.env committed — .gitignore covers .env* (with care for .env.example)iam-audit).env.local shipped to staging — environment-specific dev secrets cross the boundarypull_request_target and secret accessibility--build-arg AWS_SECRET=... ends up in image history (use --secret/BuildKit instead)process.env on unhandled exception — Sentry / Datadog / Bugsnag scrub config requiredcontainer-audit)# Secrets Audit Report
## Scope: [repos / environments / managers covered]
## Date: [date]
### Live leaked secrets found
| Provider | Location | First seen (commit / date) | Verified live? | Rotation status |
|---|---|---|---|---|
### Secrets-management posture
| Category | Status | Notes |
|---|---|---|
### Recommendations
| Priority | Item | Owner | Deadline |
|---|---|---|---|
Disposition rule (Fixed / Deferred / Accepted Risk) per owasp-audit.
gitleaks, trufflehog, detect-secrets documentationnpx claudepluginhub briiirussell/cybersecurity-skills --plugin cybersecurity-skillsScans source code for hardcoded secrets, API keys, and credentials; classifies risk severity; checks .gitignore and git history; enforces credential externalization.
Audits how secrets, credentials, and certificates are stored, rotated, and accessed. Detects hardcoded secrets and guides migration to centralized secret managers like Vault or AWS Secrets Manager.
Manages secrets via leak detection with gitleaks/grep, rotation scheduling, vault setups (AWS/GCP/Azure/HashiCorp Vault), .env safety checks, and access auditing. Activates on leak scans or overdue rotations.