[{"data":1,"prerenderedAt":20},["ShallowReactive",2],{"fix-permissive-firebase-rules":3},{"id":4,"slug":5,"title":6,"description":7,"bucket":8,"severity":9,"status":10,"publishedAt":11,"summary":12,"affectedCheck":13,"fixSteps":14,"agenticPrompt":15,"references":16},"fix-permissive-firebase-rules","permissive-firebase-rules","Your Firebase or Firestore rules let anyone read your database","Default or test mode security rules leave your whole database world readable, and the client SDK keys are public by design. Here is how to check your rules and lock them down.","NEW_VULNERABILITY","critical","published","2026-11-23T09:20:00.000Z","\u003Cp>Backend as a service platforms move authorisation out of your server and into a rules file. That is a real advantage, right up until the rules are wrong, because there is no server in between to catch the mistake.\u003C\u002Fp>\n\u003Cp>The configuration your app ships, the project identifier and the client API key, is public by design and visible in your JavaScript bundle. That is expected and is not itself the problem. The rules are the only thing standing between a visitor and your data.\u003C\u002Fp>\n\u003Cp>The common failure is starting a project in test mode, which allows open read and write access so you can build quickly, and then shipping before tightening it. A second failure is a rule that checks only that somebody is signed in, without checking \u003Cem>which\u003C\u002Fem> user they are, so any authenticated account can read every record. Either way the result is a database that answers questions for anyone who asks.\u003C\u002Fp>","\u003Cp>Open your project's rules in the Firebase console and read them. Two patterns are immediate problems.\u003C\u002Fp>\n\u003Cp>Open access, usually left over from test mode:\u003C\u002Fp>\n\u003Cpre>allow read, write: if true;\u003C\u002Fpre>\n\u003Cp>Signed in but unrestricted, which lets any account read everyone's records:\u003C\u002Fp>\n\u003Cpre>allow read: if request.auth != null;\u003C\u002Fpre>\n\u003Cp>The console's Rules Playground will simulate a read as an unauthenticated user against a specific document path, which is the quickest way to confirm what a stranger can actually do. Check the expiry date too: test mode rules are commonly written as a date comparison that has already lapsed, which fails closed, or is still open.\u003C\u002Fp>\n\u003Cp>If your rules allow unauthenticated reads of collections holding user data, treat that data as already retrieved.\u003C\u002Fp>","\u003Ch3>1. Close open access immediately\u003C\u002Fh3>\n\u003Cp>Replace any \u003Ccode>if true\u003C\u002Fcode> rule. Start from deny by default and grant only what a specific path genuinely needs.\u003C\u002Fp>\n\u003Ch3>2. Scope every rule to the owning user\u003C\u002Fh3>\n\u003Cp>Checking that a request is authenticated is not authorisation. Compare the signed in user against the record's owner, for example:\u003C\u002Fp>\n\u003Cpre>match \u002Fusers\u002F{userId} {\n  allow read, write: if request.auth != null\n    &amp;&amp; request.auth.uid == userId;\n}\u003C\u002Fpre>\n\u003Ch3>3. Validate writes, not just reads\u003C\u002Fh3>\n\u003Cp>Rules decide what a client may write as well as read. Constrain the shape and the values of incoming data so a client cannot set fields it should not control, such as a role, a balance or a flag that grants privileges.\u003C\u002Fp>\n\u003Ch3>4. Keep privileged work on the server\u003C\u002Fh3>\n\u003Cp>Anything that must not be client decided belongs in a server context with the admin SDK, behind your own endpoint. Rules protect client access, they do not make a privileged operation safe to expose.\u003C\u002Fp>\n\u003Ch3>5. Test the rules, then keep testing them\u003C\u002Fh3>\n\u003Cp>Use the emulator and the rules unit testing library to assert both what is allowed and what is refused. Rules are code, and untested rules drift. Add these to your normal test run so a future change cannot quietly reopen access.\u003C\u002Fp>\n\u003Ch3>6. Assume disclosure and act on it\u003C\u002Fh3>\n\u003Cp>If personal data was readable, you may have notification duties under the data protection law that applies to you. Decide that deliberately rather than by omission.\u003C\u002Fp>","You are helping me audit and fix the security rules on a backend as a service database for an app I own and operate.\n\nProblem: my Firebase, Firestore or Realtime Database rules may allow public or over broad access to data.\n\nWork through the following in order, and confirm with me before applying any rules change.\n\n1. Find the rules files in this repository (for example firestore.rules, storage.rules, database.rules.json) and the project configuration. If they are not in the repository, tell me and explain how to export them from the console.\n2. Read every rule and list each match path with the access it grants and the conditions attached.\n3. Flag every rule matching a dangerous pattern, and explain the practical consequence of each in plain language:\n   - allow read, write: if true\n   - any condition that only checks request.auth != null without comparing identity to the record owner\n   - a test mode timestamp condition, noting whether it has expired\n   - wildcard recursive matches that grant more than the specific path needs\n4. For each collection, tell me what data it holds and who should be able to read and write it. Ask me where you cannot tell from the code.\n5. Rewrite the rules to deny by default and grant least privilege, scoping each rule to the owning user, and validating the shape and values of writes so a client cannot set privileged fields. Show me the full proposed rules file before anything is applied.\n6. Identify any operation that the client should not be allowed to decide, and propose moving it to a server side function using the admin SDK behind my own endpoint.\n7. Write rules unit tests using the emulator and the rules testing library, asserting both the allowed and the denied cases, including an unauthenticated read of every sensitive collection. Wire them into the project's existing test command.\n8. Tell me plainly which collections were readable without authentication, so I can assess whether personal data was exposed and whether I have a notification duty.\n\nDo not print any record contents or personal data. Finish with the proposed rules, the tests, and an ordered list of what I must do by hand.",[17],{"label":18,"href":19},"Firebase: Security Rules","https:\u002F\u002Ffirebase.google.com\u002Fdocs\u002Frules",1795449486791]