Your Firebase app throws:
FirebaseError: Missing or insufficient permissions.
What it means
Your Firestore or Storage security rules rejected the request. The client reached Firebase, and the rules said no. It is not a network problem.
Common causes
- The user is not signed in, so
request.authis null and your rule requires auth. - The rule checks an owner field that does not match the signed-in user's id.
- The query asks for more than the rule allows. Firestore rules are not filters, so a query that could return documents the user may not read fails as a whole.
- Test-mode rules expired. Projects started in test mode get a time-limited open rule, and when it ends, every request fails.
- The rules were deployed to a different project than the one your app uses.
How to fix it
- Sign the user in first and confirm
auth.currentUseris set before the call. - Write rules that tie access to the owner:
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;
}
}
}
- Make the query match the rule, for example filter by the user's own id.
- Use the Rules Playground in the Firebase console to test a read and a write as a specific user.
The fix to avoid
Do not "fix" it with allow read, write: if true;. That makes your whole database readable and writable by anyone on the internet. It is one of the most common ways AI-built apps leak user data.
Check it from the outside
After you deploy, try the same read in a private window with no login. It should fail for private data.
Same steps with the FAQ: https://proofforge.live/errors/firebase-missing-or-insufficient-permissions . To see whether your live Firebase rules are open, run the free outside check at https://proofforge.live
Top comments (0)