Firebase security rules, tested caller by caller
In a Firebase app the browser reads and writes Firestore, Realtime Database and Cloud Storage directly, and the security rules Firebase evaluates decide what each client request may do.
This guide explains how rules behave in each product, where get differs from list and where reads cascade, what App Check adds and what it does not, and comes with a workbook of unauthenticated, signed-in, owner and other-user cases to run on a staging project or in the emulator.
In this guide
Firebase rules test workbook
Keep one copy of this table per Firebase project, and one per named Firestore database, in a spreadsheet of your own. Row S0 sets up the products, callers and keys.
How to use itHide the instructions
Rows F1 to K1 are one case each, and their four caller columns give the result an owner-only design expects; where your app means data to be public or shared, write your intended result over it first. Rows S0, A1 and C4 read settings in the Firebase and Google Cloud consoles. Run simulated requests in the Rules Playground, or in Firestore's Google Cloud console simulator where row F9 says, on a staging project that holds only invented data, without editing or publishing the rules, and run list, query and upload cases in the Local Emulator Suite. Row K1 starts from your server code and sends requests, if any, only to your own staging copy, within the limits on the row. Row E1 turns the cases into an emulator regression run. In your copy, record what each row's last column asks for and the date. Record that a key or service account exists and where it is used, never its value. The emulator row describes Firebase's documented steps, which were not run for this page. Firebase's pages were read on 15 November 2026.
21 rows
Case
Where to read the rule and run the case
S0. Set-up: products, databases, callers and keys
- Where to read the rule and run the case
- List each product the app uses: Firestore, with each named database, since Firestore applies rules separately to each one; Realtime Database; Cloud Storage. Firebase's API keys page says the APIs & Services > Credentials page of the Google Cloud console lists all the project's API keys and their "API restrictions", which can include a Gemini Developer API key that Firebase says must be protected from public exposure. Read only each key's name and the APIs in its restrictions there, and do not display or copy any key string.
- Unauthenticated
- No sign-in. In the Rules Playground, choose unauthenticated; in the emulator, unauthenticatedContext().
- Signed in, owns nothing
- A test account with no records. Firebase's security checklist notes that anyone could create an anonymous account in a project, so include an anonymous sign-in.
- Owner (user A)
- Test user A, holding invented records in every collection, path and bucket the cases use.
- Other user (user B)
- Test user B, holding invented records of the same kind as A.
- Record in your copy
- Project ID, each product and database in use, the four test identities by label and user ID, and each API key by name with the APIs in its "API restrictions" allowlist. Never a key value or a password.
F1. Firestore get: one document that belongs to A
- Where to read the rule and run the case
- Databases & Storage > Firestore > Rules tab, then Rules Playground, with a get on the path of one of A's documents. Simulations run against the ruleset in the editor, so leave it unchanged.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied. A rule that only checks request.auth != null lets this caller in; Firebase's insecure rules guide says to confirm that any logged-in user is meant to have access.
- Owner (user A)
- Allowed, by a rule that compares request.auth.uid with the document's owner field or with the user ID in its path.
- Other user (user B)
- Denied. For a single-document get, Firestore evaluates the rule against the document's actual fields.
- Record in your copy
- Expected and actual result per caller, the match block that decided it, and whether the rule names get, read or both.
F2. Firestore list: a query filtered to A
- Where to read the rule and run the case
- Local Emulator Suite. Query the collection with the same owner constraint the rule uses, such as where owner equals A's user ID.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied. The potential results hold documents this caller may not read, and Firestore says the entire request then fails.
- Owner (user A)
- Allowed, because the query carries the rule's own constraint, as in Firebase's stories example.
- Other user (user B)
- Denied for a query filtered to A. B's query filtered to B is allowed and returns only B's documents.
- Record in your copy
- The query constraints used, the result per caller, and whether list has its own rule or shares a read rule with get.
F3. Firestore list: the whole collection, unfiltered
- Where to read the rule and run the case
- Local Emulator Suite. Query the collection with no owner constraint, the way a careless list screen would.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied.
- Owner (user A)
- Denied, even when A owns every document: Firebase says rules are not filters, and its example query fails even when the user wrote every story.
- Other user (user B)
- Denied.
- Record in your copy
- If this query succeeds for anyone, the list rule is wider than the owner rule; note the line. Where the app caps page size, record whether the rule checks request.query.limit, which Firebase's query guide shows.
F4. Firestore create: owner field and allowed fields
- Where to read the rule and run the case
- Rules Playground, simulating a write of a new document with its document data, then the emulator for the full set. Use invented values only.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Allowed only for a document whose owner field is the caller's own ID, and only if new accounts are meant to create records. Denied for a document that names A.
- Owner (user A)
- Allowed with the listed fields. Denied when the new document adds a field outside the list, such as role or plan, if the rule uses keys().hasOnly() as Firebase's field guide shows.
- Other user (user B)
- Denied for a document that names A as owner. Firebase's content-owner example compares request.auth.uid with the owner field in request.resource.data on create.
- Record in your copy
- The document data tried in each case and which check refused it: owner match, required fields (hasAll), allowed fields (hasOnly) or a type check (is).
F5. Firestore update: protected fields and ownership
- Where to read the rule and run the case
- Rules Playground, simulating a write to an existing document with the changed document data, then the emulator.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied.
- Owner (user A)
- Allowed for the fields A may edit. Denied for a change to the owner field or to a field the app sets elsewhere, such as role, plan or credits. Firebase's field guide uses diff().affectedKeys().hasOnly() to allow only listed fields to change.
- Other user (user B)
- Denied.
- Record in your copy
- Each field tried and its result, and whether the update rule repeats the create rule's type checks. Firebase says field types need enforcing on both create and update.
F6. Firestore delete
- Where to read the rule and run the case
- Rules Playground with a delete on one of A's documents.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied.
- Owner (user A)
- Allowed where the app lets users delete their own records; otherwise denied for every caller and left to server code.
- Other user (user B)
- Denied. A rule written as allow write covers create, update and delete together, so check that the delete case was meant.
- Record in your copy
- Whether delete has its own rule or falls under a write rule, and the result per caller.
F7. Firestore subcollections and collection groups
- Where to read the rule and run the case
- The rules file, read for nested match blocks, recursive wildcards and rules_version = '2';, then the emulator for collection group queries.
- Unauthenticated
- Denied for a document in A's subcollection.
- Signed in, owns nothing
- Denied.
- Owner (user A)
- Allowed only if a rule matches the subcollection. Firebase says rules on a collection do not apply to its subcollections.
- Other user (user B)
- Denied. A collection group rule such as match /{path=**}/posts/{post} applies to every collection with that ID, so it needs its own owner condition.
- Record in your copy
- Each subcollection and collection group the app queries, every match block that covers it, and any recursive wildcard that also matches. Where two blocks match, Firestore allows the request if either allows it.
F8. Firestore role lookups with get() and exists()
- Where to read the rule and run the case
- The rules file, for each get() or exists() call and the collection it reads, then the Playground or emulator as A and B.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied where the rule requires a role document this account does not have.
- Owner (user A)
- Allowed for what A's role grants.
- Other user (user B)
- Denied where B's role does not grant it. Then try B writing its own role document: if that succeeds, the lookup grants whatever B writes.
- Record in your copy
- Which collection holds roles and who can write it. Firestore's conditions guide says using get() or exists() executes a read you are billed for even when the rules reject the request, and its structure guide limits single-document and query requests to 10 such calls.
F9. Firestore rules that trust an email address
- Where to read the rule and run the case
- The rules file, for any condition on request.auth.email or token claims, then the Google Cloud console simulator, where token payload fields can be set, or the emulator with token overrides.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied for an account at the right domain whose email is not verified. Firebase's insecure rules guide says emails are not always verified during sign-in and shows a rule that also checks request.auth.email_verified.
- Owner (user A)
- Allowed with a verified address at the domain.
- Other user (user B)
- Allowed too, if B has a verified address at the same domain. Record whether every such user is meant to see every record the rule covers.
- Record in your copy
- Each rule that reads an email or claim, and whether it checks email_verified. Firebase's checklist advises rules that require specific sign-in methods or verified email addresses for non-public data.
R1. Realtime Database read: A's own node
- Where to read the rule and run the case
- Realtime Database, then Rules, then Rules Playground, with a read at the path of A's node.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied.
- Owner (user A)
- Allowed, by a rule such as "auth !== null && auth.uid === $uid" on the node, as in Firebase's conditions guide.
- Other user (user B)
- Denied.
- Record in your copy
- Result per caller, and the read rule at that path and at every parent path above it.
R2. Realtime Database read: the parent node
- Where to read the rule and run the case
- Rules Playground, with a read at the parent path, such as the node that holds every user.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied.
- Owner (user A)
- Denied. Firebase says a read at a parent fails if no rule at that location or above grants it, even when every child path is readable.
- Other user (user B)
- Denied.
- Record in your copy
- Any read or write rule that evaluates to true at a parent. Firebase says a grant at a path covers every child node and a child rule cannot revoke it.
R3. Realtime Database query: A's records by owner
- Where to read the rule and run the case
- The rules file, for query. expressions, then the emulator with a query ordered by the owner child and equal to a user ID.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied for a query equal to A's user ID.
- Owner (user A)
- Allowed where the rule requires query.orderByChild to be the owner child and query.equalTo to be auth.uid, as in Firebase's baskets example.
- Other user (user B)
- Denied for A's user ID where the rule requires query.equalTo to be the caller's auth.uid. Firebase also says a query without the parameters in the rule fails with PermissionDenied.
- Record in your copy
- Each query. expression in the rules, the query the app sends, and whether query.limitToFirst is capped where the app means to limit downloads.
R4. Realtime Database write: .write, .validate and removal
- Where to read the rule and run the case
- The rules file, then the Playground or emulator with a write of invented data to A's node and a separate removal.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied for A's node.
- Owner (user A)
- Allowed for a value that passes every .validate rule on the path; denied otherwise. Firebase says validate rules do not cascade, so each one at each level must pass.
- Other user (user B)
- Denied, for both the write and the removal.
- Record in your copy
- Which nodes have validate rules and how removals are controlled. Firebase says validate definitions are ignored when data is deleted, that is when the new value is null, so test removal as a case of its own. Note any $other rule refusing unexpected children.
C1. Cloud Storage get: one of A's files
- Where to read the rule and run the case
- Databases & Storage > Storage > Rules tab, then Rules Playground, with a get on the path of one of A's invented files.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied.
- Owner (user A)
- Allowed, by a rule that compares request.auth.uid with the user ID in the file path, Firebase's user-private pattern.
- Other user (user B)
- Denied.
- Record in your copy
- Result per caller, and any read rule on the path that ignores request.auth, which Firebase's Storage conditions guide says can be considered a public rule.
C2. Cloud Storage list: A's folder
- Where to read the rule and run the case
- The rules file, for allow list and rules_version = '2';, then the emulator with a listAll on A's prefix.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied.
- Owner (user A)
- Allowed only if a read or list rule grants it. Firebase says list rules, and the List API, are only available in projects on rules version 2.
- Other user (user B)
- Denied. Firebase says a listAll request fails if it could return a file the caller may not read.
- Record in your copy
- Whether read is split into get and list, and every recursive wildcard rule that also matches the prefix. Firebase says the result is the OR of every rule a file matches.
C3. Cloud Storage upload: size and content type
- Where to read the rule and run the case
- The rules file, for checks on request.resource.size and request.resource.contentType, then the emulator with small invented files.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied for A's path.
- Owner (user A)
- Allowed for a file inside the size cap with an allowed content type; denied for one outside it, where the rule checks both as Firebase's example does.
- Other user (user B)
- Denied.
- Record in your copy
- The size cap and content types each upload path allows, and whether create, update and delete have separate rules. Firebase says update applies to changes to pre-existing file metadata.
C4. Cloud Storage rules that read Firestore
- Where to read the rule and run the case
- The Storage rules, for firestore.get() or firestore.exists(). The IAM page in the Google Cloud console, with "Include Google-provided role grants" ticked, for the Firebase Storage service account.
- Unauthenticated
- Denied.
- Signed in, owns nothing
- Denied when the Firestore document the rule reads does not list this caller.
- Owner (user A)
- Allowed when A's Firestore document grants it.
- Other user (user B)
- Denied unless B's document grants it, so check in the Firestore rows that B cannot write that document.
- Record in your copy
- Whether the "Firebase Rules Firestore Service Agent" role is listed. Firebase says Storage rules may access no more than two Firestore documents in one evaluation, those reads count towards Firestore billing, and only the default database can be read when several are active.
A1. App Check enforcement for each product
- Where to read the rule and run the case
- Security > App Check in the Firebase console, and the APIs tab for request metrics. Read only: do not click Enforce, which changes the project.
- Unauthenticated
- With enforcement on, a request without a valid App Check token is rejected whether or not the caller is signed in.
- Signed in, owns nothing
- The same. App Check attests the app or device, not the user.
- Owner (user A)
- The same. A request with a valid token still has to pass the rules, which Firebase's API keys page gives the job of deciding which end users reach a resource.
- Other user (user B)
- The same. B can use your genuine app, so B's requests can carry valid tokens; the rules are what refuse B.
- Record in your copy
- For Firestore, Realtime Database and Storage, whether enforcement is on, and the counts the APIs tab shows in categories including "Verified requests", "Outdated client requests", "Unknown origin requests" and "Invalid requests".
K1. Server code: Admin SDK and service accounts
- Where to read the rule and run the case
- Your server code and Cloud Functions, for every use of the Admin SDK or a server client library. Firestore says server client libraries bypass all its rules; the Realtime Database guide says an Admin SDK instance with an Editor-role service account has complete read and write access.
- Unauthenticated
- Firebase's pages say the rules do not decide this for the server client libraries or an Editor-role Admin SDK instance. The case is whether the endpoint that calls them refuses a caller with no session.
- Signed in, owns nothing
- The endpoint must refuse a caller who owns nothing, as the rules would.
- Owner (user A)
- The endpoint acts for A only on A's records.
- Other user (user B)
- The endpoint refuses B's request for A's record. Read the endpoint code first; if you send requests, send them only to your own staging copy, with test accounts and test records, one request per case and no load, and with any email or text the endpoint sends going to an address or number you control.
- Record in your copy
- Each file and function that uses the Admin SDK, the role its service account holds, and whether a service account key file exists and where it is stored. Firebase says service account private keys must be kept secret, so record the path only and never open or print the file.
E1. Emulator regression run (described, not run for this page)
- Where to read the rule and run the case
- Firebase CLI: firebase init emulators, rules files named under the database, firestore and storage keys in firebase.json, then firebase emulators:exec to run the test script and stop the emulators when it ends. Everything runs on your own machine against invented data.
- Unauthenticated
- unauthenticatedContext() from @firebase/rules-unit-testing, with assertFails on every rules case above (rows F1 to C4) that expects a denial.
- Signed in, owns nothing
- authenticatedContext() with a user ID that owns nothing, and token overrides where a case needs an anonymous or unverified-email token.
- Owner (user A)
- authenticatedContext() for A, with assertSucceeds on each allowed rules case (rows F1 to C4). Seed A's invented records inside withSecurityRulesDisabled().
- Other user (user B)
- authenticatedContext() for B, with assertFails on every rules case (rows F1 to C4) that reaches A's records.
- Record in your copy
- The commit of each rules file tested and pass or fail per case. Firebase says that without configured rules the emulators run with open data security, so confirm the rules file loaded and keep at least one case that must fail.
Where Firebase sits in your application
Firebase security rules matter because the client SDKs in the browser or mobile app talk to Cloud Firestore, Realtime Database and Cloud Storage directly, with no server of yours in between.
Firebase's own explanation of how rules work says they remove the middle (server) layer and let you specify path-based permissions for clients that connect to your data directly. Firestore's guide says every request from its mobile and web client libraries is evaluated against your rules before any data is read or written, and that the entire request fails if the rules deny access to any of the document paths it names.
The Realtime Database guide says its rules live on Firebase's servers and that a read or write completes only if the rules allow it.
Rules are written product by product. Firebase's overview says you must define Security Rules for each Firebase product you use, and that Realtime Database rules use JSON while Firestore and Cloud Storage rules use a language of their own. Firebase's structure guides say Firestore and Storage rules always begin with a service declaration of their own, and the Storage guide says its declaration prevents conflicts between Storage rules and the rules of other products such as Cloud Firestore.
Firestore's structure guide adds that rules are applied separately for each named database in a project, so with several databases you must manage and deploy rules for each one individually. The workbook takes one copy per database for that reason.
Some requests never meet the rules. Firestore's guides note that the server client libraries bypass all Cloud Firestore Security Rules and authenticate through Google Application Default Credentials. The Realtime Database Admin SDK guide says an Admin SDK instance initialised with the credentials of a service account holding the Editor role has complete read and write access to the project's database.
Code that runs on a server or in Cloud Functions therefore has to check for itself whose data it is touching, and that check is tested as part of your own API, the subject of the broken access control guide.
This page is the technical companion to the vibe coding security guide, which covers the quick checks for apps an AI builder made on Firebase or Supabase. Here the subject is the rules themselves: how each product evaluates them, the settings around them, and a workbook that turns them into test cases you can repeat after every change.
What Firebase enforces and what you write
Firebase evaluates the rules on every client request, and the developer decides what they say.
Firebase's security checklist advises initialising rules to deny all access by default and adding rules that grant access to specific resources as the app is built, and writing rules as you write the app, treating them like a database schema: whenever a new document type or path structure is needed, its rule comes first.
The starting rules depend on how a database or bucket was created. Firebase's guide to avoiding insecure rules says that when you create a database instance or Cloud Storage bucket in the Firebase console, you can choose Locked mode, which denies access to all users, or Test mode, which grants access to all users.
Firestore's quickstart describes test mode as allowing anyone to read and overwrite your data, and production mode as denying all reads and writes from mobile and web clients.
Firebase says that if a deployed app is not authenticating users and configuring security rules, anyone who guesses your project ID can steal, modify or delete the data.
How rules combine and how they treat queries shape every case in the workbook. On combining, Firebase's overview says Security Rules are applied as OR statements: if several rules match a path and any of them grants access, access is granted, so a broad rule cannot be narrowed by a more specific one.
It adds that Firebase flags overlapping matched paths as compiler warnings, and this page's advice is to read those warnings rather than dismiss them. The Realtime Database core syntax guide describes overlapping rules differently, as the Realtime Database section below sets out.
On queries, rules decide whole requests instead of filtering results. Each product's own documentation says so, and the sections below give each one.
The project's Firebase API keys are not the control. Firebase's security checklist heads its section "API keys for Firebase services are not secret" and says those keys only identify your Firebase project and app to Firebase services, with authorisation handled through Google Cloud IAM permissions, Firebase Security Rules and Firebase App Check.
The checklist and Firebase's API keys page both attach a condition: if the app's setup follows the guidelines they list, API keys restricted to Firebase services do not need to be treated as secrets. The API keys page says the key an app uses for calls to the Gemini Developer API should never be included in code or configuration files, and the checklist says service account private keys used by the Admin SDK are sensitive and must be kept secret. For a secret key that has already leaked, turn to the secrets exposure guide.
Firestore rules: get, list and queries that fail whole
Firestore's structure guide says a read rule can be broken into get, which applies to single-document reads, and list, which applies to queries and collection reads, and a write rule into create, update and delete.
A rule written as allow read covers both get and list, and allow write covers all three writes, so one broad line can allow an operation nobody meant to allow. On this page's advice, start every Firestore row by reading which operations each rule names.
Rules are not filters. Firestore's query guide says it evaluates a query against its potential result set rather than the documents actually stored, and if the query could return a document the client may not read, the entire request fails.
Its example is a query for every story in a collection, which fails even when the signed-in user wrote every story, and succeeds once it carries where author equals the user's ID, the same constraint as the rule.
The guide says the same rules apply to aggregation queries. A single-document get is different: Firestore reads the document and evaluates the rule against its actual fields.
That difference is why get and list cases fail in different ways. An owner rule can pass every get case and still break the list screen when the app's query lacks the owner constraint. The opposite failure is worse: a list rule written more loosely than the get rule hands out in bulk what get refuses one document at a time.
The query guide shows list rules that also read `request.query`, which holds a query's limit, offset and orderBy, to refuse queries without a limit or above one.
Subcollections, collection groups and overlapping matches
Firestore's structure guide says rules apply only at the matched path, so rules on a collection do not apply to its subcollections, which need rules of their own. Recursive wildcards change behaviour with the rules version: in version 1, the default, they match one or more path items, and in version 2 they match zero or more, and collection group queries require version 2.
The query guide notes that a collection group rule written as `match /{path=**}/posts/{post}` applies to every collection with that ID, wherever it sits.
Where two match statements cover one document, the structure guide says access is allowed if any condition is true. A workbook row that reaches a nested document therefore lists every match block that covers it, not only the one nearest the path.
Field validation: what a Firestore write may contain
Firebase's field-level guide says there are no restrictions at the database level on what fields a document contains or what types they hold.
The rules are where a write's contents can be checked. The guide uses `request.resource.data.keys()` with `hasAll()` to require fields and `hasOnly()` to allow only listed fields on create. For updates it uses `diff()` against the stored document with `affectedKeys()`, because on an update the keys list holds the whole document after the change, unchanged fields included.
It describes listing the fields that may change with `hasOnly()` as generally considered more secure, because a field added to the app later stays unwritable until the rule names it.
Types are checked with the is operator, and the guide says field types need to be enforced when both creating and updating a document. The guide also sets out limits on what rules can do. Reads happen at the document level, so rules alone cannot stop a reader from seeing some fields of a document they may read; the guide suggests moving those fields to a separate document, such as one in a private subcollection.
And a write is accepted or rejected whole, because rules cannot accept some fields of an edit and reject others.
Ownership is a field check as well. Firebase's content-owner example allows a create only when `request.auth.uid` matches the owner field of the new document, and an update only when it matches both before and after the change, so ownership cannot be handed to another account.
Rules can check a role kept in another document with `get()` and `exists()`, as Firestore's conditions guide shows. That guide says using these functions executes a read operation you are billed for even if the rules reject the request, and the structure guide limits single-document and query requests to 10 of these calls.
Whoever can write the role document decides what the lookup grants, so the workbook tests that document's own rules too.
Email checks need care. Firestore's guide to insecure rules warns that emails are not always verified during sign-in until the user acts on a verification email, and shows a domain rule that also checks `request.auth.email_verified`. Firebase's security checklist adds that anyone could create an anonymous account in your project, and advises protecting all non-public data with rules that require specific sign-in methods or verified email addresses.
Both are reasons the workbook treats a signed-in account that owns nothing as a caller in its own right.
Realtime Database read and write rules cascade from the top
Firebase's core syntax guide says the structure of Realtime Database rules should follow the structure of the stored data, with `.read`, `.write` and `.validate` rules set on the nodes they secure, and that if no `.read` or `.write` rule is specified at or above a path, access is denied.
It says read and write rules work from the top down: a rule that grants access at a path also grants it to every child node, shallower rules override deeper ones, and a child rule cannot revoke a privilege a parent granted. A `.read` or `.write` rule that is true at the root or at a users node therefore grants that access to everything beneath it, whatever the child rules say. Firebase's guide to insecure rules lists refining access at child paths as "(Realtime Database) Improperly inherited rules".
Reads do not filter here either. The core syntax guide says rules are applied atomically: a read at a parent path fails if no rule at that location or above it grants access, even when every child path is readable. Firebase's conditions guide says that although rules cannot be used as filters, access to subsets of data can be limited with query parameters in the rules.
Its baskets example has a read rule that requires `query.orderByChild` to be the owner child and `query.equalTo` to be `auth.uid`, and it says a query that does not include those parameters fails with a PermissionDenied error.
The guide says query-based rules can also limit how much data a client downloads, with a rule on `query.limitToFirst` as its example.
Validation works differently, because `.validate` rules do not cascade. Firebase says every `.validate` rule at every level must pass for a write to be allowed, that validation runs only after a `.write` rule has granted access, and that validate definitions are ignored when data is deleted, when the new value being written is null.
No validate rule therefore checks a removal, which is why the workbook has a separate check for it. Children that should never appear can be refused with a `$other` wildcard whose validate rule is false, as the core syntax guide shows.
Firebase's overview and its Realtime Database guide describe overlapping rules differently
Firebase's Security Rules overview says rules are applied as OR statements, so any matching rule that grants access wins. The Realtime Database core syntax guide, in its section on overlapping statements, says that where more than one rule expression identifies a node, the access method is denied if any of the conditions is false, and its example places a `$message` wildcard beside a named message1 child.
This page does not choose between them. Where your rules put a named child beside a wildcard sibling, run that case in the Rules Playground or the emulator and record what it returns.
Cloud Storage rules: paths, sizes and types
Cloud Storage rules match file names.
Firebase's Storage guide notes that buckets hold only files, not directories, and that slashes in file names only suggest folders. It says Storage rules do not cascade and are evaluated only when the request path matches a path with rules specified, and that where several rules match a file the result is the OR of all of them.
A read rule can be broken into get and list, and a write rule into create, which applies to writes to file contents, update, which applies to updates to pre-existing file metadata, and delete.
List rules, and with them the Storage List API, are only available in projects that use rules version 2. The guide also says rules are not filters: a listAll request fails if it could return a file the caller may not read.
Firebase's Storage conditions guide describes a user-private pattern that puts the user's ID in the file name prefix and compares `request.auth.uid` with it, and says any rule that does not consider `request.auth` can be considered a public rule.
Upload rules can check `request.resource`, which the guide says holds a subset of the metadata to be written, including the new file's size, content type and custom metadata, and Firebase's own example allows only image files under a size limit.
What the server stores and serves once an upload has passed the rules is a separate question, covered by the file upload security guide.
Storage rules can read Firestore through `firestore.get()` and `firestore.exists()`. Firebase says those reads count towards the project's Firestore quota and billing, that no more than two Firestore documents may be accessed in one evaluation, and that Storage rules can only read the default database when several are active.
Saving the first such rule prompts you to enable permissions that connect Storage and Firestore, and Firebase's deploy guide says that once this is enabled, the "Firebase Rules Firestore Service Agent" role appears on the Firebase Storage service account on the IAM page.
Firebase's guide to insecure rules also notes that with Storage rules that deny everything, files may still be accessible through App Engine or Google Cloud Storage APIs.
App Check: evidence about the app, not the user
Firebase describes App Check as helping protect app backends from abuse by preventing unauthorised clients from accessing backend resources.
Devices running the app obtain an attestation that requests come from the authentic app, from an untampered device, or both, and once enforcement is on for a product, requests without a valid attestation are rejected. Cloud Firestore, Realtime Database and Cloud Storage for Firebase are among the services Firebase lists as supported.
Firebase is plain about its reach. Its App Check overview says App Check relies on the strength of its attestation providers and prevents some, but not all, abuse vectors, and calls it complementary to Firebase Authentication: Authentication protects your users, App Check protects you, the developer.
Firebase's API keys page divides the work the same way, with Security Rules controlling which end users can access resources and App Check controlling which apps can. Firebase's security checklist lists enabling App Check for every service that supports it under avoiding abusive traffic.
This page reads those statements as making App Check an addition to the rules, not a replacement for them. Firebase's overview says the App Check client SDK caches its token in your app, ready to be sent with any request your app makes to protected services. On this page's reading, a user signed in to your genuine app can therefore carry valid tokens, and whether that user may read another user's document is still for the rules to decide.
The workbook records App Check as evidence about which apps reach each product, and leaves ownership questions to its other rows.
Reading enforcement without changing it
Firebase says enforcement is switched on from Security > App Check in the Firebase console, that once it is on all unverified requests to that product are rejected, and that it can take up to 15 minutes to take effect. Enforcing is a change to the project, so the workbook only reads its state.
Before enforcing, Firebase says you should make sure enforcement won't disrupt existing legitimate users, and names the request metrics on the Security > App Check > APIs tab as an important tool for that decision. The metrics sort requests into categories including "Verified requests", "Outdated client requests", "Unknown origin requests" and "Invalid requests".
It says unknown origin requests might be using stolen API keys or be forged requests, and that enforcing on a released app will break earlier app versions that do not include the App Check SDK.
How to run the rules test workbook
Run the workbook on a copy of the app that holds only invented data.
Firebase's security checklist recommends separate Firebase projects for development, staging and production, and Firebase's deploy guide says the Rules Playground tests rules using your project's database and storage resources. The staging project is therefore the one to open. Simulated requests run in the Rules Playground, or in Firestore's Google Cloud console simulator where row F9 says.
List and query cases run in the Local Emulator Suite, because the documented options of the Rules Playground and of Firestore's simulator in the Google Cloud console name no list or query operation: Firebase's Playground page describes testing reads or writes at a specific location, and Firestore's guide gives the Google Cloud console simulator's operation types as get, create, update and delete.
Upload cases run in the emulator too, with small invented files.
Row K1 starts from your own server code, and any requests it sends go only to your own staging copy. No case sends requests from your app to your production project.
- Set up the four callers first. Unauthenticated means no sign-in. Signed in, owns nothing is a test account with no records, such as an anonymous sign-in or a fresh test sign-up. Owner is test user A and other user is test user B, each holding invented records of the same kind. Record each user ID with its label, never a password.
- The expected results assume owner-only data. Where a path is meant to be public or shared by a team, write your intended result over the workbook's before you run anything, so a pass means what you meant and not what the rule happens to do.
- In the console, open the product's Rules tab and then the Rules Playground. Firestore's guide says simulated requests run against the ruleset in your editor, not the deployed ruleset, so leave the editor unchanged and never click Publish during a review.
- Firebase's guide to insecure rules says the console always shows the most recently deployed version of your rules. Compare it with the rules files your repository's firebase.json names before trusting either, because a CLI deploy overwrites rules edited in the console.
- For each case record the expected result, the actual result, the rule block you believe decided it and the date. Write "not used" for a product the app does not use, because a blank cell reads as unchecked.
- Record that a key, token or service account key exists and where it is used. Never copy a value into the workbook, and do not reveal a key in a console screen to read it.
- Repeat the workbook after any change to rules, data shape or sign-in methods. Firestore's guide says rule updates can take up to a minute to affect new queries and listeners, and up to 10 minutes to fully propagate and affect active listeners, and Firebase's deploy guide says rule releases take several minutes to fully propagate. Leave that time after a deploy to staging before you run the cases again.
Turning the cases into emulator regression tests
The steps below are described from Firebase's documentation.
They were not run for this page: the emulator needs installs this review did not make, so the page shows no emulator output. The test names and commands are Firebase's; the mapping onto the workbook is this page's.
Firebase's install guide lists Node.js 16.0 or higher, Java JDK 11 or higher and Firebase CLI 8.14.0 or higher, and sets the emulators up with `firebase init emulators`. The emulators read each product's rules file from the database, firestore and storage keys in firebase.json, and the guide warns that if those settings are not configured, the Firestore, Realtime Database and Cloud Storage emulators run with open data security.
A suite that only asserts successes would pass against open rules, so every suite needs cases that must fail, and the first of them should be the unauthenticated read of A's record.
The rules unit testing library, @firebase/rules-unit-testing, maps onto the workbook's caller columns. Firebase's unit testing guide describes `initializeTestEnvironment` to create the test environment, which its example gives the Firestore rules file, `withSecurityRulesDisabled` to seed invented records without triggering them, `unauthenticatedContext` for a signed-out caller, `authenticatedContext` with a user ID, and optional token overrides, for each signed-in caller, and `assertSucceeds` and `assertFails` to state each expected result.
It says the version 9 library is always aware of the emulators and never touches production resources, and that the emulators keep data between tests on a single run unless it is cleared.
For a pipeline, the install guide describes `firebase emulators:exec`, which starts the configured emulators, runs a script and stops them when the script ends, and calls it generally more appropriate for continuous integration. Firebase's security checklist recommends unit testing rules with the Local Emulator Suite and adding the tests to your CI pipeline.
After a Firestore suite has run, and while the emulator is still running, it serves a coverage report showing how each rule was evaluated, and the Emulator Suite UI traces each request's rule evaluation in its Firestore Requests tab.
Firebase's emulator overview also says an app will still continue to communicate with production Firebase services when emulators are not available or configured. A test that connects the app itself, rather than the testing library, should therefore confirm where it points before it writes anything.
What the workbook cannot show about your project
The workbook tests the rules as written against the cases you thought of.
Its rules rows say nothing about server code, because Firestore's server client libraries bypass its rules and an Admin SDK instance with an Editor-role service account has complete access to the Realtime Database. Row K1 lists where that code runs and what each endpoint should refuse, and an API route or Cloud Function that reads data on a user's behalf still needs testing as an endpoint of its own.
It does not show whether App Check attestation can be defeated, which Firebase ties to the strength of its attestation providers. And it cannot see a collection, path or bucket that nobody listed in the set-up row.
Simulations and emulators are models of the deployed project. Firebase's unit testing guide lists differences between its database emulators and production, including that each emulated database applies the Spark plan limits and quotas and accepts the string "owner" as an admin auth token.
A pass in the emulator is evidence about the rules file that was loaded. Firestore's guide says its simulated requests run against the ruleset in the editor. A pass in Firestore's Rules Playground is therefore evidence about that ruleset at that moment.
It is also a snapshot. Rules change with every deploy, and Firebase's deploy guide says rule releases take several minutes to fully propagate. Date every copy, keep the rules file commit beside it, and treat a workbook older than the last deploy as a starting point for the next one.
Firebase's terms, read before any active test
Firebase's terms page, last modified on 24 September 2026 when this page read it on 15 November 2026, lists the terms that apply to each service.
It lists Cloud Firestore, Cloud Storage for Firebase, Firebase App Check and Firebase Authentication, among other services, under the Google Cloud Platform Terms of Service, and Firebase Realtime Database under the Google APIs Terms of Service, with the Firebase Data Processing and Security Terms and the Firebase Paid Services Agreement.
Nothing on this page says what those terms let a customer test. For that reason the workbook's rules cases stay inside your own console and the emulator, and row K1 sends requests, if any, only to your own staging copy of your own API.
Anything beyond it, such as sending crafted requests to a live project, starts with reading the terms that apply to each product on the day and, where they leave doubt, getting Google's answer in writing.
Where a Clever Ops check or test fits
This guide is informational.
Clever Ops does not test Firebase's platform: services run by other businesses sit outside the Clever Ops method.
Your own app is a different matter. If an AI builder made it on Firebase, the vibe-coded app security check is the service that fits. Its focus is data exposure, authentication, secrets, payments and abuse, and database rules that let one user read another user's data are on that list.
Its tests go straight at the database rules and the keys, and its report is written in plain English for a non-technical builder. Where the app is a custom application with its own API, the web application and API penetration test covers, from signed-in test accounts, what each role can see and change, whether one customer can reach another customer's records, and the API called directly as well as through the screens.
Either way, active testing of your own application happens inside a scoped assessment: the scope asks for two test accounts per role, and the hosting provider's testing policy for each target is checked before the first request.
A completed workbook is useful scoping material, because it already lists the collections, paths and buckets, the callers and the cases you have confirmed. If the app is one Clever Ops built or hosts, the engagement runs as a security review instead of an independent test, with the builder and the host named in the report.
Clever Ops is not CREST accredited, so if a tender requires a CREST-accredited provider, we refer that work to a provider that is. Clever Ops does not provide emergency incident response: if data may already have been exposed, call an incident response specialist first.
Frequently asked questions
This page gives no verdict on that. Firebase's own pages describe a division of work instead. Its API keys page says API keys for Firebase services are not used to control access to backend resources, and that this can only be done with Firebase Security Rules, which control which end users can access resources, and Firebase App Check, which controls which apps can. Firebase evaluates the rules, and the developer writes them. Its checklist advises starting from rules that deny all access by default and adding rules that grant access to specific resources as the app is built, and the workbook on this page tests what those rules grant.
Firebase says not, with a condition. Its security checklist heads the section "API keys for Firebase services are not secret", and its API keys page says that if an app's setup follows the guidelines it lists, keys restricted to Firebase services do not need to be treated as secrets. The same pages draw lines elsewhere: the key an app uses for the Gemini Developer API should never be included in code or configuration files, and service account private keys and FCM server keys are sensitive and must be kept secret.
Because Firestore rules are not filters. Firebase's query guide says a query is evaluated against its potential result set, not the documents stored, and fails whole if it could return any document the client may not read. Its own example fails a query for a whole collection even when the user wrote every document, and passes once the query carries the same owner constraint as the rule.
Firebase's own pages give the two different jobs. Its API keys page gives rules the job of controlling which end users can access resources and App Check the job of controlling which apps can, and its App Check overview says App Check prevents some, but not all, abuse vectors. The overview also says the App Check client SDK caches its token in your app, ready to be sent with any request your app makes to protected services. On this page's reading, a user signed in to your genuine app can therefore carry valid tokens, and the rules are still what decide whether that user may read another user's data.
Not by taking away a read or write privilege a parent has granted. Firebase's core syntax guide says read and write rules cascade from the top down, that a rule granting access at a path grants it to every child node, and that child rules can only add privileges, never revoke them. Validate rules are the exception: they do not cascade, every one must pass for a write, and Firebase says they are ignored when data is deleted.
Firestore's guides say the server client libraries bypass all Cloud Firestore Security Rules and authenticate through Google Application Default Credentials. The Realtime Database Admin SDK guide says an Admin SDK instance using a service account with the Editor role has complete read and write access to the database, and the same guide says the Admin SDK can instead read and write with finer-grained limited privileges. Server code and Cloud Functions that act for a user therefore need their own ownership checks, tested as part of your API.
Scope the right test for your application
Tell us what you have built, who uses it and when it needs to launch. You will get a plain-English recommendation: a website audit, a web application test or a referral to a specialist.