Firestore and Realtime Database rules decide who can read and write your data. AI app builders often leave the starter rule that allows everything. Here is how to find and fix that.
The rule to look for
allow read, write: if true;
Enter fullscreen mode
Exit fullscreen mode
That lets anyone on the internet read and write the collection. Test-mode rules that expire are another trap: when they expire, the app breaks, and people paste in the open rule to make it work.
A safer pattern
Require sign-in and check ownership:
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; } } }
Enter fullscreen mode
Exit fullscreen mode
Each user can only reach their own documents. Add narrower rules for shared data.
How to test
Use the Firebase Emulator and the Rules Playground. Test three cases: signed out, owner, and an unrelated signed-in user.…