Skip to content
ScanAnt

Your Cloud Firestore database has insecure rules: what to do

Short answer

Firebase sends this email when your Firestore rules let anyone on the internet read or write your data, usually because the project was left in test mode. Replace the open rules with ones that check request.auth, deploy them and the warning is gone. It takes about ten minutes, and it is worth doing today.

Why you got this

When you create a Firestore database in test mode, Firebase writes a rule such as allow read, write: if request.time < timestamp.date(2026, 1, 1) or simply allow read, write: if true. Anyone who knows your project ID, which ships in every web page that uses Firebase, can query the whole database without signing in. Firebase scans for this and emails the project owners.

AI app builders make it worse because they often generate the rules for a quick demo and nobody comes back to them. A rule that says if request.auth != null looks safer but still lets any signed-in user, including anyone who just registered, read everyone else's documents.

What to do now

  1. Open the Firebase console, go to Firestore Database and then Rules, and read what is published right now. If you see if true or a date check, your data is open.

  2. Check the Usage tab for unexpected read or write spikes. A sudden jump you cannot explain means someone may already have been through the data.

  3. Paste the stricter rules below, press Publish, and make sure your own app still works. Fix any screen that breaks by adding a narrow rule for it, never by reopening everything.

  4. If the collections held personal data such as e-mails, orders or messages, work out what you would have to tell your users and in which country. Write down the date the rules were open.

How to fix it properly

Start from "deny everything" and open only what each collection needs. This example lets a signed-in user read and write only their own profile document, and denies the rest.

firestore.rules
rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /users/{userId} {
      allow read, write: if request.auth != null && request.auth.uid == userId;
    }
    // everything else is closed
    match /{document=**} {
      allow read, write: if false;
    }
  }
}

Rules apply per document, not per field. If a document mixes public and private fields, split it into two documents or two collections. Validate what users write too, for example with request.resource.data checks, so nobody can give themselves an admin flag.

Keep the rules in your repository and deploy them from the command line so the published version always matches the code.

bash
firebase deploy --only firestore:rules

How to check it is fixed

In the Rules tab, use the Rules Playground to simulate an unauthenticated read of one of your collections. It should be denied. Then simulate a read as a signed-in user on someone else's document, which should also be denied.

For an outside check, the free ScanAnt scan reads your public page and finds your Firebase project settings. The verified scan, which runs only on sites you have proved you own, then tests whether the collections found in your bundle can be read without signing in, and saves names and counts, never documents. It cannot tell you your rules are perfect, only that the open doors it knows about are shut.

Questions

Is the Firebase config in my web app a leak?

No. The apiKey, project ID and app ID in a Firebase web config are public by design. Security comes from your rules, not from hiding that config.

How long do I have after the email?

The email gives no hard deadline, but the data is exposed for as long as the rules stay open. Treat it as an incident for today, not for next sprint.

Will tightening rules break my app?

It may break screens that relied on open access. That is the point: add a narrow rule for each legitimate access and test with the Rules Playground before publishing.

Does the Admin SDK obey these rules?

No. The Admin SDK on your server bypasses security rules, so keep its credentials out of client code and out of git.

Do I need to tell users about the exposure?

If personal data was readable and you cannot rule out access, many jurisdictions require notification. Check the rules that apply to you or ask a lawyer.

Check your site after the fix

The quick scan is free for any public site and needs no signup. Checks that touch your database or files run only after you prove you own the site.

Choose a scan level →