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

Canonical: https://caelo.sh/guides/firebase-security-rules-check
Published: 2026-11-25 · Updated: 2026-11-27 · Arthi Arumugam, Caelo by Irth Labs

**Short answer:** Open 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.

## Check your own app

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. Follow the fix in the report and rerun Caelo. For an untracked, unignored file containing secrets, preview the US$19 quick fix. https://caelo.sh/fix
3. For an engineer's assessment, book the US$490 App Health Check. Irth Labs delivers a report and fixed repair quote, with credit toward the repair. https://www.irthlabs.com/start?service=app-health-check

## 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

- [Firebase docs: Get started with Cloud Firestore Security Rules.](https://firebase.google.com/docs/firestore/security/get-started)
- [Firebase docs: Fix insecure rules.](https://firebase.google.com/docs/rules/insecure-rules)
- [Firebase docs: Test rules with the Rules Playground.](https://firebase.google.com/docs/rules/simulator)
- [Firebase docs: API keys for Firebase.](https://firebase.google.com/docs/projects/api-keys)

## Related guides

- [Security checklist for apps built with Lovable, Bolt, Cursor, Replit or v0](https://caelo.sh/guides/vibe-coded-app-security-checklist)
- [I leaked an API key or the Supabase service_role key. What do I do now?](https://caelo.sh/guides/leaked-api-key-what-to-do)
- [How to check your Supabase row level security is actually working](https://caelo.sh/guides/supabase-rls-check)
- [Firebase says your security rules are insecure: how to fix test mode rules](https://caelo.sh/guides/firebase-insecure-rules-alert-fix)
