Firebase config in an APK: what's public and what protects data

Updated

Decompile almost any Firebase app and you will find its API key, project ID and app ID in plain text, copied from google-services.json into the app's resources. People find this, panic, and ask whether they have leaked something.

Usually, no. Firebase's documentation says API keys for Firebase services "are not used to control access to backend resources", and that keys restricted to Firebase services "do not need to be treated as secrets". The real risk is somewhere else, and it is worth ten minutes to check.

Why is the key public in the first place?

Your app needs it to talk to Firebase, and anything your app has, anyone with the APK has. That is true of every client app. See how to check your APK for leaked keys for the keys where being public is a problem.

What actually protects your data?

In Firebase's words: "Security of your Realtime Database, Cloud Firestore, and Cloud Storage data is enforced using Firebase Security Rules, and protection of covered APIs is by Firebase App Check — not by keeping your Firebase API key secret."

  • Security Rules decide who may read or write each path or document. They are the lock.
  • App Check helps covered Firebase services accept requests only from your genuine app, which stops scripts that simply copied your config.

Are your Security Rules open?

The rules to look for are the ones that allow everything:

allow read, write: if true;

Firebase's warning next to that line is: "NEVER use this ruleset in production; it allows anyone to overwrite your entire database." Its explanation of why: without authentication and rules, "anyone who guesses your project ID can steal, modify, or delete the data." Your project ID is in your APK, so nobody has to guess.

Test-mode rules, which allow everything until a date, are the same thing with a timer. Replace them before launch.

What should the rules say instead?

Tie access to the signed-in user. Firebase's example of owner-only access for Firestore:

allow read, delete: if request.auth.uid == resource.data.author_uid;

And for data that everyone may read but only its author may write:

allow read: if true;
allow write: if request.auth.uid == request.resource.data.author_uid;

At minimum, nothing should be writable by a request with no request.auth. Check Cloud Storage rules as well as the database: uploads are where open rules cost money.

Is your key restricted to Firebase?

Firebase restricts the keys it creates for you to Firebase-related APIs. Two things undo that:

  • Adding other APIs to the same key. Firebase warns: "never include the Gemini Developer API in the allowlist for a publicly accessible API key or a key used for other services."
  • Reusing it for Google Cloud APIs. For any Google Cloud API that is not a Firebase service, Firebase "strongly recommends" separate, restricted keys.

If your app calls Gemini directly with a key, that key "should never be included in your code or configuration files." Put the call behind a server that holds the key.

A quick check before launch

  • Rules: no if true on writes, no test-mode expiry, auth checks on every path.
  • App Check: turned on for the Firebase services you use.
  • Keys: the key in the app is restricted to Firebase services and nothing else.

This is part of the Google Play pre-launch checklist. Google does not review your Firebase rules, so nobody else will check them for you.

Sources

Next steps

Still need testers? Get 12 testers for your closed test through a free test-for-test exchange - you test another developer's app, they test yours, and every opt-in is verified.

Common questions

Is it safe that my Firebase API key is in my Android app?
Yes, if the key is restricted to Firebase services. Firebase says such keys are not used to control access to backend resources and do not need to be treated as secrets.
What actually protects my Firestore data?
Firebase Security Rules decide who can read and write each document, and App Check limits covered APIs to your genuine app. The API key protects nothing.
Can I use the same key for Gemini or other Google APIs?
No. Firebase says the Gemini Developer API key should never be in your code, and recommends separate, restricted keys for any Google Cloud API that is not a Firebase service.

Apps currently in closed testing

Real developers running the test described above. Test one, and get testers for your own app back.

Closed testing

In Between is a free card game. Join the group, opt in, install, open it and play a hand. Keep it 14 days. Not available in South Korea. I test your app back the same day.

Games

Available in all countries

Open to testers · 14-day test

Closed testing

# BAYAA — Closed Testing: Instructions for Testers Thank you for participating in the BAYAA (بياع) closed testing program. BAYAA is a Mauritanian marketplace designed to connect customers with shops, restaurants, pharmacies, hotels, and service providers. ## 1. What testers are expected to do - Install BAYAA through the official Google Play closed-testing link. - Keep the app installed throughout the 14-day testing period. - Open and use the app regularly during the testing period. - Create an account and test registration and login. - Browse available shops, products, and services. - Test search and navigation. - Test merchant features if you have a merchant account. - Check WhatsApp contact options where available. - Report bugs, errors, confusing screens, and suggestions. ## 2. What feedback should you provide? Please tell us: - What worked correctly? - What did not work? - Were any pages slow or difficult to use? - Did you experience crashes or unexpected errors? - What features would you like us to improve? Honest feedback is very important. You do not need to give positive feedback if you encounter a problem. ## 3. Important testing rules - Use the app with your own tester account. - Do not share your login credentials. - Do not enter real payment or sensitive personal information. - Do not make fake purchases or transactions. - Do not uninstall the app during the testing period unless instructed. - Keep your Google Play testing enrollment active. ## 4. Reporting problems Send your feedback and screenshots of errors to the BAYAA development team. Thank you for helping us improve BAYAA and prepare it for its official launch in Mauritania. **BAYAA — بياع | Supporting Mauritanian Businesses**

Shopping

Available in all countries

Open to testers · 14-day test

Closed testing

PocketLedger helps you know your money and own your month — without handing your financial life to anyone. Everything stays on your phone. There is no account to create, no bank login, no SMS reading and no internet access at all. PocketLedger works fully offline. TRACK EVERY RUPEE (OR DOLLAR, EURO, POUND) • Add income and expenses in seconds, with category, account, date, merchant and notes • Mark refunds so they reduce your spending instead of counting as income • Search by merchant or note, filter by type, and tap any category to see its transactions for the month • INR, USD, EUR and GBP supported — amounts in different currencies are never mixed or converted SEE YOUR MONTH AT A GLANCE • Net cash flow, total income and total expenses for any month • Spending by category with an interactive chart • Recent transactions and account balances on one screen BUDGETS THAT KEEP YOU HONEST • Set a monthly limit for any category • See what you have spent, what is left, and when you go over ALL YOUR ACCOUNTS • Cash, bank accounts, UPI, credit cards and wallets • Pick from popular banks (SBI, HDFC, ICICI, Axis, Kotak and many more) and UPI apps, or type any name • Live balance for every account NOTHING IS EVER LOST • Every transaction keeps a full version history: see exactly what changed, when • Deleted transactions can be restored • An activity log records every add, edit, delete and setting change PRIVATE BY DESIGN • No sign-up, no ads, no tracking, no analytics • No internet permission — your data physically cannot leave the app • Not backed up to the cloud PocketLedger is a personal budgeting and expense-tracking tool. It does not offer loans, payments, banking or investment services and does not connect to any bank. Made by Technopreneurs Technolabs.

Finance

Available in all countries

Open to testers · 14-day test

May we use analytics and ad measurement? Analytics (Vercel, and Ahrefs on our public pages) count page views without cookies. Ad measurement lets Google's tag on our public pages see which visits came from our Google ads, using a Google cookie. The site works the same either way. Cookie Policy · How Google uses data ·