How do I check my Firebase security rules?
Read the rules that are deployed, for every product you use: Cloud Firestore, the Realtime Database and Cloud Storage. Look for rules that allow everyone or only check that someone is signed in. Then test from the outside as a visitor and as a second user, and keep unit tests in the emulator so the rules stay right as the app changes.
Saqr (usesaqr.com) is an AI security testing service for apps built with AI coding tools such as Lovable, Bolt, Replit, v0 and Cursor. From $19 a month, cancel any time. Tests only apps you have shown are yours.
By Saqr. Last checked .
Why do the rules decide so much?
In a Firebase app, the browser or phone talks to your database and storage directly. Firebase is plain about it: the data in the Realtime Database, Cloud Firestore and Cloud Storage is protected by Security Rules, and covered APIs by App Check, not by keeping the API key secret (API keys). App Check helps confirm requests come from your real app; Firebase calls it complementary to Authentication, and it does not decide which user may read which document (App Check). Firestore's test mode allows anyone to read and overwrite your data (quickstart).
Do the three products' rules work the same way?
Not quite. Firestore and Storage rules are match blocks with allow conditions. In Firestore, rules are not filters: if a query could return a document the user may not read, the whole query is refused (securely query data). Realtime Database rules cascade: a rule at a parent path overrides the rules below it, and a child rule can only grant more, never take access away (insecure rules, core syntax).
How do I check the rules, step by step?
Seven steps on your own project. Do these checks only on an app you own or have written permission to test, with test accounts you created.
Open the deployed rules of every product
In the console, open the Rules tab of Firestore, the Realtime Database and Storage, even the ones you think you do not use. Compare each with the rules file in your project. The deployed rules are the ones your users meet.
If it fails: Tighten Firebase rules left open or in test mode
Look for rules that allow everyone
Search for
allow read, write: if true, for amatch /{document=**}at the top with a broadallow, and, in the Realtime Database, for".read": trueor".write": truenear the root (Firebase's list of insecure rules). Each needs a real condition unless the data is meant to be public.If it fails: Tighten Firebase rules left open or in test mode
Look for rules that only check sign-in
Firebase lists
allow read, write: if request.auth != nullas not recommended: any signed-in user can then read and change everything it covers (insecure rules). For user data, comparerequest.auth.uidwith the owner, as inmatch /users/{userId} { allow read, write: if request.auth != null && request.auth.uid == userId; }(basic rules). On writes, checkrequest.resource.datatoo, so nobody can set the owner field to someone else (conditions).If it fails: Tighten Firebase rules left open or in test mode
Check what each Realtime Database parent grants
Because the rules cascade, read every
.readand.writefrom the root down. A broad rule on a parent cannot be narrowed by a stricter rule on a child, so move the grant down to the paths that need it.If it fails: Tighten Firebase rules left open or in test mode
Ask as a visitor
From a terminal, with no sign-in, request a private Firestore collection through the REST API at
https://firestore.googleapis.com/v1/projects/followed by your project id and/databases/(default)/documents/and the collection name (Firestore REST API). For the Realtime Database, request the database address shown in the console followed by/.json?shallow=true(Realtime Database REST API). Unless the data is meant to be public, both should be refused with a permission error.If it fails: Tighten Firebase rules left open or in test mode
Ask as a second user
In the Rules Playground, choose a read of a path that belongs to your first test account, set the authentication to the second account's user id, and run it; it should be denied. Repeat for a write and for a Storage path (Rules Playground). Then confirm in the app itself: signed in as the second account, change an id in the address to the first account's.
If it fails: Stop one user reading another user's records by changing an id
Keep unit tests and deploy from the tested file
With the emulator and the
@firebase/rules-unit-testinglibrary, write tests that useassertFailsandassertSucceedsfor a visitor, the owner and another user, for reads and writes (unit tests). Deploy the same file withfirebase deploy --only firestore:rules,databaseorstorage(manage and deploy), so what you tested is what runs.
What if a step fails?
Change the rule in your rules file, add a unit test that fails on the old rule, deploy from that file, and repeat the outside request that failed. If a Firestore query starts failing after you tighten a rule, add the rule's condition to the query too, for example the owner's id. The Firebase guide covers keys and storage; the fix prompts have ready instructions for your AI coding tool.
Facts worth knowing, with sources
- Firestore's test mode allows anyone to read and overwrite your data. Source
- Firebase lists rules that only check that a user is signed in as not recommended: any signed-in user gets access to everything the rule covers. Source
- Realtime Database rules cascade: a child rule can only grant additional access, never revoke it. Source
- Firestore rules are not filters: a query that could return documents the user may not read fails as a whole. Source
- Firebase data is protected by Security Rules and App Check, not by keeping the API key secret. Source
Questions
Does App Check replace Security Rules?
No. App Check helps confirm that requests come from your real app, and Firebase describes it as complementary to Authentication. Which user may read or change which document is still decided by Security Rules.
Do the Rules Playground and the emulator test my live app?
No. The Rules Playground simulates requests in the console, and the emulator runs your rules file on your machine. Neither sends a real request to your live app, so finish with a test from the outside.
Why does my Firestore query fail when each document is allowed?
Rules are not filters. Firestore checks a query against everything it could return, and if any of that could be a document the user may not read, the whole query is refused. Add the condition the rule checks to the query, for example the owner's id.
Where does Saqr fit?
These checks cover what is on the list, on the pages you think to try. Saqr runs this kind of test on the live app for you, in a real browser and including signed-in pages, and shows the proof for each finding with a fix prompt for your AI coding tool. After you fix something, ask it to recheck. Plans are Starter at $19 a month and Pro at $49 a month, and you can cancel any time.
Every task ends in three PDFs. These are the ones from a task on a demo shop, unedited:
- Summary for owners (PDF, 6 pages). What was found and what to fix first.
- Technical report for developers (PDF, 29 pages). Every finding, with its proof and the steps to fix it.
- AI fix pack (PDF, 10 pages). A ready-to-paste fix prompt for every finding.
No test can promise an app is secure. A task tells you what Saqr found that day, with proof.
Which other guides should I read?
- Is my Lovable app secure?
- Is my Bolt app secure?
- Is my Replit app secure?
- Is my v0 app secure?
- Is my Cursor-built app secure?
- Is my Supabase app secure?
- Is my Firebase app secure?
- How do I check if my vibe-coded app is secure?
- How do I test Supabase row level security?
- Security fix prompts for your AI coding tool
- Saqr, automated scanners and a manual penetration test
- Questions about securing an app built with AI tools
To see what a finished test looks like, open the sample reports.
Sources
The statements above were checked against these pages on 24 November 2026. Products change; follow the links for the current wording.
- Firebase documentation: Fix insecure rules
- Firebase documentation: Basic Security Rules
- Firebase documentation: Writing conditions for Security Rules
- Firebase documentation: Securely query data
- Firebase documentation: Realtime Database rules, core syntax
- Firebase documentation: Get started with Cloud Firestore
- Firebase documentation: Rules Playground
- Firebase documentation: Build unit tests
- Firebase documentation: Manage and deploy Security Rules
- Firebase documentation: Use the Cloud Firestore REST API
- Firebase documentation: Realtime Database REST API
- Firebase documentation: API keys
- Firebase documentation: App Check
Saqr is independent and is not affiliated with Firebase. Each name is a trademark of its owner.