/penetration-tester:scanning-for-hardcoded-secretsfrom penetration-tester
Scans source code trees for hardcoded credentials including AWS keys, GitHub tokens, Stripe keys, and high-entropy strings. Useful as a pre-commit gate or post-incident audit.
Ships in penetration-tester. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
The single most common cause of credential breach in 2026 remains
hardcoded secrets in source code. Engineers paste an API key into a
config file "just for testing," forget to remove it, commit the
file. The credential is now in the repository's history forever
(git rebase doesn't help if anyone cloned in between) and
extractable by anyone who reaches the repo: contractors,
ex-employees, attackers via .git/ directory exposure (see skill
six), GitHub bot scrapers crawling public repos.
The cost of detection-after-commit is near-zero (free tools exist: gitleaks, trufflehog, this skill). The cost of detection-before-commit is also near-zero (pre-commit hooks). The cost of remediation after the fact is rotating every credential exposed + auditing for exploitation + potentially notifying customers of breach. The asymmetry is severe, the discipline is the only constraint.
This skill scans a filesystem tree, matching against a canonical regex library covering the credential shapes attackers and bots search for first.
| Finding | Severity | Threshold | Affected control |
|---|---|---|---|
| AWS access key (AKIA-prefix) | CRITICAL | Literal AKIA[0-9A-Z]{16} in any file | CWE-798 |
| AWS secret access key | CRITICAL | 40-char base64 in aws_secret_access_key field context | CWE-798 |
| GitHub personal access token | CRITICAL | ghp_[A-Za-z0-9]{36} or gho_, ghu_, ghs_, ghr_ | CWE-798 |
| GitHub app installation token | CRITICAL | ghs_[A-Za-z0-9]{36} | CWE-798 |
| Stripe live key | CRITICAL | sk_live_[A-Za-z0-9]{24,} | CWE-798 |
| Stripe test key | MEDIUM | sk_test_[A-Za-z0-9]{24,} | CWE-798 |
| Anthropic API key | CRITICAL | sk-ant-api03-[A-Za-z0-9_-]{93} or similar | CWE-798 |
| OpenAI API key | CRITICAL | sk-(proj-)?[A-Za-z0-9_-]{40,} | CWE-798 |
| Slack bot token | CRITICAL | xoxb-[A-Za-z0-9-]+ | CWE-798 |
| Slack user token | CRITICAL | xoxp-[A-Za-z0-9-]+ | CWE-798 |
| Google API key | HIGH | AIza[A-Za-z0-9_-]{35} | CWE-798 |
| RSA / OpenSSH private key | CRITICAL | BEGIN PRIVATE KEY header (RSA, OPENSSH, EC, DSA variants) | CWE-321 |
| JWT secret | HIGH | Long string in jwt_secret, JWT_SECRET, signing_secret field | CWE-321 |
| Generic password literal | HIGH | password = "..." with non-placeholder value | CWE-798 |
| High-entropy string in key/token field | MEDIUM | Shannon entropy ≥ 4.5 in key:/token: field context | CWE-798 |
.env-shaped KEY=VALUE in non-.env file | HIGH | Multiple [A-Z_]+= lines in .py/.js/.md files | CWE-200 |
This skill scans a filesystem path. No authorization gate (it operates on local source code, not network targets).
python3 ${CLAUDE_PLUGIN_ROOT}/skills/scanning-for-hardcoded-secrets/scripts/scan_secrets.py /path/to/repo
Options:
Usage: scan_secrets.py PATH [OPTIONS]
Options:
--output FILE Write findings to FILE (default: stdout)
--format FMT json | jsonl | markdown (default: markdown)
--min-severity SEV (default: info)
--include-tests Include files under tests/, test/, __tests__/, spec/
(default: excluded to reduce false positives)
--git-history N Also scan the last N git commits' diffs (default: 0
= working tree only)
--exclude GLOB Skip files matching glob (repeatable)
--entropy-only Only flag entropy-based findings (skip regex)
The scanner walks the tree, applies the regex library to every file's contents, and emits a Finding per match with file path, line number, severity, and the redacted matched text.
CRITICAL = the matched string is a real credential shape that upstream tools auto-extract. Rotate the credential immediately. Audit logs for any API call against that credential since the commit landed.
HIGH = pattern strongly suggests credential but requires manual verification (the literal might be a placeholder or test fixture).
MEDIUM / LOW = entropy-based heuristic that needs human review.
For any confirmed real credential:
references/PLAYBOOK.md for per-language patterns.git filter-repo or BFG Repo-Cleaner can purge the secret from history, but only if you
can force-push and coordinate with every clone-holder. For
public repos, history-scrub is often not worth the disruption
compared to just rotating.# .git/hooks/pre-commit (or via pre-commit framework)
python3 plugins/security/penetration-tester/skills/scanning-for-hardcoded-secrets/scripts/scan_secrets.py \
--min-severity high --format json . | jq -e 'length == 0' \
|| { echo "Secrets detected. Fix before commit."; exit 1; }
- name: Hardcoded-secrets scan
run: |
python3 plugins/security/penetration-tester/skills/scanning-for-hardcoded-secrets/scripts/scan_secrets.py \
. --min-severity high --format json --output secrets-scan.json
- run: |
if jq 'length > 0' secrets-scan.json | grep -q true; then
echo "::error::Hardcoded secret detected"
exit 1
fi
python3 ${CLAUDE_PLUGIN_ROOT}/skills/scanning-for-hardcoded-secrets/scripts/scan_secrets.py \
/path/to/acquired-repo --include-tests --min-severity medium
--include-tests is important here because legacy test fixtures
often contain real credentials someone forgot to redact.
JSON / JSONL / Markdown per lib/report.py. Exit codes: 0 clean, 1
high/critical, 2 error.
Matched strings are partially redacted in output (first 4 + last 4 chars visible, middle redacted) to avoid the scanner output itself becoming a leak surface.
<YOUR_KEY_HERE> →
the scanner skips strings containing <, >, EXAMPLE,
PLACEHOLDER, YOUR_, XXXX (configurable).references/THEORY.md — Per-credential-family threat model, why
each provider's keys are extracted by bots first, history-scrub
decision framework, entropy-detection theoryreferences/PLAYBOOK.md — Per-language migration patterns
(Python dotenv, Node .env+dotenv, Ruby Rails credentials, Go
envconfig), provider rotation procedures, GitHub secret-scanning
integrationWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub jeremylongshore/tons-of-skills-marketplace --plugin penetration-tester26 skills in this plugin
/analyzing-tls-configAnalyze a target's TLS configuration — negotiated protocol version, cipher
suite, certificate chain, expiry, and downgrade vectors.
Use when: SOC2 auditor flagged your endpoint for "weak TLS" but you don't
know which control failed (TSC CC6.7 transmission integrity vs CC6.6
encryption) or which cipher is the problem.
Threshold: any negotiated TLSv1.0 or TLSv1.1, OR a cipher with RC4 / 3DES /
null / EXPORT, OR a cert with under 30 days to expiry, OR a chain that fails
hostname verification.
Trigger with: "audit tls", "check ssl config", "weak tls", "analyze tls".
/auditing-cors-policyAudit a target's CORS posture — Access-Control-Allow-Origin handling,
reflected-origin bypass, credentials+wildcard mismatch, preflight
OPTIONS behavior, Vary header correctness.
Use when: a third-party integration is failing CORS preflight and
someone proposes "just set Allow-Origin to *" as the fix, OR your
bug-bounty inbox has a credential-reuse exploit chain.
Threshold: any reflection of arbitrary Origin into Allow-Origin,
Allow-Credentials:true with wildcard origin (browser-rejected combo
but server config wrong), missing Vary:Origin on per-origin responses,
preflight cached over 86400s, OR Allow-Origin trust of attacker-
controlled subdomain pattern.
Trigger with: "audit cors", "check cors policy", "cors bypass",
"preflight check".
Other plugins' skills for the same job