Hunt: Exposed Secrets (golden-image rework)
Turn an exposure surface into evidence-carrying CANDIDATES for credential exposure: .git history, .env/config files, JS bundles + source maps, public repos, CI logs, S3/blob listings. This skill produces candidates, never verdicts - and for this class the verdict is cheap: LIVE validation is mandatory before anything is a finding.
Current emphasis (update on wiki harvest): source-map rebuilt-source mining and --only-verified live validation over raw regex key greps - the newest harvested technique leads until superseded.
Assumes hunt-core for the scope gate, two-account rule,
confirmation gate, enumeration limits, stop conditions, wiki protocol,
FIND output, and Deadends. Do not re-derive any of that here.
Wiki
Hub: [[web-moc]] - Primary page: [[secret-hunting]] - Arsenal: [[recon-dorks]] Anchors: [[javascript-source-map-exploitation]], [[git-exposure]], [[static-code-analysis]], [[supply-chain-attacks]], [[aws-service-s3-buckets]], [[aws-access-token-secrets]] REFS: [[secret-hunting]]
mcp__wiki-search__query (lex) "exposed secrets git directory .env config hardcoded API keys JS bundle source maps S3 CI leakage" via wiki-search MCP - ONLY on a concrete hint the map above does not cover; not a blanket first step.
Shared bypass arsenal (blocked implies research, but walk this first): skills/exploit/hunt/hunt-secrets/references/bypass-arsenal.md - NEW 2025-2026 surfaces (CI runner dumps, MCP config keys, agent transcripts, sourcemaps, publish overshoot) + the RoE-safe verification ladder..
Paths (binding - define once at the top of the run notes)
# seat side (wsl) - engagement tree is DOUBLE-NESTED in VMshare:
ENG_DIR=/mnt/c/Users/Lenovo/Desktop/VMshare/<eng>/<eng>
RUN=$ENG_DIR/hunt/secrets/<host>
# VM side (WHERE trufflehog/gitleaks/git-dumper run, same tree):
ENG_DIR=/mnt/VMshare/<eng>/<eng>
RUN=$ENG_DIR/hunt/secrets/<host>
Corpus and probes live in the VMshare tree; the VM runs tools against the /mnt/VMshare spelling as user tz; the seat reads the same bytes at the /mnt/c/Users/Lenovo/Desktop/VMshare spelling. The repo tree targets/ is admin/ingest only - dumps and candidate lists NEVER land there.
Transport
Every VM-native command block ships through ONE documented transport:
wsl.exe -d kali-linux -u root bash -c "cd /mnt/c/Users/Lenovo/Documents/ObisidianVaults/ZTorch/ZTorch && bash scripts/vm-ssh.sh '<command>'"
- vm-ssh lands as user tz (NOT root): no root-only paths, no sudo.
- vm-ssh.sh takes the command as ONE argument; quotes ship as base64
(
echo <b64> | base64 -d | bashinside the vm-ssh argument). - Non-login shells do NOT source profile.d: target-facing fetches MUST use /opt/scope-shim/bin/{curl,httpx} by absolute path.
- Shim verdict semantics (verified live): out-of-scope dies rc 126 (never work around); in-scope passes; UNKNOWN gets an ADVISORY - not approval; verify against scope.md and self-deny.
- Bucket/repo enumeration = many-requests loops: run detached (vm-bg.sh), read logs back; the bridge drops at ~2min.
Entry gate
All four must pass; each is falsifiable:
Active engagement exists (repo tree targets//active.md) and is on targets//scope.md in-scope. Scope-guard is the deny. (targets/ is the repo admin tree; $ENG_DIR holds corpus and run artifacts only - see Paths.)
hunt-core loaded (skills/exploit/hunt/hunt-core/SKILL.md).
Producer verified - at least ONE of: (a) $ENG_DIR/state.md asset table has >= 1 endpoint row for ;
(b) a js-discover corpus exists ($ENG_DIR/js// with manifest.md passing sha256sum -c from its dir) - secrets.jsluice pass A0 already seeded;
(c) kickoff seeded $RUN/raw/surface-notes.md. None = dispatch the surface lane first.Toolchain preflight (fails LOUD; trufflehog/gitleaks/git-dumper probed, N/A-echo each when absent and the branch needs them):
for t in /usr/bin/jq /usr/bin/python3 \ /opt/scope-shim/bin/curl; do [ -x "$t" ] || { echo "MISSING TOOL: $t"; exit 1; } done # install-on-demand (operator rule): install what the branch needs command -v trufflehog >/dev/null || pip3 install --user --break-system-packages -q trufflehog || echo "N/A: trufflehog absent on VM (install failed)" command -v gitleaks >/dev/null || { git clone -q --depth 1 https://github.com/gitleaks/gitleaks /tmp/gitleaks && cd /tmp/gitleaks && HOME=/home/tz go install . && cd -; } || echo "N/A: gitleaks absent on VM (install failed)" command -v git-dumper >/dev/null || pip3 install --user --break-system-packages -q git-dumper || echo "N/A: git-dumper absent on VM (install failed)"
Checklist (mandatory)
Copy checklist.md (this skill's dir) to
$ENG_DIR/hunt/secrets/<host>/secrets-checklist.md at run start.
Unchecked at stop = UNCHECKED lane, re-run from the first unchecked
step. The SKILL.md text and the checklist header agree byte-for-byte
on that copy target.
Nudge
Review-skill re-injection text (pinned; NOTE: completion-gate emits its own generic nudge - both mean: resume at the first unchecked box):
Your work was just reviewed by the review skill and it was found
that you either missed a step of analysis, or didn't generate an
artifact of sufficient proof. Look at the markdown based checklist
and the output for each step, find what you missed, and complete
that step.
Confirmation gate
NOT confirmation: a high-entropy string; a variable named API_KEY / SECRET; a scanner or regex match (a trufflehog/gitleaks hit on its own); a key in old git history you have not tested; an .env.example placeholder; an already-rotated or invalid key.
IS confirmation: the secret VALIDATED against its own service with a single benign read-only call returning an authenticated-success signal (an identity, a 200/valid) - live and unrotated. Live validation is mandatory for this class; a string that merely looks like a key is never a finding.
Stop rule: validate with ONE minimal read-only call, observe only the auth-success signal, then stop. Never use the key a second time, never call a data/list endpoint, never write, never exfiltrate with it. A rotated/invalid key is a Deadend.
Secret-hunting quick reference (use this, don't hand-roll)
| Operation | Command | Step |
|---|---|---|
| Probe a fixed dotfile/config path | `curl -s -o /dev/null -w "%{http_code} | |
| " "https://target.com/"` (.env, .git/HEAD, .git-credentials, .aws/credentials, .npmrc, config.json) | 1 | |
| Dump an exposed .git/ directory | git-dumper https://target.com/.git/ ./dump |
2 |
| Mine dumped repo, verified only | trufflehog filesystem ./dump --only-verified |
2 |
| Mine dumped repo (gitleaks) | gitleaks detect --source ./dump --no-banner |
2 |
| Grep a JS bundle for key shapes | curl -s https://target.com/static/js/main.js | grep -Eo '(AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{35}|sk_live_[0-9a-zA-Z]{24}|ghp_[0-9A-Za-z]{36}|xox[baprs]-[0-9A-Za-z-]+)' |
3 |
| Rebuild source from a JS source map | npx source-map-explorer@2.5.3 main.js main.js.map |
3 |
| Mine rebuilt bundle source | trufflehog filesystem ./bundles --only-verified |
3 |
| List an S3 bucket (public-read proof) | aws s3 ls s3://<name> --no-sign-request |
4 |
| List a GCS bucket | curl -s "https://storage.googleapis.com/<name>/" |
4 |
| List an Azure blob container | curl -s "https://<name>.blob.core.windows.net/?comp=list" |
4 |
| Search public GitHub org/repos | trufflehog github --org=<org> --only-verified |
5 |
| Mine a cloned repo | gitleaks detect --source ./cloned-repo --no-banner |
5 |
Methodology
Rank before probing - highest yield first: exposed .git/ (full source + history) > exposed .env/config files > JS bundles + source maps (rebuilt original source) > public repos (org + employee) > CI/CD build logs > S3/blob listings. Route the load-bearing confirm (exposed .git/.env fetch, key validity check) through Burp Repeater; quick loops stay in the terminal.
Step 1 - Dotfile/config probes (fixed path list, NOT an ID sweep)
for p in .env .env.local .git/HEAD .git-credentials \
.aws/credentials .npmrc config.json; do
printf '%s -> ' "$p"
/opt/scope-shim/bin/curl -s -o /dev/null -w "%{http_code}
"
"https:///$p"
done
@ $RUN/raw/path-probes.md (rows: path | status | verdict).
Step 2 - .git exposure -> dump + mine
/opt/scope-shim/bin/curl -s https://<host>/.git/HEAD # ref = exposed
git-dumper https://<host>/.git/ "$RUN"/dump
trufflehog filesystem "$RUN"/dump --only-verified
gitleaks detect --source "$RUN"/dump --no-banner
@ $RUN/probes/git-mining.jsonl (one row per candidate with commit provenance).
Step 3 - JS bundle + source-map mining
Consume the js-discover corpus where present (raw/ + sourcemaps/); else pull bundles directly. Grep key shapes; rebuild original source from maps and mine THAT (the current-emphasis technique - rebuilt source carries comments, original identifiers, and test keys the minified bundle hides):
/opt/scope-shim/bin/curl -s https://<host>/static/js/main.js \
| grep -Eo '(AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{35}|sk_live_[0-9a-zA-Z]{24}|ghp_[0-9A-Za-z]{36}|xox[baprs]-[0-9A-Za-z-]+)'
npx source-map-explorer@2.5.3 main.js main.js.map 2>/dev/null
trufflehog filesystem ./bundles --only-verified
@ $RUN/probes/js-secrets.jsonl. Interceptor-sourced hits on the operator's own session headers/cookies are tagged provenance= self-identity and never promoted (js-parser rule, inherited).
Step 4 - S3/blob enumeration (list to prove, ONE object as evidence)
aws s3 ls s3://<name> --no-sign-request # public list = proof
/opt/scope-shim/bin/curl -s "https://storage.googleapis.com/<name>/"
/opt/scope-shim/bin/curl -s "https://<name>.blob.core.windows.net/?comp=list"
Pull at most ONE benign object as evidence, never bulk-sync real data (hunt-core stop conditions). @ $RUN/probes/buckets.jsonl.
Step 5 - Public repos + org search
trufflehog github --org=<org> --only-verified
# manual dorks ([[recon-dorks]]): "target.com" password
# filename:.env org:<org>
gitleaks detect --source ./cloned-repo --no-banner
@ $RUN/probes/repos.jsonl.
Step 6 - CI/CD leakage
Build logs, GitHub Actions artifacts, pull_request_target output, exposed .gitlab-ci.yml vars, printed env in public job logs. @ $RUN/probes/ci.jsonl (N/A: no public CI surface).
Step 7 - Candidate collection + live validation
Collect every candidate with its type tag (aws/gcp/slack/stripe/ github/db-uri). ONE benign call per candidate, auth-success signal only:
aws sts get-caller-identity # own identity ARN
/opt/scope-shim/bin/curl -s -o /dev/null -w '%{http_code}
'
-H "Authorization: token ***" https://api.github.com/user
/opt/scope-shim/bin/curl -s -d "token=$SLACK" https://slack.com/api/auth.test
/opt/scope-shim/bin/curl -s -o /dev/null -w '%{http_code}
'
https://api.stripe.com/v1/balance -u "$SK:" # NOT /v1/charges
/opt/scope-shim/bin/curl -s "https://maps.googleapis.com/maps/api/geocode/json?address=x&key=$KEY"
trufflehog --only-verified already live-checks; still re-confirm scope-impacting creds manually. @ $RUN/probes/validation.jsonl (rows: candidate ref | type | call | signal | verdict). Validated cloud keys hand off to hunt-cloud - do NOT enumerate services here; the confirmation call is where this skill stops.
Step 8 - Exit artifact (candidates)
candidates.md every class section present; pointer $ENG_DIR/hunt-secrets-.md:
SECRETS-HUNT-DONE candidates=<n> verified=<n>
(git=<n> js=<n> buckets=<n> repos=<n> ci=<n>)
Plus _requests.md rows (lane = hunt-secrets), state.md asset rows, Deadends rows with the WHY. Every probe JSONL row: {class, host, endpoint, method, evidence, observed, confidence}; pairs under probes/raw/ (sha256 filenames). Candidate KEY VALUES never enter candidates.jsonl - only type + provenance + validation verdict (leak hygiene: keys live in $RUN/probes/raw/ pairs only).
Validation
- Proof = the secret USED against its real service once, auth-success signal only. A regex hit is a HYPOTHESIS until used.
- Counterevidence: canary/decoy keys alert on use; check last-used timestamps where a console exposes them before calling the credential live.
False Positives
- Example/template keys in docs and tests.
- Placeholders in committed sample configs.
- Rotated-and-revoked keys still present in old commits.
- Known-public dataset keys (training corpora).
Cross-routing
- hunt-cloud when the credential is cloud IAM (escalation lives there).
- hunt-auth for cred reuse against the app's own login.
- hunt-api for token scope/entitlement checks.
- Pub/sub SUBSCRIBE credentials (Mercure JWT, SSE/WS tokens): after the
validation call, continue with
references/pubsub-hub-credential-testing.md- authz-model probes, topic guessability, and event-payload capture decide the severity; a validated-but-silent hub is not the end of the class. - Not this skill: public-by-design API documentation endpoints.
Severity
Rated on what the validated key reaches:
| Key / scope | Typical |
|---|---|
| Cloud/admin creds, prod-DB URI, org-wide token | critical |
| Scoped prod API key / service token | high |
| Limited-scope or read-only key | medium |
| Low-value, or rotated/invalid with only the exposure path | low - info |
Coverage / evasion
Do not stop at the dotfile probe. A single clean main.js is not "no client-side secrets" - walk every bundle, webpack chunk, *.js.map, inline script, NEXT_DATA. Deleted commits frequently survive in fork/gist/cache; a private repo today may have leaked in a public commit yesterday. Log each surface cleared so the coverage table shows the class actually tested.
Deadends
Append: - [ ] Secret exposure on <host/repo> -- .git absent,
configs 404, bundles + source maps clean, buckets private, repos
dry, candidates invalid/rotated
Record what you cleared, not just that it failed.
N/A escapes
- "N/A: trufflehog absent on VM (install failed)" (manual validation calls still run)
- "N/A: gitleaks absent on VM (install failed)"
- "N/A: git-dumper absent on VM (install failed)" (manual wget -r fallback noted)
- "N/A: no public CI surface" An N/A tick is a claim with a reason, never a silent pass. Identical strings in SKILL.md and checklist.md.
Bitter-pill variant
Freehand run: skip checklist + numbered steps, one freehand pass over the surface, output ONLY $RUN/analysis/bitter-pill.md (tried/found/ dismissed, every claim carries evidence). Live validation survives freehand - no unverified key claim. Declare with a _requests.md row (lane = hunt-secrets-bitterpill).
Depth walk (mandatory)
Walk EVERY applicable row of the payload arsenal page cited above.
Record each row in $RUN/coverage-depth.md as a table
| row | state | evidence | where state is probed, blocked, or
N/A, and evidence is a probe-pair path or a Deadends.md line. A bare
probed with no evidence reference fails the completion gate
(NEEDS-REVIEW). N/A rows cite why (surface shape forbids it).
Blocked implies research: before any Deadend is claimable on a blocked
row, (a) walk the arsenal page's bypass-ladder rows for that control
class, and (b) run one wiki query AND one mcp__wigolo__search for the
specific tech-plus-control bypass. Results, or a genuine null, land in
coverage-depth.md. "No research tried" is not a claimable state.
Exit artifact + handoff
ONE exit artifact set: $RUN/candidates.jsonl + candidates.md +
$ENG_DIR/hunt-secrets-.md (pointer with SECRETS-HUNT-DONE +
counts). Consumer (triage) finds at $RUN: raw/path-probes.md,
probes/*.jsonl, probes/raw/, candidates.{jsonl,md}. Findings leave
ONLY through G1. Distill: python3 scripts/wiki-stage.py --kind technique --slug <slug> --target-page techniques/osint/ secret-hunting.md.
Stop conditions
Terminal states complete; ONE-call validation rule enforced; cloud keys handed off at confirmation (no service enumeration here); nothing written into skill dirs; no unchecked boxes above REVIEW; hunt-core stop conditions fire unchanged.
Attack surface
APPROACH: Rank highest-yield first - exposed .git/ (dump + mine history) > .env/config files > JS bundles + source maps (rebuilt source) > public org/employee repos > CI logs > S3/blob listings; collect each candidate with its type tag, then LIVE-validate.
AVOID: A high-entropy string, an API_KEY variable, a trufflehog/gitleaks regex hit, or a key from old history you never tested is NOT confirmation - the secret must validate against its own service with ONE benign read-only call.