Rules that allow too much
- allow read, write: if true is the 'open' ruleset Firebase's guidance says never to use in production.
- Test-mode rules, offered when a database is created, grant access to everyone until an expiry date and are sometimes extended rather than replaced.
- if request.auth != null only checks that the caller is signed in; with open sign-up, that is anyone.
- Rules on a parent path in the Realtime Database cascade to all children, so a broad read at the root overrides narrower rules below.
Data model and query issues
Firestore rules are not filters: a rule must allow the whole query, but if a rule allows listing a collection, the client can fetch every document in it. Documents that mix public profile fields with private ones such as email or role cannot be partially protected, so private fields should live in a separate document. Rules that let users update their own document often forget to stop them changing a role or plan field.
Storage, Functions and Auth
- Cloud Storage rules that allow read on a whole bucket expose every user's uploads.
- HTTPS-triggered Cloud Functions are public URLs; callable functions need explicit context.auth checks and should validate input.
- Custom claims are the right place for roles; storing them in a user-writable document is not.
- App Check reduces abuse from unofficial clients but is not a substitute for rules.
Testing a Firebase app with Pentest-Swarm
Pentest-Swarm tests a Firebase-backed app from the outside, through the same HTTP APIs your client uses. It does not read your rules files or your Google Cloud project.
- Use
--browserso recon renders the app and records the Firestore, Realtime Database, Storage and Functions requests it makes. - Set scope to your app domain and the specific Firebase hosts your project uses, so testing never strays to other projects.
- Supply an ID token for a test user with
--authto test whether one user can read or change another's documents. - Use the api-security playbook for HTTPS Cloud Functions that act as your API.
Where it falls short
A black-box test can only probe the paths it discovers or can infer, and Firestore collection names are not always guessable. Firebase's Rules emulator and unit tests are the right tool for exhaustively checking rule logic; a live test confirms that the deployed rules behave as those tests claim.
Questions
Is my Firebase API key a secret?
No. Firebase API keys identify the project and are expected to be in client code. Restrict them to the APIs you use and rely on Security Rules and App Check for protection.
How do I know if my Firestore rules are open?
Check the rules in the console for if true or expired test-mode rules, then try an unauthenticated read and a cross-user read against the deployed project.
Do Firebase rules apply to Cloud Functions?
No. Functions use the Admin SDK, which bypasses Security Rules, so each function must enforce its own authorisation.