Skip to main content

Your Firebase or Google Maps key is in your frontend. Can it also call Gemini? A 10-minute check

Google said AIza keys aren't secrets, then Gemini changed that. What Google fixed in 2026, how to check your key's restrictions, and how to split Firebase, Maps and Gemini keys.

Updated 7 min readMarkdown

For more than a decade, Google told developers that the AIza... keys used by Firebase and Google Maps are not secrets. Firebase's own docs still say its API keys are "public by design." That's why every Firebase Studio, Lovable, Bolt or hand-built app that uses Firebase or a Maps embed ships one of these keys in its public JavaScript.

The catch arrived with Gemini. If the same Google Cloud project also has the Gemini API enabled, a key that was only ever meant to identify your Firebase app can end up able to call Gemini on your bill. Here's what happened, what Google changed in 2026, and a 10-minute check you can run on your own project today.

What researchers found

On February 25, 2026, Truffle Security published "Google API Keys Weren't Secrets. But then Gemini Changed the Rules." Their point was simple. Google Cloud uses one key format, AIza..., for two different jobs: public identification (Maps, Firebase) and real authentication (Gemini). When someone enables the Gemini API, also called the Generative Language API, on a project, existing unrestricted keys in that project can start working against Gemini endpoints too. There's no warning and no email.

Truffle says it scanned millions of websites and found nearly 3,000 Google API keys, originally deployed for public services like Maps, that also authenticated to Gemini. With such a key, they wrote, an attacker could reach uploaded files and cached content through the Gemini API, burn your quota, and run up usage charges.

The common path in an AI-built app looks like this:

  1. You create a Firebase project. Firebase puts a browser key in your config, and that config ships in your bundle.
  2. Months later you add an AI feature. You or your coding agent enable the Gemini API in the same Google Cloud project and reach for the key you already have.
  3. The public key now does two jobs, and one of them costs money.

What Google changed in 2026

According to Truffle's follow-up (June 29, 2026) and Google's current AI Studio docs:

  • May 7, 2026: the Gemini API started blocking unrestricted keys that had been dormant for a long time. In AI Studio they show a "Blocked" tag.
  • May 28, 2026: every new key created in Google AI Studio is an authorization key. It's bound to a service account, restricted to the Gemini API by default, and comes with fast leaked-key enforcement.
  • From June 2026: the Gemini API rejects requests from unrestricted standard keys. Standard keys with explicit restrictions still work.
  • Truffle also reported that Google planned to drop standard keys for Gemini entirely by September 2026.

That closes the worst version of the problem going forward. It doesn't tell you what your key could do before the change, or whether someone has restricted a public key to Gemini along the way. Both are worth checking.

The 10-minute check

Do this only on projects and keys you own.

1. Find the keys your live site ships. Open your published app, open DevTools, press Ctrl+Shift+F (Cmd+Option+F on Mac) in the Sources panel and search for AIza. Note every distinct key. A Firebase web config and a Maps embed often use different keys.

2. Check whether Gemini is enabled in that project. In the Google Cloud console, go to APIs & Services > Enabled APIs & services for the project each key belongs to. If Generative Language API isn't in the list, keys in that project can't reach Gemini. Truffle gives this as the first step too.

3. Read each key's restrictions. Go to APIs & Services > Credentials and open each key you found. Firebase's docs say a public Firebase key is safe in code only if:

  • it's the key your app uses for Firebase, usually named Browser key (auto created by Firebase)
  • its API restrictions list includes the Firebase APIs it needs
  • that list includes nothing else, and "in particular, the list should not have Generative Language API"

A key marked Don't restrict key (unrestricted) is the one to fix first.

4. Confirm from the outside. For a key that should be Firebase-only or Maps-only, a Gemini request should fail:

curl -s "https://generativelanguage.googleapis.com/v1beta/models?key=YOUR_PUBLIC_KEY" | head -c 400

You want an error, such as a permission or "API key not valid for this service" message. If you get back a list of models, that public key is a working Gemini credential.

5. Look at usage. Check the Usage page in Google AI Studio and your Cloud billing reports for Gemini traffic you don't recognize. One limit to know: Google's docs say the Gemini Developer API gives aggregate project and key usage metrics, not per-request audit logs with caller IP addresses. So you can see that a key was used, but not who used it.

The fix

Split the keys. Firebase's guidance is direct: use Firebase-provisioned keys only for Firebase services. If your app also uses Maps or Gemini, use a separate key for each, restricted to that API. "Never include the Gemini Developer API in the allowlist for a publicly accessible API key or a key used for other services."

Lock down the public keys. For each public key, set API restrictions to only the APIs that key needs (Method B in Google's AI Studio docs). For a Maps key, also add website (HTTP referrer) restrictions for your domains. Truffle calls referrer restrictions "bypassable," so treat them as a speed bump, not a lock.

Move Gemini to the server. Create a new Gemini key in AI Studio (it will be an authorization key), store it as a server-side environment variable, and call Gemini from a route handler, server function or edge function. Don't put it in a NEXT_PUBLIC_, VITE_ or EXPO_PUBLIC_ variable: those are compiled into the browser bundle. If you want Gemini calls from the client in a Firebase app, Firebase AI Logic with App Check is the documented route. In that setup the Gemini key is a separate key restricted to the Generative Language API, and Firebase says it should never be in your code or config files.

Rotate if Gemini was ever reachable. Google's leak checklist runs in this order: create the replacement, deploy it, disable the old key once the new one works, then audit usage. Deleting first takes your app down.

Cap the damage. Set a budget alert in Cloud Billing, and set quotas on the APIs your public keys can call.

A prompt for your coding agent

If you built with Cursor, Claude Code, Lovable or Bolt, this keeps the agent from undoing the fix later:

Our Firebase web config key is public by design and must only be used for Firebase APIs. Never use it for Gemini or Maps. Gemini calls must go through a server-side function that reads GEMINI_API_KEY from a server environment variable. Never put an AI provider key in a NEXT_PUBLIC_, VITE_ or EXPO_PUBLIC_ variable or in client code.

What an outside scan can and can't see

An outside-in scan sees only what your published site hands a stranger: the keys in your bundle, source maps, exposed files and headers. It can't see your Cloud console restrictions or which APIs a project has enabled, so steps 2 and 3 above still matter. ProofForge's notes on a leaked Gemini key cover the first 10 minutes after a leak: https://proofforge.live/leaked-keys/gemini. For a read-only check of what your live URL exposes: https://proofforge.live

Sources, checked December 1, 2026:

  • Truffle Security, "Google API Keys Weren't Secrets. But then Gemini Changed the Rules." (Feb 25, 2026), trufflesecurity.com/blog/google-api-keys-werent-secrets-but-then-gemini-changed-the-rules
  • Truffle Security, "Google Fixes the Gemini API Key Privilege Escalation Issue" (June 29, 2026), trufflesecurity.com/blog/google-fixes-the-gemini-api-key-privilege-escalation-issue
  • Google AI Studio docs, "Using Gemini API keys," aistudio.google.com/docs/api-key
  • Firebase docs, "Learn about using and managing API keys for Firebase," firebase.google.com/docs/projects/api-keys

No comments yet. Be the first to comment.