Detect hardcoded secrets in source code using pattern-based scanning for API keys, tokens, passwords, private keys, and connection strings. Use before committing, during code review, or for post-incident history scanning. Self-contained — no external tools required.
How this skill is triggered — by the user, by Claude, or both
Slash command
/prodsec-skills-ge-core:secrets-detection-patternsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Pattern-based secrets detection for source code. This skill provides regex patterns, false positive filtering criteria, and remediation guidance for detecting hardcoded secrets. It is self-contained — no external tools (trufflehog, gitleaks) are required, though they are recommended as complementary tooling.
Pattern-based secrets detection for source code. This skill provides regex patterns, false positive filtering criteria, and remediation guidance for detecting hardcoded secrets. It is self-contained — no external tools (trufflehog, gitleaks) are required, though they are recommended as complementary tooling.
Any confirmed secret in code results in a BLOCKED verdict. There is no passing threshold — secrets in code are a critical finding. A secret is either present or it is not.
Reports must NEVER include actual secret values. Report secret type, file path, and line number only. Pattern matches are redacted to show type and location: e.g., "AWS Access Key at src/config.js:42".
Format: AKIA followed by 16 alphanumeric characters.
AKIA[0-9A-Z]{16}
40-character base64-like strings after a known label.
(aws_secret_access_key|aws_secret_key)\s*[=:]\s*[A-Za-z0-9/+=]{40}
Prefixes: ghp_, gho_, ghu_, ghs_, ghr_.
(ghp_|gho_|ghu_|ghs_|ghr_)[A-Za-z0-9_]{36}
RSA, EC, DSA, and OpenSSH private key headers.
-----BEGIN (RSA |EC |DSA |OPENSSH |PRIVATE )PRIVATE KEY-----
High-confidence labeled password assignments with values >= 8 characters.
(password|passwd|pwd|secret|api_key|apikey|api_secret|client_secret|auth_token|access_token)\s*[=:]\s*['"][^'"]{8,}['"]
Connection strings with embedded credentials.
(mysql|postgresql|postgres|mongodb|redis|amqp|jdbc)://[^@\s]+:[^@\s]+@
Three-part base64url segments separated by dots, starting with eyJ.
eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}
Prefix: xox[bpaso]-.
xox[bpaso]-[A-Za-z0-9-]{10,}
Prefix: AIza.
AIza[0-9A-Za-z_-]{35}
Prefixes: sk_live_, pk_live_, rk_live_, sk_test_.
(sk_live_|pk_live_|rk_live_|sk_test_)[0-9a-zA-Z]{24,}
Classify a match as FALSE POSITIVE if:
test/, tests/, spec/, fixtures/, __tests__/, testdata/).md, .rst, .txt, .adoc) showing an example format# example: AKIA...)AKIAIOSFODNN7… — AWS's documented sample key — your-secret-here, <YOUR_API_KEY>, xxx...xxx).env.example, .env.sample, or .env.template filepassword: 'test' in test files)mock, stub, fake)Classify a match as CONFIRMED if:
When secrets are detected:
example or fixture and use obviously fake valuesIf secrets have been committed to git history, consider:
git filter-branch or BFG Repo-Cleaner to remove from historytrufflehog or gitleaks for comprehensive history reviewFor production use, consider also deploying:
Note: The patterns in this skill use regex-based detection only. Entropy-based detection (for unstructured high-entropy strings) requires external tooling.
npx claudepluginhub redhatproductsecurity/prodsec-skills --plugin prodsec-skills-ge-coreScans source code and git history for hardcoded secrets, API keys, passwords, credentials using gitleaks, detect-secrets, grep patterns. Categorizes risks and suggests prevention like pre-commit hooks.
Detects hardcoded secrets, API keys, credentials, tokens, and private keys in source code and git history using regex patterns for pentesting and code reviews.
Detects API keys, passwords, tokens, and other secrets in source code using pattern matching and entropy analysis. Scan directories or specific paths for leaked credentials.