In short
- Both put a public key in your JavaScript on purpose. Supabase calls it the publishable (or anon) key. Firebase calls it the API key. Hiding it protects nothing: the rules do.
- Supabase's typical leak is a table created by SQL or by a coding agent with row level security off, or a policy with
using (true). - Firebase's typical leak is a database started in test mode, which the quickstart says "allows anyone to read and overwrite your data", or a rule that stops at
request.auth != null. - On both, a rule that only checks for a signed-in user lets any stranger in after a sign-up. Tie every rule to the caller's id.
- What decides the outcome is what your deployed app answers to a stranger and to a second account, whichever vendor you picked.
On this page
- Supabase vs Firebase: the same bet, two rule languages
- Public keys on both: what your JavaScript gives away
- Supabase: the leak is a table without RLS, or a policy that says true
- Firebase: the leak is test mode, or a rule that only asks for an account
- The mistake they share: signed in does not mean allowed
- How to check a Supabase project
- How to check a Firebase project
- Which one should you choose?
- What Keybrum tests on each, and what it does not
- Questions
- Sources
Supabase vs Firebase: the same bet, two rule languages
Most Supabase vs Firebase comparisons weigh SQL against NoSQL, pricing and lock-in. This one compares what a stranger can do to the app you ship on each. On that question the two are closer than their fans admit. Both let your frontend talk to the database directly, with no server of yours in between. Both hand the browser a key that anyone can copy. And both leave the real access control to rules that you, or your coding agent, write.
The difference is the language of those rules, the defaults you start from, and the mistake each one makes easy. Know the mistake of your stack and you know where to look first.
| Supabase | Firebase | |
|---|---|---|
| Database | Postgres, reached through the Data API (PostgREST) and GraphQL | Cloud Firestore or the Realtime Database, document stores |
| Key in the browser | Publishable key (sb_publishable_...) or the legacy anon key | The web API key in the Firebase config |
| Who decides access | Grants and row level security (RLS) policies, in SQL | Security Rules, one set each for Firestore, the Realtime Database and Storage |
| Key that skips the rules | Secret key (sb_secret_...) or legacy service_role | The Admin SDK with a service account |
| State with no rule written | RLS on and no policy: nothing readable. RLS off with grants: everything readable | Production mode: all client access denied. Test mode: everything open |
| Typical leak | RLS off on a table, or a policy of true | Test mode left on, or request.auth != null alone |
| Built-in checker | Security Advisor (database lints) | Rules Playground and the Emulator Suite |
Public keys on both: what your JavaScript gives away
Founders often panic when they find a key in their bundle. On these two platforms it is meant to be there. Supabase's documentation lists publishable keys as safe to expose in a web page, a mobile app or source code, and adds the condition that matters: anyone can read the key, so it only reaches what row level security allows. Supabase is deprecating the legacy anon and service_role keys by the end of 2026 in favour of publishable and secret keys. Our guide to the Supabase anon key covers the old format.
Firebase says the same about its own key. Its security checklist states that API keys for Firebase services only identify your project and app to those services. Authorization comes from Security Rules, IAM permissions and App Check. See Firebase API key exposed for what that key can and cannot do.
Supabase: the leak is a table without RLS, or a policy that says true
In Supabase, a policy is a condition Postgres adds to every query on a table. The docs put the starting point in one sentence: once RLS is enabled, no data is accessible through the API with a publishable key until you create policies. That is a safe default. The trouble is getting to it.
- RLS is per table, and SQL does not turn it on. A table created in a migration, by an ORM or by a coding agent has no RLS unless the SQL says
enable row level security. Supabase's docs warn that a table in an exposed schema without RLS is readable and writable by any role with a grant on it. - Grants used to be wide open. On existing projects, a new table in
publicstarted with every privilege granted to the API roles. Supabase changed that default for new projects from 30 May 2026 and scheduled existing projects for 30 October 2026. Tables that already existed keep their grants. - The quick fix for an empty list is the leak. With RLS on and no policy, the app shows nothing. The fastest way to make data appear is
using (true), which gives every row to every caller. - Storage, functions and Realtime have their own doors. Bucket policies, database functions exposed as RPC and Realtime subscriptions are each checked separately.
This is the pattern behind CVE-2025-48757: a researcher tested 1,645 apps built with Lovable and found 170 of them, about one in ten, with missing or weak RLS that let an unauthenticated visitor in. The Supabase RLS guide has the policies to paste and the full list of mistakes.
Firebase: the leak is test mode, or a rule that only asks for an account
Firebase rules are a file per product. Each match block names a path and each allow line gives a condition. When you create a Firestore database, the console asks you to pick a starting mode. Production mode denies all reads and writes from web and mobile clients. Test mode, in the quickstart's own words, "allows anyone to read and overwrite your data". The quickstart recommends test mode to get started with the web and mobile SDKs, which is how it reaches production.
- Test mode outlives the test. A test mode rule compares the request time with a fixed date. Until that date it behaves like
if true. When the date passes the app breaks, and the quickest edit is to push the date forward. - `request.auth != null` is one sign-up away from public. Firebase's guide to insecure rules lists it: the rule checks that a user is logged in and does not restrict access further. The security checklist adds that anyone could create an anonymous account in your project.
- Three products, three rule sets. Rules that hold for Firestore say nothing about the Realtime Database or Storage. An old Realtime Database left open next to a careful Firestore is common.
- Allows add up. A catch-all block left at the bottom of the file cancels the careful rules above it.
Firebase's documentation is blunt about open rules: anyone who guesses your project ID can steal, modify or delete the data. The project ID is in your JavaScript. The Firebase security rules guide shows each leaking pattern next to the rule that holds.
The mistake they share: signed in does not mean allowed
The same bug exists on both platforms under two spellings. On Supabase it is a policy to authenticated using (true). On Firebase it is allow read: if request.auth != null. Both say: any account may read every row. In most apps anyone can create an account, so "any account" means any stranger with an email address.
-- Supabase: leaks. Any signed-in user reads every order.
create policy "read orders" on public.orders
for select to authenticated using ( true );
-- Supabase: holds. Each user reads their own orders.
create policy "read own orders" on public.orders
for select to authenticated
using ( (select auth.uid()) = user_id );auth.uid() in a select for speed.// Firebase: leaks. Any signed-in user reads every order.
match /orders/{orderId} {
allow read: if request.auth != null;
}
// Firebase: holds. Each user reads their own orders.
match /orders/{orderId} {
allow read: if request.auth != null
&& request.auth.uid == resource.data.ownerId;
}resource.data is the stored document, which the caller cannot rewrite in the same request.A second shared trap is the field a user must not set: role, is_admin, plan, credits. An owner-only update rule lets users edit their own row, including those columns. On either platform, write them from your server. This family of bugs is covered in the IDOR guide.
How to check a Supabase project
Run these two queries in the SQL editor of your own project. The first lists tables in public with RLS off. The second lists policies whose condition is simply true. Both should return nothing you cannot explain.
-- Tables in public with row level security off
select c.relname as table_name
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public'
and c.relkind = 'r'
and not c.relrowsecurity;
-- Policies that let every caller through
select tablename, policyname, cmd, roles
from pg_policies
where schemaname = 'public'
and (qual = 'true' or with_check = 'true');true policy on a public catalogue is fine. On users, orders or messages it is a leak.Then open the Security Advisor in the dashboard, and test from outside: call a table with your public key and no session, the way the RLS guide shows, then again as a second account.
How to check a Firebase project
- 1
Read the three rule sets
In the Firebase console, open Firestore Database, Realtime Database and Storage in turn, and the Rules tab of each. A product you never set up has no tab to worry about. One you set up once and forgot does.
- 2
Search for the three patterns
Look for
if true, forrequest.timecompared with a date, and forrequest.auth != null(orauth != nullin the Realtime Database) with nothing after it. Each one is open to strangers, now or after a sign-up. - 3
Simulate as a stranger and as a second user
In the Rules Playground of the console, run a read on a private path with authentication off, then as a user who does not own the document. Both should be denied.
- 4
Ask the live project
The Firebase security guide has three read-only commands, one per product, to run against your own project with no session. An answer with data means the rules are open.
Which one should you choose?
Choose on what your app needs, because security will not settle it. Supabase is the better fit when your data is relational, when you want SQL, joins and constraints, and when you want policies you can test with plain queries. A policy lives next to the table, and a pg_policies query audits a whole project in a second. Firebase is the better fit when you build on Google's mobile and web SDKs and a document model suits your data. Start it in production mode, which denies every client request until you write rules.
Each has a sharp edge. On Supabase, every new table is a new chance to forget RLS, and coding agents create tables often. On Firebase, rules are not filters and add up across blocks, which makes a large rules file hard to reason about. Whichever you pick, the leak will be in what you deployed, and only a test of the deployed app shows it.
What Keybrum tests on each, and what it does not
Keybrum is the automated pentest we build for apps made with AI. It attacks the live app from outside, after you prove the app is yours, first with no session and then as a brand-new account it creates.
- On Supabase: it lists the tables the public key can reach, reads ten rows and counts the rest, tries inserts and updates that are rolled back, calls exposed database functions, lists storage buckets, subscribes to Realtime changes, checks the auth redirect allow-list and tests the JWT secret against known weak values.
- On Firebase: it reads the Firestore collections named in your code or under common names, tests writes with a request built so nothing is written, reads the Realtime Database root and lists Storage files.
- On both: it tries to set
role,planorcreditson the new account's own record, and reports a finding only when the database accepts it.
It does not read your policies or your rules file: it reports what the deployed backend answered, with the request that worked. It never tests deletes. A Firestore collection whose name appears neither in your code nor in its list of common names can be missed. And it keeps only counts, field names and one redacted record.
A one-time report on one app is €49. Plans start at €29 a month excluding VAT for five apps, and attack again on every deploy.
Questions
Is Supabase more secure than Firebase?
Neither is safer by design. Both platforms protect their own infrastructure and leave access control to rules you write: RLS policies on Supabase, Security Rules on Firebase. An app on either one is as protected as its weakest table or collection.
What is the Firebase equivalent of Supabase RLS?
Firebase Security Rules. They play the same role as row level security policies: every request from a browser or phone is checked against them before data moves. The syntax differs, and Firebase has a separate rule set for Firestore, the Realtime Database and Storage.
Is it safe to expose the Supabase key and the Firebase API key?
Yes for the Supabase publishable or anon key and the Firebase web API key: both vendors document them as public. No for the Supabase secret or service role key and for Firebase service account credentials, which skip every rule.
Does Firebase test mode expire by itself?
A test mode rule compares the request time with a fixed date and denies everything once the date passes. Until then the database is open to anyone. Many apps ship during that window, and many owners move the date forward when the app breaks, so do not rely on the expiry.
Does enabling RLS on Supabase break my app?
With RLS on and no policy, the public key reads nothing, so lists go empty until you add policies. That is expected. Add one policy per operation tied to the caller's id rather than a policy of true.
Which is easier to audit, Supabase policies or Firebase rules?
Supabase policies can be listed with one SQL query on pg_policies, and its Security Advisor flags tables without RLS. Firebase rules live in one file per product and are tested in the Rules Playground or the emulator. In both cases, finish with a test against the live project as a stranger and as a second account.
Sources
- 1.Row Level Security, Supabase Docs
- 2.Understanding API keys, Supabase Docs
- 3.Breaking change: tables not exposed to the Data and GraphQL API automatically, Supabase
- 4.Get started with Cloud Firestore, Firebase Docs
- 5.Avoid insecure rules, Firebase Docs
- 6.Firebase security checklist, Firebase
- 7.CVE-2025-48757, NIST National Vulnerability Database