Checklist · Taking over a project
Securing the Supabase back end of an AI-built app: ten checks
By MervenorPublished Last reviewed 5 min read
In a Supabase app the browser talks to the database directly, so row-level security (RLS) and grants are what stand between your data and anyone who opens the browser's developer tools. AI app builders get the screens working first and often leave tables without policies, or with policies that let everyone in. Run these ten checks before real users arrive, and test as a stranger, not as yourself.
Why this matters
The publishable key (or the legacy "anon" key, which does the same job) is meant to be public: it ships inside your app's JavaScript. Security comes from the database: RLS policies decide which rows each request may read or change, and grants decide which operations a role may attempt at all. In 2025, CVE-2025-48757 was published for apps generated with Lovable: insufficient RLS policies let unauthenticated visitors read or write database tables. Lovable disputes that it is a platform flaw and says each customer is responsible for protecting their application's data, which is the practical lesson: whoever owns the app owns this check.
The ten checks
RLS is on for every table in exposed schemas
Including tables the AI builder created for logs, settings or test data. Supabase's documentation is explicit: once RLS is enabled, no data is reachable through the API with a publishable key until you create policies.
No policy says "everyone" for private data
A policy written for the anonymous role with
using (true)exposes every row the role can reach. Keep it for data that really is public, such as a product catalogue.Policies check ownership
Each private row carries an owner, and the policy compares it with the signed-in user, for example
using ((select auth.uid()) = user_id). Check update policies too: a user should not be able to change the owner column.Grants match what each role needs
Adding policies does not remove grants, and on existing projects new tables in the public schema start with every privilege granted to the anonymous and signed-in roles. Revoke what signed-out visitors do not need, so a missing policy cannot become an open door.
The secret key never reaches the browser
The secret key (or the legacy "service_role" key) bypasses RLS. Search the repository and the built JavaScript for it; if it was ever committed or shipped, rotate it. Supabase's own words: never use a secret key in the browser or expose it to customers.
Other paid keys live on the server
Keys for AI providers, payments or email called straight from the browser can be copied and billed to you. Move those calls into a server route or an Edge Function, with a rate limit.
Storage buckets are private unless public by design
Storage has its own policies. Check who can list, read, upload and delete in each bucket, especially buckets holding invoices, identity documents or user uploads.
Functions do not quietly bypass the rules
Postgres functions declared
security definerrun with their owner's privileges and can read past RLS. List them, check what each one returns, and make sure the ones the API can call check the user themselves.Signed-in users cannot read each other's data
Create two test accounts and try to read, change and delete the second account's rows while signed in as the first.
Policies are fast enough
Add an index on every column your policies filter on, and write
(select auth.uid())rather thanauth.uid()so Postgres evaluates it once per query instead of once per row.
How to test it yourself
Open your app in a private browser window without signing in, copy the project URL and the publishable key from the network requests, and call the REST API for each table with nothing else. Every private table should return no rows or an error. Then repeat the test signed in as each of your two test accounts. The dashboard's security checks help, but a test from the outside is what an attacker does.
When to bring in help
If any table answered with data it should not have, treat it as an incident first: lock it down, then find out what was exposed and for how long. Then fix the rest in order of risk, with tests that fail if a policy ever regresses. A fresh pair of eyes helps most when the app was generated quickly and nobody has read all of it.
Questions people ask
Is the publishable key a secret?
No. It is designed to be public and only works within the limits your policies and grants allow. The secret key is the one that must never leave the server.
Does the AI builder set up RLS for me?
Sometimes, partly. Check every table yourself; generated policies are often written for the happy path and allow more than intended.
Will turning on RLS break the app?
It blocks every request until policies exist, so enable it table by table on a test project or branch first, add the policies, then release.
Auspicia, the launch-ready check, reviews apps built with AI tools for exactly these gaps in five business days, at a fixed fee, and prices the fixes.