Home / Guides / Google API keys and Gemini: lock them down now

Google API keys and Gemini: lock them down now

Google AIza keys used for Maps or Firebase can start working for Gemini. How to restrict every key in about 10 minutes, and when to rotate.

What changed

For years Google said keys that start with AIza (Maps, Firebase and so on) were fine to put in your website. Then Gemini started accepting the same keys. When someone enables the Gemini (Generative Language) API on a Google Cloud project, existing keys in that project can quietly start working for Gemini. You get "no warning", "no confirmation dialog" and "no email notification" (Truffle Security).

Researchers found about 2,800 public keys that could access Gemini, including some of Google's own (Malwarebytes). With such a key, an attacker can access files you uploaded to Gemini and run up your AI bill (Truffle Security).

Google's current rules

What to do (about 10 minutes)

  1. Open Google Cloud Console → APIs & Services → Credentials for each project.
  2. For each key, set API restrictions so only the APIs it needs (Maps, Firebase and so on) are allowed, and make sure Generative Language API is not on the list (Google Cloud blog).
  3. Add Application restrictions (your website's domain) where you can.
  4. If you use Gemini, create a separate key, keep it in a server-side secret (an Edge Function or API route) and never in a VITE_ or NEXT_PUBLIC_ variable.
  5. If a key with Gemini access was ever in your public code, rotate it. Start with your oldest keys (Truffle Security).

Scan your app free

ShipLatch checks your live site for leaked keys, public env values, source maps and exposed files. The $29 Fix Pack gives you fix prompts written for your app and re-scans that prove each fix worked.

Scan free at shiplatch.com → See the Fix Pack · $9 playbook

Want the whole pre-launch process in one place? Get App Security for Vibe Coders, our $9 PDF playbook.

More guides