guest@electrichead:~$ get keys

static: the bots found a way to make you pay for their homework. cap your keys.

The API key lockdown

checklist 2026-11-21

AI agents are out there hunting for API keys people left in public code, then using them to pay for their own work. If your key's exposed, it's your bill. Three moves shut that down.

1. Keep keys out of code and repos

Do this once per project
  1. Put every key in a .env file or your host's secret settings. Never paste one into the code.
  2. Add .env to .gitignore before your first commit, not after.
  3. Turn on secret scanning and push protection in your git host's settings, so a key gets blocked before it's public.
  4. Check what's already there with the command below. Anything it finds goes straight to step 3.
.gitignore
.env
.env.*
!.env.example
Look for keys already in the repo and its history
git grep -nIiE 'api[_-]?key|secret[_-]?key|sk-[a-z0-9_-]{20,}' $(git rev-list --all) -- . ':!*.example' | head -50

2. Cap and alert on spend at the provider

In each AI provider's billing settings
  1. Set a hard monthly spend limit. A cap stops the damage; an alert only tells you about it.
  2. Add budget alerts at 50% and 90% of that limit, sent somewhere you'll actually see.
  3. Use one key per app or project, so you can see which one's burning and kill only that.
  4. Give each key the smallest scope and model access the provider allows.

3. Rotate anything that's leaked, then check usage logs

If a key was ever public, even for a minute
  1. Revoke it at the provider. Deleting it from the repo isn't enough: it's still in the history and in every copy.
  2. Make a new key and put it in your .env file or secret store, never in the code.
  3. Redeploy everything that used the old key.
  4. Check the provider's usage logs for calls you didn't make, and the billing page for spikes.
  5. Spotted charges you didn't make? Contact the provider's support with the dates.
Download the checklist

Didn't download? Tap ⋯, then Open in browser.

Source: AWS Security Blog

guest@electrichead:~$ next

Want the next one?

You're in.

Unsubscribe any time. From Electric Head Productions.

More at electrichead.ai
Follow @electrichead.ai