<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: NextAI Studios Limited</title>
    <description>The latest articles on DEV Community by NextAI Studios Limited (@nextaistudios).</description>
    <link>https://dev.to/nextaistudios</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4266140%2Fdf2caa1a-9f45-4efb-ad46-ca90845617b6.gif</url>
      <title>DEV Community: NextAI Studios Limited</title>
      <link>https://dev.to/nextaistudios</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nextaistudios"/>
    <language>en</language>
    <item>
      <title>My own security agents found my Firestore data open to the internet. Here's how to check yours.</title>
      <dc:creator>NextAI Studios Limited</dc:creator>
      <pubDate>Thu, 26 Nov 2026 07:21:24 +0000</pubDate>
      <link>https://dev.to/nextaistudios/my-own-security-agents-found-my-firestore-data-open-to-the-internet-heres-how-to-check-yours-4b4h</link>
      <guid>https://dev.to/nextaistudios/my-own-security-agents-found-my-firestore-data-open-to-the-internet-heres-how-to-check-yours-4b4h</guid>
      <description>&lt;p&gt;Disclosure: I built RedSuture, the tool that found this. Everything below works without it.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;About 20 minutes in, it reported a high-severity finding: two of my Firestore collections could be read by anyone, without signing in.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Here's the full run if you want to watch it (2 minutes):&lt;/p&gt;

&lt;p&gt;{&lt;a href="https://youtu.be/Bvg-WZNJAE4" rel="noopener noreferrer"&gt;https://youtu.be/Bvg-WZNJAE4&lt;/a&gt;}&lt;/p&gt;

&lt;p&gt;If your app uses Firestore, here's how to check yours in about 10 minutes.&lt;/p&gt;

&lt;p&gt;⚠️ Only run these checks against Firebase projects you own.&lt;/p&gt;

&lt;p&gt;Why this happens to so many Firebase apps&lt;br&gt;
Your Firebase web config ships to every visitor's browser:&lt;/p&gt;

&lt;p&gt;const firebaseConfig = {&lt;br&gt;
  apiKey: "AIza...",&lt;br&gt;
  projectId: "your-app",&lt;br&gt;
  // ...&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Your security rules are the only thing standing between the internet and your data. Three patterns cause most leaks:&lt;/p&gt;

&lt;p&gt;// 1. Test-mode rules that were never replaced&lt;br&gt;
allow read, write: if request.time &amp;lt; timestamp.date(2027, 1, 1);&lt;/p&gt;

&lt;p&gt;// 2. A "just make it work" fix that stayed&lt;br&gt;
allow read: if true;&lt;/p&gt;

&lt;p&gt;// 3. "Signed in" treated as "allowed to see everything"&lt;br&gt;
allow read: if request.auth != null;&lt;br&gt;
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.&lt;/p&gt;

&lt;p&gt;Step 1: Read your rules&lt;br&gt;
Open Firebase console → Firestore Database → Rules and search for:&lt;/p&gt;

&lt;p&gt;if true&lt;br&gt;
request.time &amp;lt;&lt;br&gt;
a broad match /{document=**} that allows reads&lt;br&gt;
per-user collections that only check request.auth != null&lt;br&gt;
Step 2: Test as a stranger in the Rules Playground&lt;br&gt;
On the Rules page, open Rules Playground:&lt;/p&gt;

&lt;p&gt;Choose get (one document) or list (a whole collection).&lt;br&gt;
Enter a path, such as /orders/anyId.&lt;br&gt;
Leave Authenticated switched off.&lt;br&gt;
Click Run.&lt;br&gt;
If the result is Allowed on anything private, that collection is exposed.&lt;/p&gt;

&lt;p&gt;Step 3: Confirm from outside&lt;br&gt;
The Playground shows what your rules say. This shows what the internet actually gets:&lt;/p&gt;

&lt;p&gt;curl "&lt;a href="https://firestore.googleapis.com/v1/projects/YOUR_PROJECT_ID/databases/(default)/documents/COLLECTION_NAME" rel="noopener noreferrer"&gt;https://firestore.googleapis.com/v1/projects/YOUR_PROJECT_ID/databases/(default)/documents/COLLECTION_NAME&lt;/a&gt;"&lt;br&gt;
✅ PERMISSION_DENIED is what you want.&lt;br&gt;
❌ If you get back a JSON list of documents, they're public right now.&lt;br&gt;
Run it once for every collection your app uses.&lt;/p&gt;

&lt;p&gt;Step 4: Fix it with deny-by-default rules&lt;br&gt;
rules_version = '2';&lt;br&gt;
service cloud.firestore {&lt;br&gt;
  match /databases/{database}/documents {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Each user can read and write only their own profile
match /users/{userId} {
  allow read, write: if request.auth != null
                     &amp;amp;&amp;amp; request.auth.uid == userId;
}

// Documents that belong to a user carry an ownerId
match /orders/{orderId} {
  allow read: if request.auth != null
              &amp;amp;&amp;amp; resource.data.ownerId == request.auth.uid;
  allow create: if request.auth != null
                &amp;amp;&amp;amp; request.resource.data.ownerId == request.auth.uid;
}

// Anything not matched above is denied
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
}&lt;br&gt;
Two gotchas:&lt;/p&gt;

&lt;p&gt;Rules are not filters. Your query has to ask only for documents the user is allowed to read. Otherwise Firestore rejects the whole query:&lt;/p&gt;

&lt;p&gt;// ❌ rejected: asks for every order&lt;br&gt;
getDocs(collection(db, "orders"));&lt;/p&gt;

&lt;p&gt;// ✅ allowed: matches the rule&lt;br&gt;
getDocs(query(collection(db, "orders"), where("ownerId", "==", user.uid)));&lt;br&gt;
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:&lt;/p&gt;

&lt;p&gt;match /internal/{doc} {&lt;br&gt;
  allow read, write: if false;&lt;br&gt;
}&lt;br&gt;
Deploy:&lt;/p&gt;

&lt;p&gt;firebase deploy --only firestore:rules&lt;br&gt;
Then run the curl from Step 3 again and confirm you get PERMISSION_DENIED.&lt;/p&gt;

&lt;p&gt;Step 5: Keep it from coming back&lt;br&gt;
Test your rules in CI with the emulator and @firebase/rules-unit-testing:&lt;/p&gt;

&lt;p&gt;import { initializeTestEnvironment, assertFails } from "@firebase/rules-unit-testing";&lt;br&gt;
import { readFileSync } from "node:fs";&lt;br&gt;
import { doc, getDoc } from "firebase/firestore";&lt;/p&gt;

&lt;p&gt;const env = await initializeTestEnvironment({&lt;br&gt;
  projectId: "demo-test",&lt;br&gt;
  firestore: { rules: readFileSync("firestore.rules", "utf8") },&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;test("signed-out users can't read orders", async () =&amp;gt; {&lt;br&gt;
  const db = env.unauthenticatedContext().firestore();&lt;br&gt;
  await assertFails(getDoc(doc(db, "orders/any")));&lt;br&gt;
});&lt;br&gt;
Add one test like this for each collection. New features are where open rules usually creep back in.&lt;/p&gt;

&lt;p&gt;What I took away&lt;br&gt;
"It works" doesn't mean "it's safe." The bug lived in a place no user ever sees.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;br&gt;
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.&lt;/p&gt;

&lt;p&gt;Have you found open rules in a project before? I'd like to hear how you caught them. 👇&lt;/p&gt;

</description>
      <category>firebase</category>
      <category>security</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
