🔥

Firebase Security Guide

Google's app development platform

high risk level

Firebase provides auth, database, storage, and hosting. Its Firestore security rules are powerful but complex — misconfigured rules are the #1 source of data breaches in Firebase apps, especially when AI generates them.

Common Vulnerabilities

critical

Open Firestore security rules

Default or AI-generated rules often allow read/write to all users (allow read, write: if true).

Write granular security rules that check auth.uid and validate data structure for every collection.

high

Exposed Firebase config with unrestricted APIs

Firebase config is public by design, but unrestricted API keys allow abuse (e.g., unlimited auth calls).

Restrict API keys in Google Cloud Console. Enable App Check to prevent unauthorized access.

high

Missing server-side validation

Relying solely on client-side validation means attackers can bypass checks via direct API calls.

Use Cloud Functions for server-side validation on all write operations.

critical

Insecure Cloud Storage rules

Storage buckets often have overly permissive rules allowing any authenticated user to read all files.

Restrict storage rules to user-specific paths (e.g., /users/{userId}/*).

medium

No rate limiting on Cloud Functions

HTTP-triggered Cloud Functions lack built-in rate limiting.

Implement rate limiting using Firebase App Check or a middleware layer.

Pre-Launch Security Checklist

Audit all Firestore security rules — no open read/writeRequired
Restrict API keys in Google Cloud ConsoleRequired
Enable Firebase App CheckRequired
Audit Cloud Storage security rulesRequired
Add server-side validation via Cloud FunctionsRequired
Enable email verification before account access
Review OAuth providers and redirect URIs
Check for leaked service account keys in sourceRequired
Monitor usage for anomalies via Firebase Console
Test security rules with the Firebase Emulator

Security Tips

1.

Use the Firebase Emulator Suite to test security rules locally before deploying.

2.

Never trust AI-generated Firestore rules — always test with the Rules Playground.

3.

Enable Firebase App Check to prevent API abuse from unauthorized clients.

Scan your Firebase app now

Erzo automatically detects these vulnerabilities and gives you actionable fixes.

    Erzo — AI Code Security Scanner | Error Zero