Firebase Security Rules checklist for AI-built apps
Firebase web config (apiKey, projectId, authDomain) is public by design. Security Rules are what stand between the internet and your data, and AI builders often leave them in an open or test-mode state.
Scan your live app free Passive, no signup, never touches your database.
1. Find open rules
Firebase Console → Firestore → Rules, Realtime Database → Rules, Storage → Rules. Red flags: allow read, write: if true; '.read': true / '.write': true; and test-mode rules that grant everything until a date (request.time < timestamp.date(...)).
2. Require auth and ownership
Scope documents to the signed-in user:
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;
}
}
}3. Lock down Cloud Storage
Same idea for files:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /users/{userId}/{allPaths=**} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
}4. Validate writes
Rules can check the shape of incoming data (request.resource.data), so users can't, say, set role: 'admin' on their own profile.
5. Never ship admin credentials
Service-account JSON and firebase-admin belong only in Cloud Functions or another server. In the browser they bypass all rules.
6. Consider App Check
App Check helps ensure requests come from your genuine app, reducing abuse of your backend. It complements rules; it doesn't replace them.
7. Test rules before deploying
Use the Rules Playground in the console or the Firebase Local Emulator Suite to try reads and writes as an unauthenticated user and as a different user.
Fix guides for these issues
- Verify Firebase Security Rules: Your Firebase web config is public by design, so Firestore, Realtime Database and Storage rules are the only protection for user data. Here's how to check them.
- Private key or Firebase admin credentials exposed: A private key or Google service-account JSON in browser code gives admin access to Firebase/Google Cloud. Delete the key in Google Cloud IAM and use the Admin SDK only on a server.
- Google API key in client code: AIza keys in front-end code are fine for Firebase but dangerous for Gemini or paid Maps APIs. Restrict them by HTTP referrer and API in Google Cloud Console.
FAQ
Is my Firebase apiKey a secret?
No. Firebase's docs explain API keys for Firebase services identify your project and are fine to include in client code; access is controlled by Security Rules (and optionally App Check).
My rules have a date in them. Is that OK?
Test-mode rules allow all access until that date. Replace them with real auth-based rules before launching.
Sources
- Firebase docs: Avoid insecure rules
- Firebase docs: Security Rules
- Firebase docs: API keys
- Firebase docs: App Check
Last checked against these sources on 2026-10-19. Platforms change; when in doubt, the official docs win.