Your Firestore rules may let anyone read everything.
Updated 2026-10-14 · Plain English, written for founders who built with Lovable, Bolt, Cursor or similar.
A Firebase web app ships its firebaseConfig to every browser: the API key, the project id, the storage bucket. That is normal. What protects your data is Firestore security rules. If those rules say allow read, write: if true, anyone who knows your project id can read, change and delete every document, with no login.
The usual way this happens is test mode. When you create a database in test mode, Firebase writes rules like these:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.time < timestamp.date(2026, 11, 13);
}
}
}
Until that date, the whole database is open to everyone. When the date passes, the condition becomes false and every request from your app is refused, including your real users'. The app breaks, and the quick "fix" is to push the date forward or change the line to if true. Both leave the database open.
Check from the outside
This is what a stranger does. Open your live app, open DevTools, and search the loaded JavaScript for projectId. Pick a collection name your app uses (search for collection() and ask for one document, without logging in:
curl "https://firestore.googleapis.com/v1/projects/YOUR-PROJECT-ID/databases/(default)/documents/users?pageSize=1"
200with adocumentsarray: anyone on the internet can read this collection. Treat it as a leak.200with{}: the rules let anonymous visitors list this collection; it just has nothing in it right now. Fix it before it does.403withPERMISSION_DENIED: the rules refuse anonymous reads here. Good.
Repeat for each collection that holds personal data. Rules are per path, so one closed collection says nothing about the next one.
Only do this against your own project.
Check the rules file
Open firestore.rules in your repo, or Firestore Database > Rules in the Firebase console (the console shows what is actually deployed). Look for any of these:
allow read, write: if true;orallow read, write;with no condition: open to everyone.if request.time < timestamp.date(...): test mode. Open to everyone until that date.match /{document=**}with a loose condition: that one rule covers every collection in the database.if request.auth != nullon user data: any signed-in account can read every user's documents.
Rules only add access. If any rule that matches a path allows the request, it is allowed, so one broad rule near the top overrides careful rules below it.
Fix it
Replace the catch-all with rules that tie each document to its owner. This example has a users collection keyed by the Firebase Auth uid, and an orders collection with an ownerId field:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read, create, update, delete: if request.auth != null
&& request.auth.uid == userId;
}
match /orders/{orderId} {
allow read, delete: if request.auth != null
&& resource.data.ownerId == request.auth.uid;
allow create: if request.auth != null
&& request.resource.data.ownerId == request.auth.uid;
allow update: if request.auth != null
&& resource.data.ownerId == request.auth.uid
&& request.resource.data.ownerId == resource.data.ownerId;
}
}
}
Deploy with firebase deploy --only firestore:rules, or paste into the Rules tab and publish.
- Anything not matched is denied. Delete the
match /{document=**}block entirely; do not just tighten its date. resource.datais the document as stored;request.resource.datais what the write would store. Checking both on update stops a user from handing their order to someone else, or taking someone else's.- Rules are not filters. A query has to ask only for documents the rules allow, for example
where("ownerId", "==", user.uid). A query that could return other users' documents is refused as a whole. - Your server is unaffected. The Admin SDK ignores security rules, so backend code and Cloud Functions keep working while you lock down the client.
Realtime Database too
If your project also uses the Realtime Database, it has its own rules in database.rules.json. Open looks like ".read": true, ".write": true at the top, or a time check like "now < 1700000000000" from test mode. Access granted at a parent path cannot be taken back further down, so fix it at the root:
{
"rules": {
"users": {
"$uid": {
".read": "auth != null && auth.uid === $uid",
".write": "auth != null && auth.uid === $uid"
}
}
}
}
What SecureIndie checks
- On your live site: an anonymous, read-only request for one document in up to five collections your site's own code names. No fields are requested and document ids are not kept.
- In your repo, when you connect it:
firestore.rulesanddatabase.rules.json, including test-mode dates that have not passed yet. A rules file can differ from what is deployed, so these findings say they were read from code.
After the fix
- Re-run the curl from above. It should now return
403. - Sign in as one test user and try to read a second test user's document. Use the Rules Playground in the console to try it without writing code.
- If the database held personal data while it was open, read what to do if data leaked. You usually cannot tell who read it, so plan as if someone did.
Check your app
SecureIndie looks for this mistake. The free quick check covers the basics from outside (exposed files, keys in your site's code, headers) in about a minute. Database rules, payment webhooks and AI endpoints need the full audit, which also reads your code and proves what a visitor can actually reach.
Questions
Is the apiKey in my firebaseConfig a secret?
No. It identifies your project and ships in every Firebase web app. Security rules, not the key, decide what a visitor can read or write.
My test-mode rules expired and the app broke. Should I just extend the date?
No. Extending the date keeps the database open to everyone for longer. Write rules that check request.auth.uid, then the app works for signed-in users and stays closed to strangers.
Is request.auth != null enough?
Only for data every user is meant to see. Anyone can create an account in most apps, so "signed in" is not "allowed". Compare request.auth.uid with the owner of the document.
Related guides
- Anyone may be able to list and download your Firebase files.
- Supabase RLS is off. Anyone can read that table.
Checks covered: FB-RULES-003, FB-FS-006, FB-RULES-005 · If you think data already leaked