Firebase rules "if true": how to find open Firestore and Storage rules and fix them
Firebase and Firebase Studio apps often ship with Firestore or Realtime Database rules that let anyone read and write. It happens because the quick-start rules work, so nobody changes them. The rule to look for In Fires
Firebase and Firebase Studio apps often ship with Firestore or Realtime Database rules that let anyone read and write. It happens because the quick-start rules work, so nobody changes them.
The rule to look for
In Firestore, allow read, write: if true; means any visitor can read and write that collection. In Realtime Database, ".read": true and ".write": true at the root do the same. Test mode rules that expire still leave a window open.
How to check from outside
Your Firebase config is in your frontend and is public by design. The rules are what protect the data. Open the Rules tab in the console and read them. Then use the Rules Playground, simulating an unauthenticated read of each collection.
The fix: tie access to the signed-in user
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
match /posts/{postId} {
allow read: if true;
allow create: if request.auth != null;
allow update, delete: if request.auth != null
&& request.auth.uid == resource.data.ownerId;
}
}
}
Store ownerId on every document and check it in the rule. Public read on a collection is fine only when the data is meant to be public.
Storage rules too
Cloud Storage has its own rules. allow read, write: if true on a bucket exposes uploads.
Test
Run the Playground as signed out, as the owner and as another user. Both the signed-out and other-user cases must fail for private data.
ProofForge's free scan looks for exposed Firebase signals in your public app without logging in. Free first look: https://proofforge.live/check/firebase-studio
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.