Day 5 of 24

Search your app bundle and git history for secret keys

A key deleted from the code can still sit in an old commit that anyone with access can read.

What goes wrong

Treat any secret that ever reached your browser code or your git history as public. AI tools often paste API keys straight into the code to make a feature work. Next.js copies every variable that starts with NEXT_PUBLIC_ into the JavaScript sent to the browser, and Vite does the same with VITE_. Git keeps every old version of every file, so a key removed today is still in the history.

How to check

  1. List every key the app uses: payments, email, AI providers, database.
  2. Ask your developer which ones carry a public prefix, and why.
  3. Open your live site, view the loaded scripts and search for the start of each secret key.
  4. Ask your developer to run a secret scanner over the full git history.

How to fix

Move secrets into server-only environment variables. Treat any key that ever reached git or the browser as public: create a new one, deploy, then revoke the old one.

What good looks like: No secret key appears in the loaded scripts, the scanner finds none in the history, and every key that leaked has been replaced.

Source: Next.js: Environment variables

What we saw in an audit

In one audit, a local environment file had been committed to git history, and the keys in it had not yet been rotated.

Sample report based on a real audit. Client details and figures changed.

Rather have someone run this check for you?

Get the whole app checked
Search your app bundle and git history for secret keys