caelo

Caelo › Guides › Check your Firebase security rules

How to check your Firebase security rules are not open (test mode)

By Arthi Arumugam, Irth Labs · Published · Updated

Short answerOpen the Rules tab for Firestore, Realtime Database and Storage in your Firebase console. If any rule says allow read, write: if true (in Realtime Database: ".read": true or ".write": true), or allows access until a date (test mode), your data is open to anyone with your project's public config. Replace it with rules that require request.auth and check that the signed-in user owns the document, then test with the Rules Playground as a signed-out user and as a second user.

What are the red flags in your rules?

  • allow read, write: if true; means anyone, signed in or not.
  • allow read, write: if request.time < timestamp.date(...); is test mode. It is open to everyone until that date.
  • allow read, write: if request.auth != null; means any signed-up user can read and change everyone's data.
  • Storage rules left in test mode, so anyone can read or overwrite every uploaded file.
  • In Realtime Database the same mistake is written in JSON: ".read": true or ".write": true at the top of the rules.

What does a safer rule look like?

For a collection where each document belongs to one user, the rule should compare the signed-in user to the document's owner, for example: allow read, write: if request.auth != null && request.auth.uid == resource.data.ownerId; and on create, check request.resource.data.ownerId instead.

Fields such as role, plan, price or paid should not be writable by the user at all. Change them only from a server function.

Test it

  1. In the Firebase console, open Rules, then the Rules Playground.
  2. Simulate a read of another user's document while signed out. It should be denied.
  3. Simulate the same read as a different signed-in user. It should be denied.
  4. Simulate a write that changes a role or price field. It should be denied.

1. Run the free local check

npx caelo .

Caelo is a free, open source (MIT) command line tool and MCP server from Irth Labs that checks the files of an AI-built app for exposed API keys, Supabase and Firebase misconfigurations and .env files with real values. It runs on your machine, uploads nothing and uses no AI model. Each finding comes with a plain-English fix.

2. Act on a finding

Follow the fix in your report and run Caelo again. If Git could commit an untracked file containing secrets, preview a US$19 quick fix for that file.

For findings that need an engineer, Irth Labs offers a US$490 App Health Check. You receive a written report within 48 hours and a fixed repair quote. The fee counts toward the repair if you proceed.

Book the App Health Check See repair services

Questions

Is the Firebase config (apiKey) in my app a secret?

No. The Firebase web config, including apiKey, is public by design. Your security rules are what protect your data.

My app was built with an AI tool. Does it use Firebase?

Some AI builders use Firebase, many use Supabase. Check your project settings or code for firebase or supabase imports. The same principle applies to both: database rules are the lock.

What if I need admin access?

Use the Firebase Admin SDK from a server or Cloud Function. It bypasses rules, so its credentials must never be in client code.

Can a scanner find open Firebase rules for me?

For Firestore rules files, partly. Caelo (npx caelo .) reads the rules files in your project folder and flags allow rules with no condition (if true, or a bare allow read, write;) and Realtime Database JSON rules set to true. It does not flag rules that expire on a test-mode date. It cannot see rules that exist only in the Firebase console, so read the Rules tab yourself as well.

Sources