Firebase Realtime Database insecure rules: how to fix them
Short answer
A Realtime Database whose rules say ".read": true or ".write": true can be read or changed by anyone who knows its URL, no login needed. Set both to false at the root, then open only the paths your app needs for signed-in users. Deploy the rules and test them in the simulator.
Why you got this
Test mode in the Realtime Database writes open rules for a limited time, and many projects never replace them. Even after the date passes, a rule such as ".read": "auth != null" still lets every account, including a freshly created one, download the entire tree.
The database URL looks like your-project-default-rtdb.firebaseio.com and appears in the Firebase config of every web page. Anyone can add .json to a path and read it in a browser. There is no hacking involved, which is why bots check for it constantly.
What to do now
In the Firebase console open Realtime Database, then Rules. Look at the root. Any ".read": true or ".write": true on the root or on a broad node means the data is open.
Open your own database URL with .json added at the end in a private window. If you see data instead of "Permission denied", it is public right now.
Replace the root rules with false and publish, then re-test your app. You can restore narrow access afterwards, which is better than leaving the door open while you think.
Look at Usage for unusual downloads or writes, and check for junk nodes someone may have added. Back up the data before you clean anything.
How to fix it properly
This example denies everything by default and gives each signed-in user access to only their own branch. Replace users with the nodes your app really has.
{
"rules": {
".read": false,
".write": false,
"users": {
"$uid": {
".read": "auth != null && auth.uid === $uid",
".write": "auth != null && auth.uid === $uid"
}
}
}
}Rules cascade: if a parent grants access, a child cannot take it back. Keep the root closed and grant access as deep in the tree as you can. Add .validate rules for the shape and size of what users may write.
Keep the file in version control and deploy it from the command line.
firebase deploy --only databaseHow to check it is fixed
Repeat the .json request in a private window; it should answer "Permission denied". In the console, the Rules Playground lets you simulate reads and writes as a signed-in or signed-out user.
The verified ScanAnt scan checks, on sites you have proved you own, whether the database root or paths found in your code answer a plain read request from anyone. It saves only the fact of access, never the values. A pass means the paths it could find are closed, not that every rule is correct.
Questions
Is Realtime Database or Firestore safer?
Neither is safe by default if the rules are open. Both are only as safe as the rules you publish, so review them whichever you use.
Why does auth != null not protect me?
Because anyone can create an account and become authenticated. It proves someone signed in, not that they may see a particular record.
Can I hide the database URL?
No, and you should not try. It is public by design. Rules are the control.
Do I need to rotate any key?
The web config values are not secrets. Rotate keys only if a service account or Admin SDK credential was exposed.
Related checks
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 →