Skip to content
Database access

Firebase security rules allow if true: how to fix it

An unconditional allow rule grants the covered operation without checking the caller. Replace unintended public access with rules matching ownership or membership, then test both denied callers and legitimate users.

Check your app free, first fix free
By Brennan ZamboUpdated
In short

First identify whether the rule belongs to Firestore, Realtime Database or Storage; their rule languages and data paths differ. Do not paste one service's syntax into another. For private records, test anonymous, owner and non-owner access with synthetic data. Keep intentionally public data separate and never infer complete safety from a single denied request.

Identify which Firebase service is involved

Firestore rules, Realtime Database rules and Cloud Storage rules are not interchangeable. Read the actual failing or exposed path and the service it belongs to before editing anything. An example for Firestore documents will not repair a Realtime Database JSON rule, and a database rule does not automatically protect stored files.

Find broad wildcard matches as well as the rule nearest the collection. A narrow rule that looks correct may not constrain a separate permissive match. Review the effective access pattern rather than assuming that adding one owner condition cancels every other permission.

Model an owner-only document explicitly

This Firestore example illustrates a private document whose owner is set at creation. Adapt the collection and fields on staging, and review all other matches before deployment.

text
rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /notes/{noteId} {
      allow create: if request.auth != null
        && request.resource.data.ownerId == request.auth.uid;
      allow read, delete: if request.auth != null
        && resource.data.ownerId == request.auth.uid;
      allow update: if request.auth != null
        && resource.data.ownerId == request.auth.uid
        && request.resource.data.ownerId == resource.data.ownerId;
    }
  }
}

The update condition prevents a caller from changing the owner through that path. It is not a complete schema validator, administrator policy or team-sharing design. Add field and operation constraints required by the product instead of interpreting this small example as a full ruleset.

Use the emulator or a dedicated test project

Create a synthetic note as account A. Confirm A can perform the intended operation. Then check account B and an unauthenticated caller against that known path. Test creates, updates and deletes individually; a passing read case says nothing about whether somebody can overwrite a record.

Include malformed writes and ownership changes in the negative tests. Also verify query behavior through the actual application query, because a rule that seems reasonable at a single-document path may not permit the query your interface uses.

Keep server credentials out of the browser

Firebase client configuration often contains public identifiers. An administrator service-account credential is a different category. If a private key or service-account credential shipped publicly, revoke the affected credential and review the privileged server paths. Changing client security rules does not revoke a downloaded administrator key.

Interpret a public scan's limits

An outside tool cannot infer every collection or authenticated permission. ProofForge avoids requesting customer document contents and uses supported count-only or limited public signals where available. If a response or project binding cannot establish access safely, the result stays inconclusive rather than becoming a green check.

Turn the check into a release decision

Keep a small record of the production URL, the time you checked it, the exact finding and the action you took. A local preview and a deployed application can have different environment variables, response headers and database projects. After a repair, deploy the intended version and check the public address again. Do not assume that changing a repository file changed the live system.

Read coverage as carefully as the score. A timed-out asset, an ambiguous backend configuration or a request that could not safely establish access should remain unknown. It should not disappear from your release notes merely because there is no red finding. If a check was not completed, decide who will review it and what additional evidence is needed.

ProofForge's free report includes the first fix. The $9 Fix Report unlocks all findings' available repair guidance and builder prompts, with a PDF and private report link. Fix + Guard costs $29 once and adds builder rules, on-demand deploy-hook scans for 30 days and four weekly rechecks you start yourself. These are different deliverables, not different promises that an application is completely secure.

Keep private report URLs out of public issues and commits. If you need shareable evidence, use the owner-verification and publication flow for an eligible receipt. A signature protects the recorded assessment against undetected changes; it does not make the assessment exhaustive, prove a business outcome, or show that a later deployment still matches an earlier result.

Questions builders ask

Is allow read: if true always a vulnerability?
It is appropriate only where the product intentionally publishes that data. It is a problem when it grants public access to information meant to be private.
Can I reuse Firestore rules for Storage?
No. Each service has its own paths and rules model. Review the actual service documentation and test its operations.
Does an Admin SDK key follow client Security Rules?
Privileged server credentials have a different access model. Keep them off the browser and authorize the server operations that use them.

Continue with a related guide

Sources

Read-only, about a minute

Scan your app free

See what your live app ships to every visitor, with the first fix free. A clean scan is not a full audit. Run it only on an app you own or have permission to test.

Scan your app free
All guides