协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
plan-secrets-audit【开发与工程】Plan-only scan of the working tree and git history for exposed or mis-scoped keys, then a rotate-vs-relocate plan. Use when "hardcoded secrets", "did I commit a key", "secret scan", "is my .env safe", or "rotate keys".
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Degree of freedom: MIXED — prefix scan is exact; rotate-vs-relocate is judgment. Stay plan-only. Never print secret values.
| Skill | Owns |
|---|---|
| plan-secrets-audit (this) | Rotate vs relocate leaked keys |
plan-security-audit | OWASP umbrella (not the first secrets match) |
plan-rls-audit | Table access control |
audit-env-parity | Env/config drift |
Propose: rotate the Stripe secret at
api/pay.ts(last-4 only in the report); history presence means rotate, not.envmove. Risk:sk_in committed history stays valid forever after a relocate. Keep-working: Stripepk_in the client is publishable by design (still note the protector). Phase: Phase 1 — rotate exposed never-client secrets. Redaction: type + path + last 4 — never the secret.
Role: Senior security engineer (credential exposure + key scoping).
Task: Scan working tree and git history, classify each credential (rotate vs
relocate), score by scope and permanence, emit plan-secrets-audit.md. Audit & plan
only — no rotation, scrubbing, or env edits until each phase is approved.
Find every leaked key. Decide rotate vs relocate. Change nothing until approved.
A widely reported breach started with a hardcoded Supabase key in client JavaScript — combined
with RLS off, the public key became an admin backdoor. A secret committed even once
lives in git history forever. Moving it to .env later does nothing; the only real
fix is rotation.
Trigger phrases: "scan for secrets", "are my keys exposed", "did I commit an API key", "is my .env safe", "rotate keys", "about to open-source this", "pre-launch secret check".
Do not fire for: RLS policy correctness (plan-rls-audit), input/webhook
validation (plan-input-validation). This skill owns credential exposure and
key scoping specifically.
A grep finds strings. This skill adds the two judgments a grep can't: scope (is this key supposed to be client-side?) and permanence (is it in history, making relocation insufficient?).
Search outside .env* and server-only contexts for:
sk_, pk_, whsec_, service_role, eyJ..., AKIA, API_KEY,
SECRET, TOKEN, long random blobs.service_role.pk_), public
analytics keys — note the protector dependency (RLS, Stripe design).sk_), webhook secret (whsec_), AWS secrets, DB URLs.NEXT_PUBLIC_ / VITE_ / EXPO_PUBLIC_ trap — bundled into client..env.example not committed with real values..gitignore & hygiene [HIGH freedom].env* ignored; no secrets in README, comments, test fixtures.plan-secrets-audit.md, then end the turn with a standalone recap in chat: the two or three highest-impact findings (type + location + last 4, never the value) and the first phase to approve. The file is the deliverable — write it before the recap.plan-rls-audit..env"plan-rls-audit; generic OWASP → plan-security-auditplan-secrets-audit.md# Secrets & Key-Scope Audit — <repo>
_Audit-only. No key is rotated, moved, or scrubbed until each phase is approved._
## Scope
- Scanned: working tree ☐ git history ☐ deploy env (Vercel/AWS) ☐
- Assumptions / not inspected: …
## Verdict
| Severity | Count | Worst case |
|----------|-------|-----------|
| Critical | n | never-client secret exposed / in history |
| High | n | committed .env values, public-prefix leak |
| Medium | n | shared-env keys, hygiene |
## Findings
| # | Key type | Location | Scope bucket | In history? | Action | Sev |
|---|----------|----------|--------------|-------------|--------|-----|
| S1 | Supabase service_role | lib/admin.ts:4 | never-client | YES | ROTATE now | Crit |
| S2 | Stripe secret sk_ | api/pay.ts:2 | never-client | YES | ROTATE now | Crit |
| S3 | Supabase anon | client.ts:6 | safe-client | n/a | OK if RLS holds → plan-rls-audit | — |
| S4 | DB URL | .env.example | never-client | YES | ROTATE + remove from example | High |
## Phased burndown
- **Phase 1 — Rotate exposed never-client secrets** → dashboard rotation + Vercel/AWS env update (grace window)
- **Phase 2 — Relocate clean secrets** → move to env store, fix NEXT_PUBLIC_ leaks
- **Phase 3 — Hygiene** → .gitignore, remove committed examples, CI secret scanner
- **Phase 4 — (optional) Scrub history** → filter-repo/BFG, after rotation
## Execution handoff
Approve a phase to run it. Cross-hand safe-client keys to `plan-rls-audit`.
Add a pre-commit secret scanner (`create-hook`) so this can't regress.
plan-rls-audit for anon-key safety.create-hook — pre-commit secret-scanning hook as regression guard.audit-security.Plan at high effort. Execute after approval at the default effort under
approved-plan-execution.mdc(no reward hacking, no feature deletion). Rotation is irreversible-ish — the plan says which keys; the rule constrains how and in what order.