critical · M3 · MASVS-AUTH-2 · PTKD-BACKEND-FIREBASE-OPEN-RULES
Firebase security rules open to everyone
Firestore, Realtime Database or Storage rules let anyone (or any signed-in user) read or write all data. The Firebase config in your app is enough to use them.
How it is exploited
The project was created in Firestore test mode: `allow read, write: if request.time < timestamp.date(2026, 12, 1);`. Until that date anyone can list and overwrite every collection using the apiKey and projectId from the app. Afterwards the app breaks for everyone, and the usual quick fix (`if true`) makes it permanent.
Why it matters
Full read/write of user data by anyone; mass deletion; billing spikes from abuse.
How to fix it
- Replace catch-all `match /{document=**}` rules with one `match` per collection.
- Require ownership: `allow read, write: if request.auth != null && request.auth.uid == resource.data.ownerId;`.
- Validate writes (`request.resource.data`) so users cannot set fields like isAdmin.
- Test with the Firebase Emulator and the Rules Playground before `firebase deploy --only firestore:rules`.
firestore.rules
rules_version = '2';
service cloud.firestore {
match /databases/{db}/documents {
match /users/{uid} {
allow read, write: if request.auth != null && request.auth.uid == uid;
}
}
}Does your app have this?
PTKD checks your build or your source project for PTKD-BACKEND-FIREBASE-OPEN-RULES and every other check in this knowledge base.
Scan your appReferences
Related checks (M3)
- Permissive CORS with credentials
- State-changing request succeeded without authentication
- Weak JWT observed on the wire
- Biometric authentication not bound to a cryptographic key
- Premium access is stored on the phone and trusted (heuristic)
- Firebase rules trust an email address nobody verified
- Users can make themselves admin or premium in Firestore
- Supabase auth settings in the local config (check the hosted project)