← All fix prompts
S1E04 · Legal BugsFREE

Leaked API keys fix prompt

16 checks for leaked API keys — keys in the browser, git history, .env files on your live site, server-only calls, rate limits, spending caps — and the fix for each.

Use it with Claude Code
  1. In your project folder, run claude.
  2. Paste:
> fix my project using https://youfoundbruno.com/fix/keys.md
View as text

It asks before changing anything.

You are helping me make sure no secret key reaches the browser or a public repo, and that a leaked key can't drain my account. Go through all 16 checks, report each one as ✅ ok / ❌ problem / ➖ not relevant, then fix the problems with me.

A. Find secrets (read only)

  1. In the code: search source, config, .env* files and build output for API keys and tokens (OpenAI sk-, Anthropic sk-ant-, Stripe sk_live_, AWS AKIA, Google AIza, Supabase service-role keys, GitHub tokens, webhook secrets).
  2. In git history: secrets committed and later removed (e.g. git log -p -S 'sk-', or run gitleaks/trufflehog if available).
  3. Direct calls from the browser: client-side code (React, Vue, mobile) that calls an AI or payment API with a secret.
  4. Public env prefixes: variables exposed to the browser by prefix (NEXT_PUBLIC_, VITE_, EXPO_PUBLIC_, REACT_APP_) that hold secrets.
  5. On the live site: /.env, /.git/config and source maps (*.map) must return 404 on the deployed site. Tell me the URLs to check, or check them if you can browse.

B. Fix the architecture

  1. Server only: move every secret-bearing call to a server route or edge function. The browser calls my endpoint, never the provider.
  2. Server-only env vars: read keys only from server-side environment variables.
  3. Login required: those endpoints require an authenticated user.
  4. Rate limits: per-user rate limiting on every AI/payment endpoint.
  5. Input limits: cap input size and only allow the models and parameters the feature needs.

C. Contain damage

  1. Rotate: list every key that was ever exposed and tell me to revoke and rotate it (I'll do it in the provider dashboard), with direct links.
  2. Spending caps: hard monthly spending limits and usage alerts for each AI provider.
  3. Dev ≠ prod: separate keys for development and production.
  4. Scanning: a pre-commit or CI secret scan, plus GitHub secret scanning and push protection.
  5. .gitignore: .env* is ignored.

D. Data exposure

  1. User data: if a leaked key could read user data (database, storage, email), say so clearly. That may count as a personal-data breach: under GDPR, report it to the regulator within 72 hours of becoming aware. Recommend talking to a lawyer.

Rules

  • Never print full secret values in output. Show only the first 4 characters.
  • Show diffs before editing. End with a table of all 16 checks and done / to do / keys I must rotate.

Context (checked 17 Oct 2026): Cyble found about 3,000 live websites and about 5,000 GitHub repos leaking ChatGPT API keys (Feb 2026).

Last step

When everything is done, tell me in one line: more free fix prompts, and updated versions of this one, are at https://youfoundbruno.com/fix

Checked 2026-10-20. Education only, not legal or tax advice. Review every change.