Is Your Website Leaking API Keys? How to Check in 10 Minutes

AI app builders make it possible to launch a website in a weekend. They also make one mistake very easy: putting a secret key inside the code that every visitor downloads. Bots look for these keys all day, and a stolen AI key can be used on your bill.

You do not need to be a programmer to check. Here is how.

What counts as a leak?

Is Your Website Leaking API Keys? How to Check in 10 Minutes

Not every key in a page is a problem. Some are meant to be public.

Kind of key Public in the browser?
Stripe publishable key (pk_…) Yes, by design
Supabase anon key Yes, if row level security is on
Firebase web config Usually yes, if rules are set
Stripe secret key (sk_…) Never
OpenAI or Anthropic key Never
Supabase service role key Never
AWS secret access key Never

Check by hand

  1. Open your site in Chrome on a computer.
  2. Press F12 (or Cmd + Option + I on a Mac) to open developer tools.
  3. Open the Network tab and reload the page.
  4. Press Ctrl + F (Cmd + F) in that tab. This searches inside the files the page loaded.
  5. Search for sk-, sk_live, service_role, AKIA and SECRET.

If you find something, look at what is around it. The letters sk- can also be part of an ordinary word, so only a long random value counts.

Then try these addresses on your own domain: /.env, /.env.local and /.git/config. All of them should show a “not found” page.

Check automatically

Going through every file takes patience, because modern sites split their code into dozens of pieces. A scanner does it in one go. The free API key checker from Hostwares reads the page, its scripts and any public source maps, the same files any visitor’s browser can download, and does not use a key if it finds one. Only scan websites that belong to you or that you have permission to test.

Found a key? Follow this order

  1. Revoke it in the provider’s dashboard. This comes first. Removing it from the page does not help, because copies may already exist.
  2. Create a new one.
  3. Move it to the server. The browser should call your own server, and your server calls the AI provider.
  4. Publish the site again and repeat the check.
  5. Look at the usage page for calls you do not recognise, and set a spending limit.

Why it happens so often

Build tools such as Vite and Next.js copy some variables into the public files on purpose. Anything that starts with VITE_ or NEXT_PUBLIC_ is visible to everyone. When an AI builder adds a chatbot quickly, it sometimes puts the key behind exactly such a name.

A good habit: before every launch, search your own site for the word “key”. It takes a minute, and it is much cheaper than a surprise bill.

Written by the Hostwares team.

Leave a Comment