Features
Firebase Checks
DeployReady reads the Firebase files in your project and flags security rules that let the wrong people read or write your data. By default the checks are static: they read files on disk and never contact your Firebase project. An opt-in mode runs your rules in the Firebase Emulator Suite on localhost.
The static checks run on every scan. There is no flag to enable them and no credentials to provide. The emulator mode, --firebase-emulator, is opt-in.
What is checked#
| Rule | Severity | Fires on |
|---|---|---|
firebase-rules-open | critical | firestore.rules or storage.rules: allow ...: if true, an allow with no condition that includes a write, or any open allow on a recursive wildcard ({document=**}, {allPaths=**}). |
firebase-rules-open-read | warning | An open read-only allow on a specific path. Fine for a public catalogue, a leak for anything else. |
firebase-rules-test-mode | critical (warning once expired) | The console’s test-mode rule, request.time < timestamp.date(Y, M, D): open to everyone until that date. |
firebase-rules-auth-only | critical for writes, warning for reads | A user-owned path (/users/{userId}, /orders/{id}, /messages/{id}, users/{uid}/... in Storage, and similar) gated only by request.auth != null, with no comparison of request.auth.uid to the path variable or an owner field. |
firebase-rules-recursive-wildcard | critical | A recursive wildcard that only requires sign-in. Anyone can sign up, so this is open to the internet. |
firebase-rtdb-open | critical (warning for a narrow public .read) | database.rules.json: ".read" or ".write" set to true at the root, at a $wildcard, or ".write": true anywhere. |
firebase-rtdb-test-mode | critical (warning once expired) | ".read": "now < <epoch ms>". |
firebase-rtdb-auth-only | warning | ".read" or ".write" of auth != null only. |
firebase-service-account-committed | critical | A JSON file containing "type": "service_account" and a private_key, unless a root .gitignore rule ignores it. The key is never printed. |
firebase-no-rules-file | info (not scored) | firebase.json or .firebaserc is present but no rules file is in the repository, so deployed rules could not be checked. |
How rules are read#
- A small, tolerant scanner reads match nesting, allow statements, and simple one-line helper functions such as isOwner(id). Helpers are inlined before the condition is judged. Comments are ignored. Syntax it does not understand is skipped rather than failing the scan.
- Conditions it judges: true, no condition, sign-in-only (request.auth != null, isSignedIn()-style helpers, verified email), and the test-mode date check, combined with && and ||. Any other condition, such as an owner comparison, custom claims, field validation, or get() and exists() lookups, counts as a real restriction and is not flagged.
- Findings carry the file and line, redacted evidence, and a recommendation with a corrected rule example.
- Files read: *.rules, database.rules.json, firebase.json, .firebaserc, and other JSON files under 256 KB (for service account keys), anywhere in the project except node_modules, build output, and dot-directories.
Proving rules in the Firebase Emulator Suite#
deployready analyze . --firebase-emulatorReading rules is not the same as running them. With --firebase-emulator, DeployReady starts the Firestore and Storage emulators with your firestore.rules and storage.rules, then sends real requests and records what the rules actually allow. It is available since 0.6.0.
What it does#
- Picks one rules file per service (the one firebase.json names, else the shallowest) and builds a test plan from every match path: wildcard variables get concrete ids, and the variable the rules compare to the caller becomes the owner’s uid.
- Copies the rules into a temporary directory and starts the emulators bound to 127.0.0.1 on free ports, under a throwaway demo-deployready-* project id. Nothing is read from or written to your repository, and no credentials are passed to the emulator process.
- For each path, seeds a minimal document or object as admin (an emulator-only bypass), then tries get, list, create, update, and delete as anonymous, user A (the owner), and user B (another signed-in user), using unsigned emulator tokens and resetting the data before each probe. Create probes set the owner fields to A, so a missing ownership check shows up as B creating a document on A’s behalf.
- Stops the emulators and deletes the temporary directory. Every request is checked to be plain HTTP to loopback. A real Firebase project is never contacted.
How results combine with the static checks#
| Emulator result | Static result | Outcome |
|---|---|---|
| Anonymous (or any user) allowed | Flagged | The static finding is kept and gains proof: the request, status, response, and the owner’s control request. |
| Anonymous allowed | Not flagged | New firebase-emulator-open-access: critical for writes, recursive or user-owned paths, otherwise warning. The emulator disagrees with the static reader. |
| Signed-in non-owner allowed | Not flagged or flagged lower | New firebase-emulator-owner-check-missing: critical when a write is allowed, warning for reads on user-owned paths. Signed-in reads on a shared, non-user path are only an info note, since they are often intended. |
| Everything denied for anonymous and non-owners | Flagged | The static finding becomes an info note, “Not reproduced in the emulator: ...” (for example an expired test-mode rule). It is downgraded only when every probe returned a clear allow or deny. |
| Seeding failed or responses were unclear | Any | The path is reported as untested or inconclusive and static findings are left alone. |
Emulator findings are listed with their file and allow line. The coverage area firebase (emulator) is passed when every path was tested cleanly, inconclusive when some paths were skipped or errored (for example a collection-level match without a wildcard, or a rules file beyond the first per service), and untested when the tools are missing.
Example fix#
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}Not flagged on purpose#
The Firebase web config (apiKey, authDomain, projectId, appId) is public by design. It ships in every client, and access is enforced by your security rules, not by hiding it. The Firebase module never reports it. If the general secret scanner reports an apiKey: "AIza..." as a hardcoded secret, that is a false positive. Restricting the key by HTTP referrer in Google Cloud Console adds defense in depth.
What is not checked#
- Rules that exist only in the Firebase console and not in the repository (see firebase-no-rules-file).
- Deep rule semantics: get() and exists() cross-document logic, custom claim correctness, field-level validation, rate limits, and per-method differences beyond the checks above.
- Rules in another format, such as Terraform or generated files, and rules files over 1 MB.
- Cloud Functions, App Check, Auth settings, and Firebase Hosting configuration.
- Service account keys outside JSON files, or files ignored only by a nested .gitignore. A key in git history is not detected. If one was ever committed, rotate it.
See also Supabase checks and Static analysis.