Skip to content
GUIDES#app security#vibe coding#Firebase

Security in Vibe Coding Apps: What Firebase Does Not Do for You

You built an app with AI, wired up Google Sign-In, and everything works. The problem is that "works" and "secure" are two different tests, and in a vibe-coded app only the first one almost always gets run. Here is how to run the second one before real users arrive.

Yaakov Tzedek
Yaakov Tzedek · AI expert·9 min read
THE BOTTOM LINE
  • Firebase's Google Sign-In tells you who the user is, not what they can access. Learn Security Rules, which API keys to expose, and a pre-launch checklist.

Signing in with Google in Firebase answers exactly one question: who the user is. It does not determine what they are allowed to read, modify, or delete. That is determined by Security Rules and server-side checks, two things that AI-generated code tends to leave wide open so that "everything just works." Security is not over-engineering: it is the difference between an app where each user sees only their own data, and an app where any logged-in user can see everyone's data.

This question came up recently in one of the AI groups on Facebook, phrased honestly and precisely: if Firebase already stores the data and handles authentication, why does the product itself need additional security? It is an excellent question, because the answer explains most of the security problems in apps being built today through AI conversations.

In short

QuestionShort answer
Does signing in with Google protect the data?No. It identifies the user, it does not restrict them.
What actually restricts access?Firebase Security Rules, and code running on the server.
What is the common mistake?Open rules left over from development, or a rule that allows access to anyone who is logged in.
Is a Firebase API key in the code a problem?No. A Gemini key or a service account key in the code, yes.
The most important testA second user attempting to read the first user's data.

Why signing in with Google does not protect your data

Every system has two separate questions: who you are, and what you are allowed to do. The first is called Authentication, and the second is Authorization. When a user signs in with Google, Firebase knows with certainty that it is her. That is all.

Imagine an office building with a security guard at the entrance checking IDs. The check at the door is excellent, but if every office inside is unlocked, anyone who gets in can open any drawer. Signing in with Google is the security guard at the entrance. Security Rules are the locks on the doors.

And here is the detail most app builders do not know: in an app built on Firebase, the browser talks directly to the database. There is no server of yours in the middle filtering requests. The app's code, including the project details, is downloaded to the machine of every person who visits the site, and anyone can send requests to the database themselves, without going through the interface you built. What stands between them and the data are the rules, and only the rules.

This is well known in the professional community too. In the OWASP Top 10, the most widely recognized list of web application security risks, the category ranked first in the 2025 edition is Broken Access Control (OWASP Top 10:2025, checked on 2026-10-19). That is exactly the problem that authentication alone does not solve.

What Security Rules are in Firebase

Security Rules are a short file that Firebase runs against every request arriving from an app or a browser. According to the Cloud Firestore documentation, every request from a client library is evaluated against the rules before any data is read or written, and if the rules deny access to any of the documents, the entire request fails.

When you create a new Firestore database, two modes are offered. According to the official quickstart guide, test mode "allows anyone to read and overwrite your data," while production mode blocks all reads and writes from apps and browsers. Test mode is very convenient for development, so AI tools and quick-start guides choose it frequently. The problem starts when it stays that way after launch.

The Firebase page on insecure rules lists three patterns worth identifying in your file:

  1. Fully open access. A rule such as allow read, write: if true;. According to Firebase, anyone who guesses the project ID can steal, modify, or delete the data.
  2. Access for any authenticated user. A rule such as allow read, write: if request.auth.uid != null;. It looks secure because it requires a login, but it allows any authenticated user to read and modify every document in the collection, including other people's. Firebase recommends verifying that this is actually what you intended.
  3. Incorrect inheritance in Realtime Database. There, rules cascade from a parent path down to its child paths, and according to the documentation you cannot revoke access at a deeper path that was already granted at a path above it.

A correct rule checks ownership, not just authentication. This is Firebase's official example for owner-only access, from the basics page:

service cloud.firestore {
  match /databases/{database}/documents {
    match /some_collection/{userId}/{document} {
      allow read, write: if request.auth != null && request.auth.uid == userId
    }
  }
}

In plain language: reading and writing are only allowed if you are logged in, and also if your ID is the ID that appears in the document path. The second part is the entire difference.

Exposed keys: which key can be visible and which cannot

Not every key that appears in the code is a leak, and not every hidden key is safe. There is a lot of confusion here, including in the groups.

According to the official Firebase documentation on API keys, keys that are scoped to Firebase services only identify the project, they do not need to be treated as secrets, and they may be included in code and configuration files. The protection comes from Security Rules and App Check, not from hiding the key. So if you see the Firebase apiKey in your site's code, that is not what you need to worry about.

What you do need to worry about:

  • A Gemini API key. According to the same page, it should never appear in code or configuration files. This is especially relevant for apps that add an "AI chat" feature: a key like that in the browser lets anyone use it at your expense.
  • Private service account keys. According to the Firebase security checklist, they are sensitive and must remain secret, because they grant full server-side access.
  • FCM server keys, Firebase's notification service. The same checklist states they must be kept secret.

For anyone building on Supabase instead of Firebase, the logic is identical, just with different names:

FirebaseSupabase
The key that may appear in codeFirebase API keypublishable key (formerly anon)
What protects the dataSecurity RulesRow Level Security (RLS)
What bypasses the protectionServer libraries and Admin SDKsecret key (formerly service_role)
Where the bypassing key must liveServer onlyServer only

According to the Supabase documentation (checked on 2026-10-19), the public key only reaches what RLS permits, so RLS must be enabled on every table before deployment, and the secret key bypasses RLS entirely and must never reach the browser, the app, or the code repository. Anyone building with Claude Code on Supabase will find this in detail in the guide to Claude Code with Supabase.

Server-side checks: why you cannot trust the browser

Everything that runs in the browser is under the user's control. They can open developer tools, change a value, and send their own request. A hidden button is not a permission, and a JavaScript check is not a lock.

Three examples that come up repeatedly in apps built quickly:

  1. A price sent from the browser. If the shopping cart sends "amount to charge," a user can change it. The price must be determined on the server, based on the product ID.
  2. A role field the user can write to. If the user document has an isAdmin or role field, and the Security Rules allow the user to update their own document, they can make themselves an administrator.
  3. A user ID arriving from the client. If the server receives "I am user 123" and believes it, anyone can impersonate anyone else. According to the Firebase documentation, after login you send the ID token to the server over HTTPS, and the server verifies it and extracts the uid itself.

And an important point in the other direction: according to the documentation, Firestore's server libraries bypass all Security Rules. This is intentional, because your server is supposed to be trusted. But it means that code on the server (such as Cloud Functions) must check permissions itself, because the rules no longer work on its behalf.

Why "the code the AI wrote" is not enough

AI tools write code that works, and that is exactly what you asked of them. When you test the app, you log in, see your data, and everything looks fine. Neither of you tried being a different user.

Open rules make the app work on the first try, and tight rules produce permission errors until they are configured correctly. When the goal is "make it work," the easy path wins. This is not negligence on the tool's part, it is a missing instruction.

The solution is not to give up on AI, but to ask it for the check explicitly: show the rules file, explain for each collection who can read and who can write, and look for secret keys in code that reaches the browser. And then verify it yourself, because a convincing explanation is not proof. The same principle of minimum permissions and confirmation before an irreversible action also appears in the draft rules for working with AI agents.

Checklist Before You Have Real Users

Go through this list before the first person who isn't you signs up. Most items are based on the official Firebase Security Checklist (checked 2026-10-19):

  1. Check what state your database is in. Open the Rules tab in the console. If you see if true or a date-based rule left over from test mode, it must change.
  2. Start from a full block. Firebase recommends a default-deny posture, opening access only to the collections that actually need it.
  3. Replace every request.auth != null with an ownership check or a role check, unless every authenticated user is genuinely supposed to see everything.
  4. Run the second-user test. Open a second account in a private browsing window and try to read or modify data belonging to the first account. If it works, stop and fix it.
  5. Add rules alongside every new collection. In Firebase's own language, security rules are a schema, and you add them when you add documents.
  6. Test your rules in the emulator. Firebase recommends testing them with the Firebase Local Emulator Suite and including those tests in your deployment pipeline.
  7. Search your client-side code for secret keys: Gemini, service accounts, FCM, and keys for any external services. All of these belong on the server.
  8. Move every money- or permission-related decision to the server: prices, roles, discounts, and access to other users' data.
  9. Enable App Check on every service that supports it. According to the documentation, it verifies that requests come from your app and prevents some abuse, but not all of it, and it does not replace rules.
  10. Set up budget alerts. Firebase recommends them so you know when usage exceeds expectations, and they're also an early warning sign of abuse.
  11. Keep your development project separate from your production project, so experiments never touch real users' data.
  12. If you have email and password sign-in, enable email enumeration protection, which appears on the official checklist.

Beyond the technical layer, there is also a legal one: an app that collects personal data in Israel is subject to the Privacy Protection Law. I covered that in the guide to privacy policies and accessibility for AI-built websites.

The bottom line

The question asked in the group was why a product needs "excessive security" when Firebase is already there. The answer is that Firebase gives you the locks, but it does not lock the doors for you. Authentication says who gets in. Rules say where they're allowed to go. And in an app where the browser talks directly to the database, the rules are the only line of defense.

This does not require being a security expert. It requires half an hour, one rules file you actually understand, and a second user who tries to break into the first one.

Want to learn how to work with AI tools in a structured way, with hands-on practice in every lesson? There is an interactive course series for 9.90 ILS, suitable even for someone building their first app.

Sources

Frequently asked questions

Was this article helpful?
Share:WhatsAppLinkedInX
Yaakov Tzedek
WRITTEN BY

Yaakov Tzedek

An Israeli AI lecturer, consultant and implementer who has supported 100+ organizations in AI implementation and lectured for 200+. Official content partner of Meta, Google, Canva and TikTok, featured on Israel's Channel 13.

More about Yaakov →