Firebase Security Rules Audit: Step-by-step Checklist, Test Matrix, and Remediation Templates
Firebase SecuritySecurity RulesCloud FirestoreRealtime DatabaseAudit ChecklistEmulator Suite

Firebase Security Rules Audit: Step-by-step Checklist, Test Matrix, and Remediation Templates

AApp Forge Editorial
2026-11-11
7 min read

Audit and harden Firestore and Realtime Database Security Rules with a reusable checklist, threat test matrix, and remediation guidance.

A Firebase Security Rules audit helps you find data leaks, unintended writes, and privilege-escalation paths before they reach production. This reusable checklist covers Firestore and Realtime Database, maps common threats to emulator tests, and provides remediation patterns you can adapt to your data model.

Overview

Security Rules are part of the application’s authorization boundary. Client code can improve the user experience, but it must not be trusted to enforce access control. A useful audit therefore starts with the data a caller could request or modify, then verifies that every permitted operation has a clear reason.

Review Firestore and Realtime Database separately. They use different rule languages and have different evaluation models. A rule set that is safe for one product area may still be too broad for another, especially when collections, subcollections, paths, or query behavior change over time.

Before beginning, document the intended access policy in plain language. For each important resource, record who may read it, who may create it, which fields they may change, and which operations require a trusted backend such as Cloud Functions or the Admin SDK. If the policy cannot be explained clearly, the rules will be difficult to test and maintain.

For a deeper local-testing workflow, use the Firebase Security Rules Testing Guide. Pair this audit with your Firestore data modeling review, because a convenient data shape can sometimes create an unnecessarily broad authorization boundary.

Checklist by scenario

1. Establish the audit baseline

  • Identify every Firebase project, database, environment, and deployed ruleset.
  • Confirm which application versions and client SDK versions access each database.
  • Export or commit the rules source so the review has a traceable version.
  • List authentication providers, account states, custom claims, and administrative roles used by the rules.
  • Mark data that is public, user-owned, shared by a group, or backend-only.
  • Record any Cloud Functions or trusted services that write data outside normal client access.

2. Unauthenticated access

Test every top-level path as an unauthenticated caller. A denial should be the default unless the resource is deliberately public.

  • Attempt reads of individual documents, collections, queries, and Realtime Database paths.
  • Attempt creates, updates, deletes, and multi-document or multi-location writes.
  • Try guessed identifiers and adjacent paths, not only valid IDs from the user interface.
  • Verify that public content does not expose internal metadata, email addresses, tokens, or moderation fields.

3. Authenticated user access

Use at least two ordinary user identities, including users who own different records. Test both positive and negative cases.

  • Confirm a user can read only the documents or paths intended for that user.
  • Attempt to replace an owner or user ID with another account’s ID.
  • Attempt to read another user’s document by changing the document ID or path.
  • Attempt to update protected fields such as ownerId, role, billing state, approval status, or timestamps.
  • Attempt to delete records that the product says users may view but not remove.
  • Test stale, missing, and malformed authentication data rather than assuming every signed-in account is equivalent.

4. Groups, teams, and shared records

  • Test a member, a non-member, a former member, and a group administrator.
  • Verify membership checks use the authoritative membership record, not a client-supplied role field.
  • Check whether a user can alter their own membership, role, invitation status, or group identifier.
  • Test access after membership removal and after a role change.
  • For shared documents, verify that update permissions do not silently grant delete or ownership-transfer permissions.

5. Queries and collection access

Firestore rules are not filters. A query must be compatible with the rule conditions for every document it could return. Test the exact query shapes used by the application, including ordering, limits, pagination, and compound constraints.

  • Run allowed queries with the expected constraints.
  • Remove each constraint one at a time and confirm the query is denied when it would broaden access.
  • Test direct document reads separately from collection queries.
  • Check whether a new index or alternate query path could expose records outside the intended scope.

6. Realtime Database path and write validation

  • Test parent, child, and sibling paths; do not review only the path used by the current UI.
  • Check whether a write to a parent can overwrite protected children.
  • Test fan-out or multi-location updates as a single operation.
  • Use validation rules to enforce required types, fields, ranges, and relationships where appropriate.
  • Confirm that disallowed fields cannot be smuggled into an otherwise valid write.

7. Test matrix

Threat scenarioFirestore testRealtime Database testExpected result
Unauthenticated readRead a protected document and queryRead protected parent and child pathsDenied unless explicitly public
Horizontal accessRead or update another user’s documentChange the user ID in the pathDenied
Privilege escalationSet an admin or owner fieldWrite a role or membership pathDenied or backend-only
Mass assignmentAdd protected fields to an update mapAdd unexpected children to a writeDenied by field or validation checks
Parent overwriteReplace a document with unauthorized fieldsOverwrite a parent containing protected childrenDenied
Stale membershipUse a removed member’s credentialsUse a removed member’s path accessDenied under current policy

What to double-check

Authentication is not authorization

A signed-in user is not automatically entitled to every record. Rules should check the relevant ownership, membership, or role relationship. If custom claims are used, define how they are issued, refreshed, revoked, and tested. Avoid treating a client-written profile field as proof of privilege.

Create, update, and delete are different operations

Separate permissions where the business policy differs. A user who may create a comment may not be allowed to edit it after publication. A user who may update a profile may not be allowed to change its owner, status, or audit fields. For updates, compare the existing record with the proposed record and restrict sensitive changes explicitly.

Validation is part of the boundary

Authorization answers “who may act?” Validation answers “what may they write?” Check required fields, expected types, acceptable ranges, immutable identifiers, and server-managed timestamps. Keep validation aligned with the client’s actual payloads, but do not weaken it merely to accommodate an accidental client behavior.

Backend access can bypass client rules

Review Admin SDK and service-account access separately. A secure client ruleset does not prevent an incorrectly authorized backend job from writing sensitive data. Check callable functions, scheduled jobs, migration scripts, and support tools for authentication and authorization checks. The Firebase Authentication Architecture Guide can help document the identity and session assumptions behind these flows.

Test the deployed rules

Local emulator tests are valuable, but include a controlled deployment verification step. Confirm that the expected project is selected, the intended rules file is deployed, and the client is not accidentally connected to another environment. Keep production verification narrow and reversible.

Common mistakes

  • Using broad allow conditions: Rules that permit an entire collection or database path may solve a short-term development problem while creating a lasting exposure.
  • Relying on hidden document IDs: An unpredictable ID is not an authorization control. Assume identifiers can be discovered or guessed.
  • Checking only the interface: A hidden button does not stop a caller from sending a direct request. Test the database operation itself.
  • Testing only successful cases: Every important permission needs a corresponding denial test, including altered IDs, extra fields, and removed memberships.
  • Ignoring nested paths: A protected parent does not guarantee that every child path has the intended behavior. Review path inheritance and exceptions carefully.
  • Deploying rules without regression tests: A change that fixes one access path can unintentionally break or broaden another. Run the full test suite in CI before deployment; the Firebase CI/CD and Deployment Guide provides a useful deployment context.
  • Leaving temporary rules in place: Track development exceptions as tasks with owners and removal dates. Do not treat a temporary open rule as an acceptable release configuration.

When to revisit

Run this Firebase Security Rules audit before a major release, after changing the Firestore data model or Realtime Database paths, and whenever authentication providers, custom claims, roles, or membership logic change. Repeat it after SDK, Firebase CLI, or Emulator Suite workflow changes that affect testing or deployment.

Make the review part of regular release planning and security review cycles. Revisit it after an incident, a migration, a new administrative tool, or the introduction of a new client surface such as a mobile app, web app, or partner integration. Refresh the threat cases when the product adds sharing, invitations, payments, moderation, exports, or offline synchronization.

For a practical next pass, create a rules test inventory with one row for each protected resource. Assign an owner, record the expected result, and link each row to an automated emulator test. Then run this short release gate:

  1. Review the changed data paths and authorization assumptions.
  2. Run positive and negative tests for unauthenticated, ordinary, group, and privileged identities.
  3. Test protected fields, parent overwrites, queries, and multi-location writes.
  4. Inspect the deployed project and rules version in a controlled verification step.
  5. Record unresolved exceptions with an owner and a dated remediation plan.

Keeping the checklist, test matrix, and rules source together turns an audit from a one-time inspection into a repeatable control for Firebase app development.

Related Topics

#Firebase Security#Security Rules#Cloud Firestore#Realtime Database#Audit Checklist#Emulator Suite
A

App Forge Editorial

Firebase Engineering Editor

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.