Skip to content
ShipSafeStack

Checklist

Is the Firebase API key safe to expose?

Short answer. The web config apiKey is not a secret when it is restricted to Firebase APIs. Firebase says it only identifies the project. Firestore, Realtime Database, and Storage are protected by Security Rules and App Check, not by hiding that key. A service account JSON file, and a key for the Gemini Developer API, are secrets and do not belong in the client.

Updated 30 Nov 2026

This is a practical checklist, not a guarantee. It is not a penetration test, a compliance audit, or proof that an app is safe to launch.

This page answers the question with the checks, not with a yes that covers every key in the Google Cloud project. The string in firebaseConfig.apiKey is the public one when the restrictions match what Firebase documents. A service account private key is not. The same question for other client identifiers is Is the Supabase anon key safe to expose? and Is the Sentry DSN safe to expose?. Firebase is the directory entry. How the products differ is Supabase vs Firebase.

Firebase's API key page below was last updated 18 Nov 2026. This page was checked 25 Nov 2026. If a label here disagrees with the console, follow the current page.

What the web config key is

Firebase's API keys page says an API key routes requests to your project. For Firebase services, that key identifies the project or the app. It is not authorization. Authorization is Google Cloud IAM, Firebase Security Rules, and Firebase App Check.

On the web, the value sits in the Firebase config object, in the field named apiKey. Apple apps use API_KEY in GoogleService-Info.plist. Android apps use current_key in google-services.json. The SDK reads that config when it calls a Firebase API. You can also pass the same value through Firebase options or an environment variable. Moving it into NEXT_PUBLIC_ or VITE_ does not make it secret, and it does not make it more secret. Those prefixes are still shipped to the browser. The wider pass is API keys in the frontend.

Firebase says keys restricted to Firebase services do not need to be treated as secrets, and that it is fine to include them in code or in a checked-in config file, when the rest of the setup on that page is in place. An email from Google Cloud about a "publicly accessible Google API key" is not, by itself, proof the Firebase key is the wrong kind. The same page says to confirm three things on APIs & Services, then Credentials:

  • It is the key the Firebase app uses, and only for Firebase services. Auto-created names are usually Browser key (auto created by Firebase), Android key (auto created by Firebase), or iOS key (auto created by Firebase).
  • The API restrictions allowlist includes the Firebase-related APIs that key needs.
  • The allowlist has no other APIs. In particular, it should not include Generative Language API.

Each API key belongs to one Firebase project. You cannot move it to another project. Deleting it in the Cloud console is permanent, and calls that used it fail.

Open rules are open data

The key page says Security Rules decide which end users can reach Realtime Database, Cloud Firestore, and Cloud Storage. App Check decides which apps can call the APIs it covers. Neither of those is "hide the apiKey."

Firebase's own sentence is not to rely only on restricting or obscuring the key. A ruleset of allow read, write: if true, or Test mode that grants access to all users, lets anyone who can reach the project read and write, whether or not they copied the key from your bundle. Worked examples are Firebase Security Rules examples. The Admin SDK does not go through those rules. That is a different credential, below.

If the app uses email-and-password Authentication, Firebase says someone with the API key still cannot read database or Storage data that Security Rules protect. They can call the Authentication endpoints for your project. Firebase says you can lower the default quota on identitytoolkit.googleapis.com toward the traffic you expect. If you set it too low, sign-in fails when traffic jumps, until you raise it. Quotas are in the Google Cloud console.

Restrict the key, and keep other Google APIs on their own keys

Firebase says every API key it auto-provisions is restricted to Firebase-related APIs. New keys have had that allowlist since May 2024. During that month, older unrestricted keys that Firebase had created were restricted to the Firebase list plus APIs the project already had enabled. Keys you created yourself were not changed. Keys that were already restricted were not changed.

Look at APIs & Services, then Credentials. If API restrictions says Don't restrict key, Firebase says that key can call any API enabled on the project. That is the setting to close. Choose Restrict key and keep the allowlist to the Firebase APIs the client actually calls. The official table of which API must be on the list for which product is on the API keys page. Most Firebase APIs do not need to be on it. Removing one the client does need returns API_KEY_SERVICE_BLOCKED or a 403 that says the request is blocked. Test a restriction on a non-production key before you change the key a live app uses.

Other Google APIs do not belong on that allowlist. Firebase says to create a separate key, restricted to that one API, for anything that is not a Firebase product. They name the Places API for Maps and the Gemini Developer API, and they say this matters especially when the API is a billable Google Cloud service. The Gemini key must not be in client code or in a config file. In the console it is called Gemini API Key or Gemini Developer API key (auto created by Firebase), and it is restricted to Generative Language API. Never add Generative Language API to a key that is public or that other services share. A separate key can be rotated without breaking Firebase.

What must not ship to the client

The browser key is not a service account. The Admin SDK authenticates as a service account. Google Cloud's service account key page says the private key is how you mint credentials for that account, and that knowing the private key is like knowing a password. The JSON file you download is that key. It does not go in the repo, in a chat, or in a NEXT_PUBLIC_ or VITE_ variable. Google also says not to embed service account keys in client apps. How generated code keeps doing that is how to keep API keys out of AI-generated code.

If that JSON, or a user-managed service account key, is already public, Google's key rotation page says to rotate it immediately:

1. Create a new key for the same service account. 2. Put the new key only on the server, and point Cloud Functions or the host at it. 3. Disable the old key and confirm the server still works. The Cloud console can show a disabled key. Disabling itself is done with the gcloud CLI or the API, not the console button. Google's disable page says disabling does not revoke short-lived credentials already issued from that key. To cut those off, disable or delete the service account, which also cuts off every workload that uses it. 4. Delete the old key from the service account's Keys tab. Deletion is permanent. Google's create and delete page says to disable first and delete once you know nothing still needs the key.

A Gemini Developer API key in the client is the same class of mistake. Remove it from the bundle, create a replacement that stays on the server, and delete or restrict the exposed one so it cannot call Generative Language API from a browser. The steps are Leaked Gemini API key?.

Checklist for a generated app

Lovable, Bolt, Cursor, and v0 will paste a Firebase config into the client because that is how the web SDK is initialized. Read what else landed next to apiKey.

  • The value in the client is the Firebase web apiKey, not a downloaded service account JSON and not a key named for Gemini.
  • In Google Cloud, APIs & Services, Credentials, that key is Restrict key, not Don't restrict key. The allowlist is Firebase APIs. Generative Language API is not on it.
  • Maps, Places, or Gemini each have their own key. The Gemini key is only on the server.
  • Firestore, Realtime Database, and Storage rules are not if true and not an open Test mode. The examples are Firebase Security Rules examples.
  • If you use email-and-password sign-in, the Identity Toolkit quota matches the traffic you expect.
  • Then run a free passive check on the public URL. It can see a key that shipped in a script. It does not read your Firebase rules or your Cloud project. The worksheets are the checklist pack and the pre-launch checklist.

FAQ

Is the Firebase apiKey in my JavaScript a leak?

Not by itself. Firebase says a key restricted to Firebase services identifies the project and does not authorize access. It is fine in source when Security Rules and App Check are what actually protect the data, and when the key's allowlist has no non-Firebase APIs. An open ruleset is the leak. A service account file next to that config is a different leak.

Google emailed me that my API key is publicly accessible. Do I rotate it?

Check the key they named. Firebase's API key page says a Firebase key can be in client code when it is the browser, Android, or iOS key, its allowlist is only the Firebase APIs it needs, and Generative Language API is not on that list. If the email names a Gemini key, or a key set to Don't restrict key, that key should not stay in the client. Restrict it or replace it with a server-only key. Deleting the Firebase browser key without a replacement makes Firebase calls fail, and deletion cannot be undone.

Does Security Rules still matter if the key is public?

Yes. Firebase says database and Storage access is enforced by Security Rules, and that you should not rely on hiding the key. Anyone who can reach the project can send the request the rules allow. Test mode and allow read, write: if true are open. The Admin SDK bypasses those rules, which is why its key stays on the server.

Where do I see the allowlist?

Google Cloud console, APIs & Services, Credentials, then the key. Firebase also lists the key in the web app's config under Project settings, General. The allowlist of required Firebase APIs is the table on Firebase's API keys page. If a call returns API_KEY_SERVICE_BLOCKED, the API you called is missing from that list, or you are using the Firebase key for a non-Firebase API that needs its own key.

Sources

Checked 25 Nov 2026.

Informational only. This page describes checks and vendor documentation. It is not a security audit, a penetration test, or a certification, and it is not a guarantee.

Newsletter

A short weekly note on new tools and security checklists. No spam, unsubscribe anytime.