Is the Google API key (AIza...) in your frontend safe? Firebase, Maps and Gemini keys explained
By Abbi Labs · Last updated 29 November 2026
Scan your app free and see which keys your site is handing out.
Abbi Labs reads the same JavaScript every visitor downloads and flags Google (AIza), OpenAI, Anthropic, Stripe, AWS, GitHub and Supabase secret keys, masked. It also checks Supabase tables readable with your public key, exposed .env and .git files, security headers, CORS, cookie flags and TLS. Read-only. No sign-up for the quick check.
No app handy?
Example result · our deliberately broken demo app
6 issues found: 3 critical, 1 high, 1 medium, 1 low
- Critical: Stripe live secret key in public JavaScript
- Critical: /.env file readable by anyone
- High: Git repository exposed (/.git/HEAD)
The demo's problems are planted on purpose. Paste your own URL above to see yours.
No sign-up. Read-only public-resource and protocol metadata checks. No model prompts or tool execution. Scan only sites you own or are allowed to test.
Run on every deploy or use from Cursor / Claude Code via MCP →
Weekly AI-app security checklist
One short email a week: a practical check for apps built with Supabase, Next.js and AI tools (RLS, leaked keys, headers and more). Unsubscribe anytime.
You search your built JavaScript, find a string starting with AIza, and panic. Sometimes that's fine. Sometimes it's a bill waiting to happen. The trouble is that every Google API key uses the same format, so the string alone doesn't tell you which one you've got. What matters is which APIs the key is allowed to call.
Facts below are from Firebase's Learn about and manage API keys for Firebase, Google's Using Gemini API keys and the Google Maps Platform security guidance.
The three keys that look the same
- Firebase web config key (the
apiKeyinfirebaseConfig). Public by design. Firebase says it only identifies your project and app. Your data is protected by Security Rules and App Check, not by keeping this key hidden. Firebase-provisioned keys are automatically restricted to Firebase-related APIs, and the console usually names them "Browser key (auto created by Firebase)". - Maps JavaScript key. Has to be in the browser to load the map, so it's public too. Anyone can copy it from your page, so it needs a website restriction and API restrictions or it can be used elsewhere on your bill.
- Gemini API key. A secret. Google says to treat it like a password and never ship it in web or mobile client code, because keys in client code can be extracted and used to spend your quota. In the console it's called "Gemini API Key" or "Gemini Developer API key (auto created by Firebase)" and is restricted to the Generative Language API.
The dangerous case is a key that's public and can call Gemini. Firebase's docs are blunt about it: never include the Gemini Developer API in the allowlist of a publicly accessible key or a key used for other services.
How this ends up in AI-built apps
- "Add an AI feature." The quickest working answer is calling Gemini straight from the React component with the key in
VITE_GEMINI_API_KEYorNEXT_PUBLIC_GEMINI_API_KEY. Those prefixes put the value into the bundle every visitor downloads. - One key for everything. The Firebase key is already in the config, so the agent reuses it for Gemini or Places and adds those APIs to its allowlist. Now your public key can call paid APIs.
- An old unrestricted key. A key made years ago for one thing, with "API restrictions: Don't restrict key", works for every API enabled on the project, including ones you enable later.
Check yours in 3 minutes
- Find it. Open your live site, DevTools, Sources (or view-source), and search all files (Ctrl/Cmd + Shift + F) for
AIza. Note where each one appears. Is it infirebaseConfig, next to a Maps loader, or next togenerativelanguage.googleapis.com,@google/genaiorGoogleGenerativeAI? - Match it in the console. Google Cloud console, APIs & Services, Credentials. Click the key whose value matches. Look at two things: Application restrictions (None, Websites, IP addresses, Android, iOS) and API restrictions (Don't restrict key, or a list of APIs).
- Read the API list. A browser key should list only what that page needs. If you see
Generative Language APIon a key that's in your frontend, that's the problem. If it says "Don't restrict key", fix that too. - Optional quick test on your own key. This asks Gemini to list models using the key and nothing else:
A JSON list of models means the key can call Gemini. An error saying the API is blocked, not enabled, or the request is denied means it can't. Only run this against keys you own.curl "https://generativelanguage.googleapis.com/v1beta/models?key=YOUR_AIZA_KEY"
The fix, per key
Firebase web key
Keep it in your code. In Credentials, make sure its API restrictions list only the Firebase-related APIs your app uses and nothing else, and that Generative Language API isn't on it. Then do the part that actually protects your data: Firebase Security Rules on Realtime Database, Firestore and Storage that deny by default, plus App Check for the products that support it. If your Realtime Database is open to the world, the key doesn't matter. See our Realtime Database guide.
Maps key
Google's advice is one type of application restriction plus one or more API restrictions on every key. For a website, set Application restrictions to Websites and add your domains (for example https://yoursite.com/*). Under API restrictions, allow only the Maps APIs your pages call. Use a separate key per app, delete keys you don't use, and set a quota and budget alert, since a referrer is a header a script can fake. Short version in our tip: is the Maps key in your frontend locked to your domain?
Gemini key (or any key that can call Gemini)
Get it out of the browser. Move the Gemini call to a server route, server action or edge function that checks the user is signed in, and keep the key in a server-only environment variable (no VITE_ or NEXT_PUBLIC_ prefix). Then follow Google's leak checklist:
- Create a new key in Google AI Studio or the Cloud console.
- Deploy your app with the new key on the server side.
- Disable the old key in the Cloud console once the new one works. Google suggests not deleting it until the new key is fully live, to avoid downtime.
- Check billing and API usage in the Cloud console for traffic you don't recognise.
Two Gemini changes from Google's docs worth knowing: since 28 May 2026, new keys made in AI Studio are created as authorization keys bound to a service account, and the Gemini API now rejects requests from unrestricted standard keys. So if your Gemini calls started failing, restricting the key (or creating a new one) is the fix. Don't fix it by widening a public key.
If the key was ever committed to git, it's still in the history even after you delete the line. Rotating is what makes it useless. More on that in AI API key exposed in your frontend.
Paste this into your AI builder
Audit how this app uses Google API keys (strings starting with AIza).
1. List every place a Google API key is read or hard-coded, and which
Google API each one calls (Firebase, Maps, Gemini/Generative
Language, Places, other).
2. Any Gemini call must happen on the server (API route, server action
or edge function) that checks the user is signed in. Read the key
from a server-only env var with no VITE_ or NEXT_PUBLIC_ prefix.
3. Don't reuse the Firebase config apiKey for any non-Firebase API.
4. Show me the final list: file, key env var name, API, client or server.Then fix the restrictions yourself in the Cloud console. Your AI builder can't see them.
What Abbi Labs checks
Honest scope: the free quick check downloads your home page and the JavaScript files it loads from your domain and flags any Google API key (AIza) it finds, showing only a masked prefix and suffix. A key that appears in a file with Gemini code is flagged as a likely exposed Gemini key with higher severity. It can't log in to your Google Cloud console, so it can't see whether a key is restricted, and it can't see keys that never reach the browser. To tell which kind of key you've got, paste it into the free Is this key safe in the frontend? tool. The key never leaves the page.
FAQ
Is my Firebase apiKey a secret?
No. Firebase says its API keys only identify your project and app, and that access to your data is controlled by Firebase Security Rules and App Check, not by hiding the key. It's safe in your code as long as the key is restricted to Firebase-related APIs and isn't also allowed to call other APIs, especially the Generative Language (Gemini) API.
Is it OK to put a Gemini API key in a VITE_ or NEXT_PUBLIC_ variable?
No. Google's Gemini docs say to treat the key like a password and never put it in web or mobile client code, because anyone can pull it out and spend your quota. Call Gemini from a server route or edge function and keep the key there.
Can I just use my Firebase key for Gemini too?
Firebase says not to. Use your Firebase-provisioned keys only for Firebase-related APIs, use a separate key for anything else, and never add the Gemini Developer API to the allowlist of a public key.
Google emailed me about a publicly accessible API key. Is that a leak?
If the key in the email is your Firebase web key, Firebase's docs say it's fine as long as it's the key used only for Firebase, it allows the Firebase APIs your app needs, and nothing else is in its API restrictions list (in particular not Generative Language API). If it's any other key, treat it as leaked.
Will HTTP referrer restrictions stop all misuse of a Maps key?
They stop other websites from using your key in a browser, but a referrer is just a header a script can set. Google recommends one application restriction plus API restrictions on every key, and a quota and budget alert are worth adding too.
Does Abbi Labs check for this?
Partly. The free quick check (no sign-up) reads your home page and the JavaScript files it loads and flags any AIza key it finds, masked. If that key sits in a file with Gemini code, it's flagged as a likely Gemini key, which is more serious. It can't see your Google Cloud console, so it can't tell whether the key is restricted. Paste a key into the free Is this key safe? tool to see which kind it looks like.