Fix guides

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"

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:

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.

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

After the fix

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

Checks covered: FB-RULES-003, FB-FS-006, FB-RULES-005 · If you think data already leaked