Auditing Firebase
Firebase is Google’s platform for web and mobile apps: authentication, databases (Cloud Firestore and Realtime Database), file storage (Cloud Storage), hosting and functions. As with Supabase, the client talks directly to the data. The only thing that decides who reads or writes what is Firebase Security Rules. An overly broad rule raises no error: the app works and the data is left open.
Responsibility model
Section titled “Responsibility model”Google runs the infrastructure and the services. The customer writes the rules, restricts the keys, configures Auth, turns on App Check, protects service accounts and manages the project’s IAM permissions.
flowchart LR
A["Web or mobile app<br/>public config:<br/>apiKey, projectId"] --> AU["Firebase Auth<br/>user token"]
A -->|"token + App Check"| R{"Security Rules"}
R -->|"allowed"| FS[("Firestore /<br/>Realtime Database")]
R -->|"allowed"| ST[("Cloud Storage")]
S["Backend with Admin SDK<br/>service account"] -->|"skips the rules"| FS
S --> ST
Keys: what is secret and what isn’t
Section titled “Keys: what is secret and what isn’t”| Credential | Secret? | What to check |
|---|---|---|
Firebase API key (apiKey in the config) |
No: it only identifies the project | That it’s restricted to Firebase APIs |
| API key for other Google APIs (Maps, Gemini…) | Yes, in practice | That it’s a different key, restricted to that API and the app |
| Service account key (Admin SDK JSON) | Yes | That it isn’t in the client, repositories or images |
| FCM server key (legacy HTTP API) | Yes | That it isn’t in the client; migrate to the current API |
Google is explicit: Firebase API keys aren’t treated as secrets and can be included in code. Authorization is done by IAM, Security Rules and App Check. The real finding appears when that same key grants access to paid APIs without restriction.
# From the inside, with read access to the Google Cloud projectgcloud services api-keys list --project <project>gcloud services api-keys describe <key-id> --project <project> # check restrictionsLab: insecure and secure rules
Section titled “Lab: insecure and secure rules”The lab uses the Firestore emulator (firebase-tools 15.37.0) and @firebase/rules-unit-testing. A script seeds data with rules off (withSecurityRulesDisabled) and repeats the same operations against two rule sets:
// insegura.rules (summary)match /mensajes/{id} { allow read, write: if request.time < timestamp.date(2026, 12, 21); } // test modematch /pedidos/{id} { allow read, write: if request.auth != null; } // any usermatch /boosts/{id} { allow read: if request.auth != null && resource.data.creatorId == request.auth.uid; allow create, update: if request.auth != null && request.resource.data.creatorId == request.auth.uid;}// segura.rules (summary)function signedIn() { return request.auth != null && request.auth.token.firebase.sign_in_provider != 'anonymous'; }function isOwner(uid) { return signedIn() && request.auth.uid == uid; }
match /mensajes/{id} { allow read: if isOwner(resource.data.userId); allow create: if isOwner(request.resource.data.userId) && request.resource.data.keys().hasOnly(['userId', 'texto']) && request.resource.data.texto is string && request.resource.data.texto.size() <= 2000;}match /pedidos/{id} { allow read: if isOwner(resource.data.userId) || request.auth.token.admin == true; allow write: if false; // orders are created by the backend with the Admin SDK}match /boosts/{id} { allow read: if isOwner(resource.data.creatorId); allow create: if isOwner(request.resource.data.creatorId); allow update: if isOwner(resource.data.creatorId) && request.resource.data.creatorId == resource.data.creatorId;}firebase emulators:exec --only firestore --project demo-auditoria "node test.mjs insegura.rules"| Operation | Insecure rules | Secure rules |
|---|---|---|
| Anonymous user lists every message | ALLOWED | denied |
| Anonymous user writes a message as Ana | ALLOWED | denied |
| Beto reads Ana’s order | ALLOWED | denied |
| Beto changes the amount on Ana’s order | ALLOWED | denied |
Beto takes over Eva’s boost (creatorId: 'beto') |
ALLOWED | denied |
| Eva edits her own boost | denied (no longer hers) | ALLOWED |
What each row shows:
- Test mode opens the database to anyone who knows the
projectId. It expires after about 30 days and the app stops working. At that point the temptation is to change the date or writeif true. request.auth != nullonly requires some account. If sign-up is open, anyone gets one in a minute, even without going through the app, by calling the Auth API directly.- Checking the owner only on
request.resource(the document as it would end up) lets a user overwrite other people’s documents by setting themselves as owner. Onupdate, also checkresource(the current document) and prevent the ownership field from changing. After the takeover, Eva herself lost access to her boost.
Patterns to look for in the rules
Section titled “Patterns to look for in the rules”| Pattern | Risk | Fix |
|---|---|---|
allow read, write: if true; or no condition on {document=**} or {allPaths=**} |
Everything open | Deny by default and open per collection |
request.time < timestamp.date(...) |
Forgotten test mode | Real rules before launch |
request.auth != null as the only condition |
Any account reads and writes everything | Ownership (request.auth.uid == ...), role or attribute |
Owner checked only on request.resource |
Taking over other users’ documents | Check resource on update and prevent the owner from changing |
| Role read from a field the user writes | Escalation to admin | Custom claims (request.auth.token.admin), set only by the Admin SDK |
Email domain without email_verified |
Anyone signs up with that domain | Require request.auth.token.email_verified == true |
| Anonymous users treated as registered | Access to non-public data without a real identity | sign_in_provider != 'anonymous' |
| No field validation | Extra fields, arbitrary types or sizes | keys().hasOnly(...), types and sizes |
| Realtime Database: restrictive rule on a child | Ignored: RTDB rules can only grant access, never take it away | Restrict on the parent node |
Cloud Storage
Section titled “Cloud Storage”Storage rules are separate from Firestore’s and often stay in their initial state. allow read, write; inside match /{allPaths=**} leaves every file readable and replaceable. Identity verification files, invoices and private attachments need per-user rules (match /usuarios/{uid}/{file} with request.auth.uid == uid), upload size and type limits, and never a permanent public URL.
App Check, Auth and abuse
Section titled “App Check, Auth and abuse”- App Check verifies that the request comes from the legitimate app, with App Attest or DeviceCheck on Apple, Play Integrity on Android and reCAPTCHA Enterprise on the web. Turn it on for every service that supports it and switch to enforcement after reviewing the metrics. It doesn’t replace the rules: it reduces automated abuse, but it doesn’t decide which data each user can see.
- Auth:
- Email enumeration protection turned on.
identitytoolkit.googleapis.comquota tuned against brute force.- MFA through Identity Platform if the data calls for it.
- Anonymous sign-in only for state before signing in.
- Functions:
- Secrets in Secret Manager, not in environment variables.
max-instancesin line with normal traffic.- Budget alerts and spend caps.
- Environments:
- Separate projects for development, staging and production.
- Production access with minimal IAM roles.
Outside check
Section titled “Outside check”The public config (apiKey, projectId, storageBucket) is in the JavaScript or the mobile app package (see JavaScript analysis). On a project you own or are authorized to test, with that config and the official SDK:
- No session: read by ID and list every collection the app uses.
- Register two test accounts through the API, not the app, and repeat cross reads and writes.
- Try an
updateon someone else’s document, changing the ownership field. - Request Storage files by path, without a session and as the other account.
From the inside, rules are read in the console’s Rules tab, tested in the Rules Playground and versioned in the repository (firestore.rules, storage.rules) with CI tests against the emulator.
Real cases
Section titled “Real cases”- Arc, CVE-2024-45489 (2024). Arc’s Firestore rules allowed changing a boost’s
creatorID(CSS and JavaScript the browser injects into websites) after it was created. An attacker could assign any user a boost carrying their own JavaScript. The company fixed it within a day, disabled JavaScript in synced boosts and audited its rules. It’s the takeover row from the lab. - 900 websites and 125 million records (2024). After getting into Chattr (AI hiring for restaurant chains) by creating an account directly against Firebase, three researchers scanned the Internet. They found more than 900 websites with open rules: 106 million email addresses, 20 million passwords (many in plaintext) and 27 million billing records. They emailed the affected owners and only 24% fixed it.
- Tea (July 2025). An unprotected Firebase Storage bucket exposed about 72,000 images, including about 13,000 verification selfies and ID documents. Days later a second exposure was confirmed, of more than a million private messages.
Checklist
Section titled “Checklist”- No service account key or FCM server key in the client or repositories
- Firebase API keys restricted to Firebase APIs; separate, restricted keys for other APIs
- No
if true, test-mode orrequest.auth != null-only rules - Ownership checked on
resourceandrequest.resource; the owner field can’t change - Roles via custom claims; verified email wherever the domain is trusted; anonymous users kept separate
- Field, type and size validation on writes
- Per-user Storage rules with size and type limits
- Rules in the repository with CI tests against the emulator
- App Check turned on and enforced on every supported service
- Email enumeration protection and tuned Auth quota
- Function secrets in Secret Manager;
max-instancesand budget alerts - Separate projects per environment; minimal IAM in production
- Outside test with two accounts created through the API
References
Section titled “References”- Firebase security checklist
- Firebase: Avoid insecure rules
- Firestore: Fix insecure rules
- Firebase: Learn about using and managing API keys
- Firestore: Test your security rules with the emulator
- Firebase App Check
- The Browser Company: CVE-2024-45489 Incident Report
- NVD: CVE-2024-45489
- 900 Sites, 125 million accounts, 1 vulnerability