Guide

How to check if your AI-built app is leaking API keys

AI app builders are brilliant at one thing: getting a working app in front of you fast. But "fast" and "make it work" often means an API key gets pasted somewhere it should never live — your app's frontend, where anyone can read it. If you've built with Lovable, Bolt, Replit or v0, there's a real chance a key is sitting in your code right now, in plain sight. Here's how keys leak, which ones actually hurt, and how to check yours.

Where API keys leak in AI-built apps

An API key is a password for a service — OpenAI, Stripe, your database. The golden rule is simple: secret keys belong on a server, never in the browser. The moment a key lands in your frontend code, it gets bundled into the JavaScript your app ships to every visitor. Anyone can open their browser's developer tools and read it.

The most common leaks are all variations of the same mistake:

Your frontend secret API key Anyone, in DevTools Your account your bill · your data

The keys that actually cost you money

Not all leaked keys are equal. Some are meant to be public (like a Supabase anon key or a Google Maps key). Others hand a stranger your wallet or your database. Ranked by how much they hurt:

Money

AI provider keys

OpenAI (sk-…), Anthropic (sk-ant-…), OpenRouter (sk-or-…) and friends. The single most common leak in AI-built apps — the app talks to an AI, and the key ends up in the browser. Whoever finds it runs your model on your dime until the bill (or your credits) is gone.

Money

Payment keys

A Stripe secret key (sk_live_…) exposed in the frontend can be used to create charges, refunds or read customer data. Rare, but catastrophic when it happens.

Data

Database & backend keys

A Supabase service_role key or open Firebase rules give full read/write access to your users' data. We break this one down in detail in Exposed Supabase keys: anon vs service_role.

Good to know

Some keys are supposed to be public and are safe in the browser — a Supabase anon key (with database rules on), a Google Maps AIza… key, a Stripe publishable key. The danger is the secret ones. Telling them apart is the whole game.

Why it happens more with AI-built apps

When you ask an AI to "connect this to OpenAI" or "add payments," it writes code that works — and the quickest working version often puts the key right in the frontend. The AI isn't trying to expose you; it's optimizing for "it runs." And if you're not a developer, there's no obvious sign that a key which works in the preview is also visible to the whole internet.

How to check if your keys are exposed

A rough manual check you can do right now:

The honest catch

Real bundles are minified and split across many files, keys are easy to miss, and it's genuinely hard to tell a harmless public key from a dangerous secret one by eye. It's the kind of check that's easy to get wrong — and "I looked and didn't see anything" is not the same as "it's safe."

Not sure if your app is leaking a key?

Paste your app's URL and our free scan checks it in about 10 seconds — across your database, AI provider and payment keys.

Scan your app free →

What to do if you find one

// DANGER — secret key shipped to the browser const openai = new OpenAI({ apiKey: "sk-…" }) // visible to every visitor // SAFE — key stays on your server, frontend calls your API // server route / edge function: const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY })