SHIPSAFE guides / Guide

Developer guide

Firebase and Supabase keys: which are safe in client code and which are not

Some keys are meant to be public and some give full access. Mixing them up is one of the most common ways a backend gets exposed.

By Ilyas A. Almadani · Updated October 22, 2026 · Steps checked against the vendors' official documentation, linked at the end

The short version
  1. Firebase API keys identify your project. They are not a password, and can ship in your app.
  2. A Gemini Developer API key is secret, even inside a Firebase project.
  3. Supabase: the publishable (anon) key is public, the secret (service_role) key never is.
  4. Your data is protected by Security Rules or Row Level Security, not by hiding the key.

Firebase

Firebase's documentation states that API keys for Firebase services are not secret in the way server keys are. They identify your Firebase project and app, and it is safe to include them in code or configuration files. The details matter:

  • Keys identify, not authorise. Access control comes from Firebase Security Rules, IAM and App Check, not from the key.
  • Restrict every key. Keys that Firebase creates for browser, Android and iOS apps are limited to Firebase-related APIs by default. Check in the Google Cloud console that the restrictions are still there, because keys can be edited.
  • Do not reuse a Firebase key for other Google APIs. Use separate, restricted keys for non-Firebase APIs such as Maps or Places.
  • Gemini Developer API keys are secret. Firebase says not to put them in code or config files and not to add the Gemini Developer API to the allowlist of a publicly accessible key.
  • Do not rely on obscurity. Firebase says not to rely only on restricting or hiding your keys.

What actually protects Firebase data

  • Security Rules protect Realtime Database, Cloud Firestore and Cloud Storage. Test mode rules that allow everything must not reach production.
  • App Check helps ensure requests come from your genuine app.
  • Service account JSON files are secrets. Never commit or ship them.

The GoogleService-Info.plist file in an iOS project and google-services.json on Android contain this public configuration. They are not passwords, but they identify your project, so check your rules and key restrictions.

Supabase

Supabase now uses two key types, with older JWT-style keys kept for compatibility:

  • Publishable key (sb_publishable_...): low privilege, meant for public code such as web pages, mobile apps and CLIs. The older equivalent is the anon key.
  • Secret key (sb_secret_...): elevated privilege, for backend code only: servers, APIs with their own authorisation, and Edge Functions. The older equivalent is the service_role key.

The important detail: secret keys use the service_role role, which has the BYPASSRLS attribute, so they skip every Row Level Security policy. A leaked secret key means full read and write access to your tables.

Row Level Security is required

Supabase tells you to enable Row Level Security on every table before you deploy. The publishable key maps to the anon or authenticated roles, and your policies should target those roles. A table without RLS, reachable with the public key, is open to everyone who has it.

If a Supabase secret or service_role key leaked

  1. Create a new secret key.
  2. Replace the compromised key in every component and confirm each one uses the new key.
  3. Delete the leaked secret key. Supabase says deletion is irreversible, so do it after the replacement works. For legacy keys, deactivate them instead, which can be reversed.
  4. Check your database and logs for access you did not expect.

Supabase also says a secret key used from a browser is rejected, but still tells you to delete any leaked key immediately, because other tools can use it. Note that creating new keys does not revoke the legacy anon and service_role keys. They keep working until you disable them under Settings, then API Keys.

What a scanner can tell you

SHIPSAFE can flag a committed GoogleService-Info.plist as an informational finding and remind you to review rules and key restrictions, and it detects Google API key formats and other credentials in project files. It cannot tell whether a Supabase key is the publishable or secret one, or whether your Row Level Security policies are correct, so treat a finding as a prompt to check, not a verdict. Mac App Store page.

Quick reference

KeyIn client code?
Firebase API key for Firebase services (restricted)Yes, with rules and restrictions in place
Gemini Developer API keyNo
Firebase service account JSONNo
Supabase publishable or anon keyYes, with RLS enabled
Supabase secret or service_role keyNo, server only

For other providers, see hard-coded API keys in an iOS app and the pre-release checklist.

Frequently asked questions

Is it safe to commit my Firebase config file?

The values identify your project and are not passwords, and Firebase says keys for Firebase services can be in your code or config files. Safety depends on your Security Rules and API key restrictions, and whether to commit the file is a team policy decision.

What is the difference between the Supabase anon key and the service_role key?

The anon key (now the publishable key) is for client code and respects Row Level Security. The service_role key (now the secret key) bypasses Row Level Security and must only be used on a server.

Can I put a Gemini API key in my Firebase app?

No. Firebase's documentation says a Gemini Developer API key is secret and must not be placed in code or configuration shipped with your app. Call it from a server.

Official documentation used for this guide

Vendor interfaces change. If a menu looks different, follow the linked documentation.

More guides

See all SHIPSAFE guides

Check your project before the next release

SHIPSAFE scans a project folder on your Mac for leaked keys and risky release settings, and shows the file, the line and a suggested fix for each finding. It runs 100% locally, with no upload and no account. It is a review assistant, not a guarantee of security.

SHIPSAFE findings list showing the file, line and evidence for each issue