Skip to content
ScanAnt

What are Firebase Security Rules?

Firebase Security Rules are the server-side rules that decide who can read or write data in Cloud Firestore, Realtime Database and Cloud Storage. Your web app's Firebase config is public by design, so these rules are the only protection for your data.

How it works

The Firebase client talks to the database directly from the browser, so there is no server of yours in between to check permissions. Every request is evaluated against your rules, which can use the signed-in user's ID and the data itself. Test mode writes a rule that allows everyone until a date, then quietly expires or, worse, is extended and forgotten. A rule such as "any signed-in user" is also too broad, since anyone can create an account.

// Too open: anyone can read and write
match /{document=**} { allow read, write: if true; }

// Owner only
match /users/{uid}/notes/{id} {
  allow read, write: if request.auth != null
                     && request.auth.uid == uid;
}

How to tell if your site is affected

  • Your rules contain if true, or a time-limited rule from test mode such as request.time < timestamp.date(...).
  • Rules check only request.auth != null, so every signed-up user can read everyone's data.
  • Realtime Database rules set .read or .write to true at the root.
  • Storage rules allow public listing or let any user upload to any path.
  • The Firebase console has shown a warning that your rules are not secure.

How to fix it

  1. Start from deny-all and add only the access each collection needs.

  2. Scope access to the owner: compare request.auth.uid with the owner field or with a path segment.

  3. Validate written data in the rules: allowed fields, types and sizes, and block clients from setting fields such as role or admin.

  4. For Storage, restrict by path and owner and limit file size and content type.

  5. Use the Firebase Emulator and the Rules Playground to write tests for allowed and denied cases, and use App Check to limit who can call your project.

How ScanAnt checks for it

Quick scanVerified scanDeep scanCode scan

The free quick scan detects the Firebase config in your page and labels it as normal. For verified owners, the verified scan tries a plain unauthenticated read of the collections and Realtime Database paths it finds and checks whether the Storage bucket can be listed, keeping names and counts only. The deep scan also looks at Remote Config. The code scan flags open or test-mode rules in uploaded rules files.

Questions

Is the Firebase apiKey a secret?

No. The web config identifies your project and is public by design. Protection comes from rules, App Check and authentication.

What is wrong with test mode?

It allows anyone to read and write your whole database for a limited time. Many projects launch with it still on.

Do rules apply to the Admin SDK?

No. Server code using the Admin SDK bypasses rules, so protect those credentials and check permissions in your own code.

Are Firestore and Storage rules separate?

Yes. Each product has its own rules file, and a locked Firestore does not protect an open Storage bucket.

See if your site is affected

Free for any public site, no signup. Need the verified or deep scan? Choose the level on the scan page.

Choose a scan level →