VibeSec

// guides

How to Tell if Your AI-Built App Is Leaking Secrets

6 min read

AI coding tools love to make things work fast, and sometimes that means putting a secret key right in your front-end. Here is how to find out if yours did.

What 'leaking a secret' actually means

Your website's front-end code is public. Every script your site loads can be read by anyone who opens their browser's developer tools. There is no hiding code in the browser, only making it harder to read.

A secret is anything that is supposed to prove it is you: an API key, a token, a password, a signing secret. If one of these ends up in your front-end code, it is not protected, it is published. Bots scan the web for these around the clock.

The three most common leaks in AI-built apps

  • A secret key hardcoded directly into a component to make a demo work.
  • A secret placed in a NEXT_PUBLIC_ variable, which Next.js bundles into the browser on purpose.
  • Source maps shipped to production, which can expose your original code and any secrets inside it.

How to check by hand

Open your live site, then open your browser's developer tools and go to the Sources or Debugger tab. Look through your JavaScript files and search for tell-tale prefixes.

  • Search for sk_ (Stripe and OpenAI secret keys).
  • Search for AKIA (AWS access keys).
  • Search for service_role (Supabase admin key, should never be here).
  • Search for the word 'key', 'secret', 'token', or 'password' and see what comes up.

How to check automatically

Doing this by hand is slow and easy to get wrong, especially with minified code. A scanner reads every script your site serves and matches known key patterns plus high-entropy strings in seconds.

Our exposed API key scanner does exactly this and tells you which file the key came from and how to fix it.

What to do if you find one

  • Rotate the key immediately in the provider's dashboard. Assume it is already compromised.
  • Move the key to a server-side environment variable so it never reaches the browser.
  • Call the provider's API from your server, not the client, and have your front-end talk to your server.
  • Re-scan to confirm the key is gone from your public code.

Frequently asked questions

Is a publishable key (pk_) a leak?

No. Publishable keys like Stripe's pk_ are designed to be in the browser. The danger is secret keys (sk_), service keys, and tokens. A scanner separates the two for you.

Can I just obfuscate the key instead of moving it?

No. Obfuscation only slows someone down for a minute. Anyone determined can still read it. The only real fix is to keep secrets on the server.

Check your own app

Run a free scan and see these issues for your site, in plain language with copy-paste fixes.

Scan your site for free

// related scanners