Ashrafiucse secrets detection

From jiayaoqijia/cryptoskill · View interactive version

Ashrafiucse secrets detection is an AI agent skill from the GitHub repository jiayaoqijia/cryptoskill. Finds hardcoded secrets in any project — API keys (AWS, GitHub, Google, Stripe, Slack), passwords, tokens, private keys, JWTs, database URLs with credentials. Runs a fast regex scan, then triages matches to remove false positives and checks .env/git hygiene. Use when auditing a codebase for leaked c

How to use this skill

Skill file

Secrets Detection

Step 1 — Fast regex scan

bash scripts/scan.sh <project_root>

The script greps the pattern set in references/patterns.txt (one ERE regex per line — edit that file to tune, not the script). Output: file:line:matched line.

If grep -rE is unavailable, replicate manually with rg -n using the same patterns file.

Step 2 — Triage (kill false positives)

For each hit, read the surrounding code and drop it if the value is:

Keep — and flag as CRITICAL — anything that looks real: correct prefix + realistic entropy + committed to git history.

Step 3 — Hygiene checks

git ls-files | rg -i '\.env($|\.)'          # .env files tracked?
cat .gitignore 2>/dev/null | rg -i 'env|secret|key|pem'   # .env ignored?
git log --all --oneline -S 'AKIA' -- '*.py' 2>/dev/null | head  # leaked keys in history?
rg -n --hidden -g '!*.lock' -g '!package-lock.json' '(BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY)' <root>

Report:

  1. Committed real secrets → CRITICAL. Fix: rotate/revoke immediately (a removed file is not a revoked key), then scrub history (git filter-repo / BFG).
  2. Tracked .env files → CRITICAL regardless of content.
  3. Secrets in git history but not HEAD → HIGH (history is forever on clones/forks).
  4. Placeholder secrets in prod-looking config → MEDIUM (someone will "temporarily" deploy them).
  5. Secrets handling patterns — note whether the project uses env vars / secret manager properly, and whether secrets can leak into logs (see also ../data-exposure/SKILL.md).

Step 4 — Dev-artifact leak surface (developer tools commit secrets too)

rg --files --hidden -g '.vscode/**' -g '.idea/**' -g '*.postman_collection.json' -g '*.postman_environment.json' -g '*.http' -g '*.rest' -g 'devcontainer.json' -g '*.insomnia*' | head
rg -n -i "token|secret|password|api[_-]?key|authorization" .vscode/ .idea/ *.postman* *.http devcontainer.json 2>/dev/null | head

Same triage rules apply (fakes/fixtures dropped); these surfaces pair with the generic patterns from Step 1 — the difference is WHERE to look, not WHAT to match.

Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.