How to check your Firebase security rules before launch
Firebase apps talk to the database straight from the browser, so your Security Rules are the only thing standing between your data and the internet. Rules left in test mode or set to allow everything are one of the most common launch mistakes.
Red flags to look for
Open firestore.rules, storage.rules or database.rules.json (or the Rules tab in the Firebase console) and look for:
// Firestore / Storage: anyone can read and write
allow read, write: if true;
allow read, write;
// "Test mode": open to everyone until a date
allow read, write: if request.time < timestamp.date(2026, 11, 1);
// Realtime Database
{ "rules": { ".read": true, ".write": true } }
Test mode rules are open to everyone until the date passes, then they block everything. Both are wrong for a live app.
How to check, step by step
- In the Firebase console, open Firestore Database → Rules (and Storage → Rules, Realtime Database → Rules if you use them).
- Read every
allowline. Each one should checkrequest.authand, for personal data, that the user owns the document. - Use the Rules Playground on the Rules tab to simulate an unauthenticated read of a private document. It should be denied.
- For a full test, run your rules in the Firebase Local Emulator Suite before deploying.
A safe starting point
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId}/{document=**} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
}
Anything not matched by an allow rule is denied, so add rules only for the collections your app needs.
Copy-paste prompt for your AI coding tool
Paste this into Cursor, Claude, Lovable, Bolt or whichever AI built your app:
Review my Firebase Security Rules (Firestore, Storage and Realtime Database). Remove any rule that allows reads or writes without authentication, including test-mode date rules. Rewrite them so every collection requires request.auth and users can only read and write their own documents, with validation on the fields they write. Explain each rule in plain English and show me how to test it with the Rules Playground and the Firebase emulator.
Check your repo in about a minute
Paste a public GitHub repo into KeySnare for a free grade and your top 3 issues, each with a copy-paste AI fix prompt.
Run a free scan →FAQ
Is the Firebase web config (apiKey) a secret?
No. The Firebase web config is meant to be included in your app. Security comes from your Security Rules and, optionally, App Check.
What is Firebase test mode?
A starter rule that allows all reads and writes until a set date. It is meant for development only and must be replaced before launch.
How do I test my rules?
Use the Rules Playground in the Firebase console for quick checks and the Firebase Local Emulator Suite for automated tests.
Does a KeySnare scan see rules changed in the console?
No. KeySnare only scans rules files committed to your repo.