Check whether your app is giving away its keys

AI builders put keys wherever the code needs them, and browser code is public by definition. Anyone who opens your site can read it. This takes thirty seconds to check and it is the first thing I look at in any rescue.

The thirty-second check

Open your live site, press F12, open the Sources or Debugger tab, and search all files for the beginnings of key strings: sk_, service_role, AIza, xoxb, and the word secret.

How to checkAnything that matches and is not clearly a public key is exposed to every visitor.
What to changeDo not close the tab and hope. Go to the next step.

Searching your repository is not enough. Keys also arrive through build-time variables that were given a public prefix by mistake.

Which keys are safe in the browser and which are not

Publishable and anonymous keys are designed to be public and are protected by access rules on the server side. Secret keys, service keys and admin tokens are not, and they let the holder do anything your app can do.

How to checkIf the name contains secret, service, admin or private, it must never reach the browser.
What to changeMove that work to a server route. The browser asks your server; your server uses the secret.

A public database key with no access rules is just as dangerous as a secret one. See the row level security page.

What to do, in this order, if a key was exposed

Rotating first and cleaning later is the right order. The old key stays valid until you revoke it, and anyone who copied it is already holding it.

How to checkAsk how long the site has been live with this key. That is your exposure window.
What to changeRevoke and reissue the key in the provider dashboard. Put the new one only where the browser cannot see it. Then check the provider's usage logs for anything you did not do.

For payment and email providers, also check for charges, refunds and messages you did not send.

Keeping it from coming back

The next generated feature will do the same thing again unless the boundary is explicit.

How to checkGrep your source for the public prefix and make sure every variable carrying it is genuinely meant to be public.
What to changeKeep secrets out of the client folder entirely, and read them only inside server routes. Add a check to your build that fails when a secret-looking string appears in the bundle.

Committing a .env file to a public repository has the same effect as shipping it in the browser.

Not one of these five?

Send me the link and the exact error text. I will tell you what is broken and what it would take to fix, in writing, within 24 hours. That part is free, and you are not obliged to hire me afterwards.

If you do want it fixed: emergency rescue starts at $600, and I name one fixed number before I start.

Send me the link