Is your Firebase database still in test mode? How to check for "allow read, write: if true" (and fix it)
LaunchGuard is a weekly report on the live app you shipped from Lovable, Cursor, Bolt, or v0. Its security basics check looks for exposed API keys, open Supabase or Firebase rules, public files and missing headers. The first scan is free (no card, ownership proof required, read-only) and shows your 1–2 most severe findings with a fix prompt. getlaunchguard.app
Everything below you can do yourself in the Firebase console, for free. Only test a project you own.
TL;DR
- When you create a Cloud Firestore database, a Realtime Database or a Cloud Storage bucket in the Firebase console, you pick Locked mode or Test mode. Test mode "allows anyone to read and overwrite your data." (Firebase: Firestore quickstart; Firebase: Basic Security Rules)
- The open rule looks like
allow read, write: if true;(Firestore),".read": true, ".write": true(Realtime Database) orallow read, write;(Storage). Firebase's own comment on it: "NEVER use this ruleset in production; it allows anyone to overwrite your entire database." (Firebase: Avoid insecure rules) - Your Firebase API key and project ID being in the frontend is normal. Firebase says the key only identifies your project and that data is protected "using Firebase Security Rules … not by keeping your Firebase API key secret." So the rules are the lock. (Firebase: API keys)
- Fix: replace the open rule with owner-only rules, test them in the Rules Playground as a signed-out user and as a different user, then publish.
Why this happens in AI-built apps
The Firestore quickstart tells you to "select test mode" to get started with the web SDK. (Firebase: Firestore quickstart) The Storage quickstart says "During development, consider setting up your rules for public access." (Firebase: Get started with Cloud Storage on Web) That is the fastest way to get a prototype working, so it is also what you often end up with after a quick build session.
Firebase's warning is direct: "You might think you're the only person using your app, but if you've deployed it, it's available on the internet. If you're not authenticating users and configuring security rules, then anyone who guesses your project ID can steal, modify, or delete the data." (Firebase: Avoid insecure rules)
Two traps:
- "Signed in" is not "owner". A rule like
allow read, write: if request.auth != null;lets any logged-in user read and write everything. If anyone can sign up, that is close to open. Firebase lists it as "Not recommended." (Firebase: Avoid insecure rules) - Realtime Database rules cascade. A
.read: truehigher up the tree cannot be taken back with.read: falselower down. A child rule "can only grant additional privileges." (Firebase: Avoid insecure rules)
Step 1 — Read the rules that are actually deployed
The Firebase console "always shows the most recently deployed version" of your rules. A local firestore.rules file in your repo may be out of date. (Firebase: Avoid insecure rules)
- Open the Firebase console and select your project.
- Go to Firestore, then the Rules tab. Do the same for Realtime Database and Storage if you use them. (Firebase: Avoid insecure rules; Firebase: Get started with Cloud Firestore Security Rules)
- Look for these patterns:
| You see | What it means |
|---|---|
match /{document=**} { allow read, write: if true; } |
Anyone can read and overwrite every document. (Firebase: Avoid insecure rules) |
An allow read, write with a date check on request.time and no request.auth check |
Open to everyone until that date. Note the date; it is not a security rule, it is a timer. |
".read": true, ".write": true at the top of Realtime Database rules |
Anyone can read and overwrite the whole database. (Firebase: Avoid insecure rules) |
allow read, write; on match /{allPaths=**} in Storage |
"every file in your Cloud Storage bucket accessible to any user" and anyone "can overwrite all your files." (Firebase: Avoid insecure rules) |
if request.auth != null with nothing else |
Any signed-in user can access the data. (Firebase: Avoid insecure rules) |
allow read, write: if false; |
Locked. Clients cannot access it; only the Admin SDK and Cloud Functions can. (Firebase: Avoid insecure rules) |
If you created a Realtime Database in test mode and never changed the rules, Firebase emails you and then the rules start denying all requests after a trial period. (Firebase: Realtime Database REST setup) Do not wait for that: an expiry email means the data was open until then.
Step 2 — Test it like a stranger would (your own project only)
In the console (no code): open the Rules editor, click Rules Playground, choose a read, enter a path such as users/some-user-id, set Authentication to unauthenticated, and click Run. Then run it again as an authenticated user with a different user ID. Both should be denied for private data. (Firebase: Quickly validate Firebase Security Rules) Note that the Playground runs against the ruleset in the editor, not the deployed one. (Firebase: Get started with Cloud Firestore Security Rules)
From a terminal, against the live database (signed out):
Firestore REST requests with no token are checked against your Security Rules, the same as your app's users. (Firebase: Use the Cloud Firestore REST API) Replace YOUR_PROJECT_ID and users with your own project ID and a collection name your app uses:
curl "https://firestore.googleapis.com/v1/projects/YOUR_PROJECT_ID/databases/(default)/documents/users"
If you get documents back, a signed-out visitor can read that collection. A PERMISSION_DENIED error means the rules blocked it. (Firebase: Use the Cloud Firestore REST API)
For Realtime Database, any database URL is a REST endpoint when you add .json; shallow=true returns only the top-level keys: (Firebase: Realtime Database REST setup; Firebase: Realtime Database Retrieving Data)
curl "https://YOUR_DATABASE_NAME.firebaseio.com/.json?shallow=true"
Data back means it is publicly readable. An error instead of data means the rules blocked the signed-out read.
Step 3 — Replace the open rule with owner-only rules
A common pattern is one document per user under users/{userId}, and other documents that store the owner's UID in a field. Adapt the paths and field names to your data. These patterns come from Firebase's "content owner only" examples. (Firebase: Avoid insecure rules; Firebase: Security Rules and Firebase Authentication)
Cloud Firestore
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Each user can read and write only their own profile
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
// Documents that store their owner's uid in author_uid
match /posts/{postId} {
allow read, delete: if request.auth != null && request.auth.uid == resource.data.author_uid;
allow create: if request.auth != null && request.auth.uid == request.resource.data.author_uid;
allow update: if request.auth != null
&& request.auth.uid == resource.data.author_uid
&& request.auth.uid == request.resource.data.author_uid;
}
// Everything else stays closed. Access is denied when no rule allows it.
}
}
Access is denied by default when no rule allows it, so you do not need a catch-all deny. (Firebase: Security Rules language) Use rules_version = '2'; as the first line; it is required for collection group queries. (Firebase: Get started with Cloud Firestore Security Rules)
Realtime Database
{
"rules": {
"users": {
"$uid": {
".read": "auth !== null && auth.uid === $uid",
".write": "auth !== null && auth.uid === $uid"
}
}
}
}
Do not put .read or .write at the top level: it would override these child rules. (Firebase: Avoid insecure rules)
Cloud Storage
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
// Files look like: user/<UID>/file.jpg
match /user/{userId}/{fileName} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
}
If some data really is public (for example published posts), allow public read on that path only, and keep write owner-only, as in Firebase's "mixed public and private access" examples. (Firebase: Avoid insecure rules)
Step 4 — Publish, then re-test
- Console: edit the rules, click Publish. (Firebase: Get started with Cloud Firestore Security Rules)
- CLI:
firebase deploy --only firestore:rules,firebase deploy --only databaseorfirebase deploy --only storage. (Firebase: Manage and deploy Firebase Security Rules) - Deploying from the CLI overwrites the rules in the console, so pick one place to edit and stick with it. (Firebase: Get started with Cloud Firestore Security Rules)
- Firestore rule changes can take up to a minute for new queries and up to 10 minutes for active listeners. (Firebase: Get started with Cloud Firestore Security Rules)
Then repeat Step 2: signed out should be denied, another user should be denied, and your own account should still work in the app. For a repeatable check, write tests with the @firebase/rules-unit-testing library and the emulator, using unauthenticatedContext and assertFails. (Firebase: Build unit tests)
Fix prompt for Lovable, Cursor or Bolt
My app uses Firebase. Review my Firebase Security Rules for Firestore,
Realtime Database and Storage (whichever I use).
1. Show me the rules currently in firestore.rules / database.rules.json /
storage.rules and list every rule that allows access with "if true",
no condition, a request.time date check, or only "request.auth != null".
2. List every collection/path the app reads or writes, and which user
should be allowed to access each one.
3. Rewrite the rules so each user can only read and write their own data
(request.auth.uid matches the userId in the path or an owner field).
Allow public read only on paths I confirm are meant to be public.
Start Firestore rules with rules_version = '2';
4. Add rules unit tests with @firebase/rules-unit-testing that assert a
signed-out user and a different signed-in user are denied.
5. Tell me exactly how to deploy (firebase deploy --only firestore:rules
etc.) and how to re-test signed out.
Do not use the Admin SDK in the frontend to work around denied requests.
Show me the plan before you change anything.
FAQ
My Firebase API key is in the frontend. Is that the leak? No. Keys restricted to Firebase services "do not need to be treated as secrets" if your setup follows Firebase's guidance. The protection is your Security Rules (and App Check). A Gemini Developer API key is different: never put it in a publicly accessible key. (Firebase: API keys)
Does App Check replace Security Rules? No. App Check helps protect backends from abuse by checking requests come from your app, and Firebase says it "prevents some, but not all, abuse vectors." Rules still decide which user can read which data. (Firebase: App Check; Firebase: API keys)
My backend uses the Admin SDK. Do rules apply to it? No. Server client libraries and requests with a service-account OAuth token bypass Security Rules and use IAM instead. That is why locked rules (if false) still let Cloud Functions work. (Firebase: Get started with Cloud Firestore Security Rules; Firebase: Use the Cloud Firestore REST API; Firebase: Avoid insecure rules)
Is request.auth != null enough? Only if every signed-in user should see all of that data. Otherwise add an owner check. (Firebase: Avoid insecure rules)
Sources
- Firebase docs — Avoid insecure rules: https://firebase.google.com/docs/rules/insecure-rules
- Firebase docs — Get started with Cloud Firestore Security Rules: https://firebase.google.com/docs/firestore/security/get-started
- Firebase docs — Get started with Firestore Standard edition (quickstart, test mode vs production mode): https://firebase.google.com/docs/firestore/quickstart
- Firebase docs — Basic Security Rules (Locked mode / Test mode): https://firebase.google.com/docs/rules/basics
- Firebase docs — Get started with Cloud Storage on Web: https://firebase.google.com/docs/storage/web/start
- Firebase docs — Quickly validate Firebase Security Rules (Rules Playground): https://firebase.google.com/docs/rules/simulator
- Firebase docs — Use the Cloud Firestore REST API: https://firebase.google.com/docs/firestore/use-rest-api
- Firebase docs — Realtime Database: Installation & Setup for REST API: https://firebase.google.com/docs/database/rest/start
- Firebase docs — Realtime Database: Retrieving Data (REST, shallow): https://firebase.google.com/docs/database/rest/retrieve-data
- Firebase docs — Security Rules and Firebase Authentication: https://firebase.google.com/docs/rules/rules-and-auth
- Firebase docs — Security Rules language: https://firebase.google.com/docs/rules/rules-language
- Firebase docs — Manage and deploy Firebase Security Rules: https://firebase.google.com/docs/rules/manage-deploy
- Firebase docs — Build unit tests: https://firebase.google.com/docs/rules/unit-tests
- Firebase docs — API keys: https://firebase.google.com/docs/projects/api-keys
- Firebase docs — App Check: https://firebase.google.com/docs/app-check
- Related LaunchGuard guide — How to check if your Lovable, Bolt, Cursor or v0 app leaked an API key in the JavaScript: https://getlaunchguard.app/guides/check-api-key-in-frontend-javascript-lovable-bolt-v0
Last checked against the sources above: 25 November 2026.