My own security agents found my Firestore data open to the internet. Here's how to check yours.
Disclosure: I built RedSuture, the tool that found this. Everything below works without it. I build an AI chatbot for websites, and I built a security tool on the side. Before asking anyone to trust that tool with their
Disclosure: I built RedSuture, the tool that found this. Everything below works without it.
I build an AI chatbot for websites, and I built a security tool on the side. Before asking anyone to trust that tool with their app, I ran it against my own.
About 20 minutes in, it reported a high-severity finding: two of my Firestore collections could be read by anyone, without signing in.
Every screen in my app worked. Signed-in users only ever saw their own data. But anyone who skipped the app and talked to Firestore directly could read everything in those two collections.
Here's the full run if you want to watch it (2 minutes):
{https://youtu.be/Bvg-WZNJAE4}
If your app uses Firestore, here's how to check yours in about 10 minutes.
⚠️ Only run these checks against Firebase projects you own.
Why this happens to so many Firebase apps
Your Firebase web config ships to every visitor's browser:
const firebaseConfig = {
apiKey: "AIza...",
projectId: "your-app",
// ...
};
That's fine, because Google designed it to be public. But it also means anyone can query your database directly, without ever loading your app's screens.
Your security rules are the only thing standing between the internet and your data. Three patterns cause most leaks:
// 1. Test-mode rules that were never replaced
allow read, write: if request.time < timestamp.date(2027, 1, 1);
// 2. A "just make it work" fix that stayed
allow read: if true;
// 3. "Signed in" treated as "allowed to see everything"
allow read: if request.auth != null;
Number 3 is the sneaky one. Anyone can create an account in your app, so request.auth != null lets any stranger with an account read every user's data.
Step 1: Read your rules
Open Firebase console → Firestore Database → Rules and search for:
if true
request.time <
a broad match /{document=**} that allows reads
per-user collections that only check request.auth != null
Step 2: Test as a stranger in the Rules Playground
On the Rules page, open Rules Playground:
Choose get (one document) or list (a whole collection).
Enter a path, such as /orders/anyId.
Leave Authenticated switched off.
Click Run.
If the result is Allowed on anything private, that collection is exposed.
Step 3: Confirm from outside
The Playground shows what your rules say. This shows what the internet actually gets:
curl "https://firestore.googleapis.com/v1/projects/YOUR_PROJECT_ID/databases/(default)/documents/COLLECTION_NAME"
✅ PERMISSION_DENIED is what you want.
❌ If you get back a JSON list of documents, they're public right now.
Run it once for every collection your app uses.
Step 4: Fix it with deny-by-default rules
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Each user can read and write only their own profile
match /users/{userId} {
allow read, write: if request.auth != null
&& request.auth.uid == userId;
}
// Documents that belong to a user carry an ownerId
match /orders/{orderId} {
allow read: if request.auth != null
&& resource.data.ownerId == request.auth.uid;
allow create: if request.auth != null
&& request.resource.data.ownerId == request.auth.uid;
}
// Anything not matched above is denied
}
}
Two gotchas:
Rules are not filters. Your query has to ask only for documents the user is allowed to read. Otherwise Firestore rejects the whole query:
// ❌ rejected: asks for every order
getDocs(collection(db, "orders"));
// ✅ allowed: matches the rule
getDocs(query(collection(db, "orders"), where("ownerId", "==", user.uid)));
Data your server reads doesn't need an open rule. The Admin SDK skips the rules, so collections that only your backend reads can be fully closed:
match /internal/{doc} {
allow read, write: if false;
}
Deploy:
firebase deploy --only firestore:rules
Then run the curl from Step 3 again and confirm you get PERMISSION_DENIED.
Step 5: Keep it from coming back
Test your rules in CI with the emulator and @firebase/rules-unit-testing:
import { initializeTestEnvironment, assertFails } from "@firebase/rules-unit-testing";
import { readFileSync } from "node:fs";
import { doc, getDoc } from "firebase/firestore";
const env = await initializeTestEnvironment({
projectId: "demo-test",
firestore: { rules: readFileSync("firestore.rules", "utf8") },
});
test("signed-out users can't read orders", async () => {
const db = env.unauthenticatedContext().firestore();
await assertFails(getDoc(doc(db, "orders/any")));
});
Add one test like this for each collection. New features are where open rules usually creep back in.
What I took away
"It works" doesn't mean "it's safe." The bug lived in a place no user ever sees.
Proof changes how you react. The finding came with the exact request that read my data, so it went to the top of my list instead of into the backlog.
Rules are only one layer. Access control, sign-in, and business-logic bugs live in your API too, and those are harder to check by hand.
If you'd like the whole app tested the way an attacker would, RedSuture's agents cover sign-in, access control, injection, business logic, and open databases like this one. Every finding is reproduced in a sandbox before it's reported. Your first Standard scan is free at redsuture.com, and there's a sample report from a real scan.
Have you found open rules in a project before? I'd like to hear how you caught them. 👇
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.