The Kitchen Check: 5 tests to find out if your AI-built app has a backend
Octopoda — · 14 min read
Think of your app as a restaurant. The frontend is the dining room, everything customers see. The database is the
pantry, where every ingredient lives. The backend is the kitchen in between: it takes each order, checks it against
the rules, and only then goes to the pantry.
Lots of apps built with AI skip the kitchen. The frontend talks straight to the database, so any customer can walk into
the pantry and take whatever they like. How common is that?
Broken access control tops the OWASP Top 10 for 2025, and OWASP found some form of it in every
application in its test data.
In March 2025, a researcher scanned 1,645 apps built with Lovable and found 170
whose database wasn't properly locked. The exposed data included user emails, payment and subscription records, and
API keys. The flaw got a CVE: unauthenticated attackers could read or write arbitrary
tables in generated sites.
A later scan of over 5,600 public vibe-coded apps found more than 2,000 vulnerabilities, 400+ exposed
secrets and 175 cases of exposed personal data, including medical records and bank account numbers.
You can check your own app in about 10 minutes without reading any code. Each of the five checks below has a test you
can run right now, what the result means, and a prompt to paste into your coding agent (Cursor, Claude Code, Lovable,
Bolt) to fix it.
The examples use Supabase, the database behind most of these apps. If you use Firebase, the same ideas apply, and
there's a section for you near the end.
Only test apps you own. Every test below reads from your own project. Running them against someone else's app
without permission is not okay, and in many places it's illegal.
The 10-minute version
#
Check
Pass looks like
1
Is the pantry locked?
Row Level Security is on for every table, with a policy for each action
2
Can a stranger walk into the pantry?
Asking the database directly returns [] or an error, not other people's rows
3
Is the master key hanging in the dining room?
No secret or service_role key anywhere in your site's JavaScript
4
Does the kitchen check every order?
Changing an ID in a request gives you an error, not someone else's data
5
Are there back doors?
No public views, risky functions or open storage buckets you didn't mean to have
Check 1: Is the pantry locked?
In restaurant terms, the pantry door needs a lock and a rule for who may take what.
In your app, that lock is Row Level Security (RLS), a Postgres feature that decides which rows each user can see and
change. Supabase's docs say that any table in an exposed schema (like public) without
RLS can be read and written by anyone the API lets in, so RLS should be on for every one of them.
Supabase's own linter rates an RLS-less table in public as an error, because anyone with your
project URL can create, read, update and delete its rows.
RLS being on isn't the same as RLS being right. The 2025 Lovable research pointed out
that checking whether a policy exists doesn't tell you whether it restricts anything.
The test (3 minutes)
Open your project in the Supabase dashboard and run the Security Advisor (under Advisors),
a built-in set of checks for common security problems.
Fix anything marked ERROR today.
Open the Policies page for your tables (under Authentication in the dashboard) and look at each table:
"RLS disabled" on a table that holds user data means the pantry is unlocked.
RLS on with no policies locks the table to everyone. Nothing can be read or
written through the API until you add policies. That's safe, but your app may be quietly broken.
A policy that says using (true)lets everyone through. Applied to anon, it
opens the table to every visitor who isn't logged in.
For a table where each row belongs to one user (user_id), Supabase
recommends one policy per action, each comparing the row's owner to the
logged-in user, written as (select auth.uid()):
sql
alter table public.orders enable row level security;create policy "Read own orders" on public.orders for select to authenticated using ( (select auth.uid()) = user_id );create policy "Create own orders" on public.orders for insert to authenticated with check ( (select auth.uid()) = user_id );create policy "Update own orders" on public.orders for update to authenticated using ( (select auth.uid()) = user_id ) -- which rows you may change with check ( (select auth.uid()) = user_id ); -- what they may look like after
Without the with check on updates, a user could edit their own row and reassign it to someone else.
Fix prompt
text
Audit Row Level Security in my Supabase project. For every table in the public schema:1. Make sure RLS is enabled.2. List its current policies in a table: table, action (select/insert/update/delete), role, USING, WITH CHECK.3. Flag any policy that uses `true`, checks user_metadata / raw_user_meta_data, or is missing for an action the app uses.4. Propose replacement policies that only let a user touch their own rows, using (select auth.uid()) = user_id, with `to authenticated`, and both USING and WITH CHECK on updates.Show me the SQL as a migration and explain each policy in one line before applying anything.
Check 2: Can a stranger walk into the pantry?
In restaurant terms, skip the waiter, walk to the pantry door and try the handle.
Your app's frontend talks to Supabase through an API that Supabase generates from your database.
Your public key (the "publishable" key, or anon in older projects) sits in your site's code on purpose. It's
designed to be public, as long as RLS is doing its job. So anyone who opens your site
has everything they need to call that API directly, without your app's screens in the way, which is what this test
does.
The test (3 minutes)
Open your live app in Chrome, log out, and open DevTools (right-click → Inspect) → Network.
Reload and click around until you find a request to https://<something>.supabase.co/rest/v1/<table>.
The <something> is your project ref.
The <table> part is a table name.
The apikey request header is your public key.
Ask for that table directly from a terminal, using the request format from
Supabase's own quickstart:
If you're using a legacy anon key and get an error about a missing token, add -H "Authorization: Bearer <same-key>".
Repeat it for each table you saw, especially profiles, users, orders, payments, messages and anything with
"admin" in the name.
What the result means
You get
Meaning
Rows of data that aren't public on purpose (other people's emails, orders, messages)
The pantry is open, and anyone on the internet can read it. Fix Check 1 now.
[] (an empty list)
RLS is filtering you out. Good, unless the table really is empty.
A permission error
The anonymous role has no access to the table. Good.
Public data, like a product list or blog posts
Fine, if you meant it to be public.
Writes matter as much as reads. In the Lovable research, one site let an anonymous
request create a record, including one marked as paid. Don't test writes on live data.
Instead, check that every insert, update and delete policy from Check 1 is limited to authenticated and to the
user's own rows.
Fix prompt
text
My Supabase tables were readable with just the public key. Without changing app behaviour for logged-in users:1. Enable RLS on every table in the public schema and add owner-only policies (see my Check 1 audit).2. For tables the app never needs from the browser, revoke access from the anon and authenticated roles.3. Turn off "Automatically expose new tables" in the Data API settings so new tables aren't public by default.4. Give me a curl command per table that I can re-run with the public key to confirm each one now returns [] or an error.
Check 3: Is the master key hanging in the dining room?
In restaurant terms, the manager's master key, the one that opens every door, is taped to a dining-room table.
Supabase has two kinds of keys:
The publishable key (sb_publishable_..., legacy name anon) is meant for browsers and apps.
The secret key (sb_secret_..., legacy name service_role) bypasses every RLS policy you have.
Supabase's docs say a secret key must never go in a browser, a shipped app or
source control. Supabase blocks secret keys used from a browser, but notes that someone who copies the key can still use
it from any other tool.
It usually leaks through an environment variable with a public prefix:
In Vite, which many Lovable and Bolt apps are built on, any variable starting with VITE_ ends up in client-side
code, and Vite's docs say not to put secrets like API keys in them.
The same goes for your Stripe secret key, your OpenAI key and any other secret: once it's in the browser bundle, anyone
can read it.
The test (2 minutes)
In your code or hosting dashboard, list every environment variable that starts with NEXT_PUBLIC_, VITE_,
EXPO_PUBLIC_ or PUBLIC_. None of them should hold anything called secret, service role, private or sk_.
Open your live site, then DevTools → Sources, and press Cmd+Option+F (Ctrl+Shift+F on Windows) to search all files.
Search for:
sb_secret_ (new Supabase secret keys start with this)
service_role
sk_live_ and sk-proj- (Stripe and OpenAI secret keys)
the first 12 characters of your secret or service_role key, copied from Supabase → Project Settings → API Keys.
Don't paste the full key into any online tool.
Any hit means the key is public. Treat it as leaked: rotate it in the provider's dashboard first, then fix the code.
Deleting it from the code alone doesn't help, because old builds and anyone who copied it still have it.
Fix prompt
text
Find every secret this app uses (Supabase secret/service_role key, Stripe secret key, AI provider keys, email keys).1. Show me each place it's read, and whether that code can run in the browser.2. Move every secret-using call to server-only code (a Next.js Route Handler or Server Action with `import 'server-only'`, or a Supabase Edge Function), read from an env var WITHOUT a NEXT_PUBLIC_/VITE_ prefix.3. Make the browser call that server code instead of the third-party API.4. List which keys I must rotate because they were already shipped to the browser.
Next.js's server-only package makes the build fail if server-only code is ever
imported into the browser.
Check 4: Does the kitchen check every order?
In restaurant terms, a customer hands the waiter an order for table 12's food, and the kitchen should notice they're
sitting at table 4.
If your app has its own backend code (Next.js Route Handlers, Server Actions, Supabase Edge Functions, an Express
server), each of those endpoints has to answer two questions on every request: who is asking (authentication), and may
they touch this exact record (authorization)?
The second question is the one that gets skipped. OWASP ranks it the #1 API security risk:
an attacker changes an ID in a request (/api/orders/123 → /api/orders/124) and gets someone else's object, because
the endpoint never checked ownership.
Two common traps:
Hiding a button is not a check. In Next.js, a Server Action can be called with a direct POST request, not just from
your UI. The Next.js docs say to verify authentication and authorization inside
every action, because a check on the page doesn't cover the actions in it. Middleware (Proxy) alone isn't enough
either. The Next.js authentication guide calls it useful for early checks but
says it shouldn't be your only line of defense.
With Supabase on the server, getSession() reads the session out of the cookie without re-validating it, and
cookies can be forged. Supabase's Next.js guide
says to protect pages and data with getClaims(), which verifies the token's signature.
The test (3 minutes)
Make two test accounts, A and B. As B, create something (an order, a note, a profile) and note its ID from the URL
or the Network tab.
Log in as A. In DevTools → Network, find a request that loads or changes one of A's own things by ID.
Right-click it → Copy as cURL, paste it in a terminal, swap A's ID for B's, and run it.
You get
Meaning
B's data, or B's thing gets changed
The kitchen isn't checking orders, so any logged-in user can reach anyone's data.
403, 404, or an empty result
The endpoint checks ownership. Good.
Then run the same request with the cookie header removed. Anything that still works without being logged in should be
something you meant to be public.
Fix prompt
text
Audit every server entry point in this app: Next.js Server Actions ("use server"), Route Handlers (route.ts),Supabase Edge Functions, and any API routes.For each one, show me in a table: what it does, whether it verifies the user (with supabase.auth.getClaims(), nevergetSession(), on the server), and whether it checks that the user owns or may access the specific record by ID.Then fix each missing check: return 401 if not logged in, 403/404 if the record isn't theirs. Put the checks in oneshared server-only data access layer so new endpoints can't skip them.
Check 5: Are there back doors?
In restaurant terms, the front door is locked, but the delivery entrance and the wine cellar are wide open. Supabase
projects tend to have the same few back doors.
Functions can run as their owner. A security definer function runs with the permissions of whoever created it, so if
that's a powerful role like postgres, the function can bypass RLS. If it sits in an exposed schema like public,
anyone can call it through the API, which is why
Supabase says never to create one there. In
the Lovable research, API tokens for other services leaked through exposed
database functions and edge functions.
Storage buckets can be public. Anyone with a file's URL can
download it from a public bucket, with no login or policy check,
though uploads and deletes still go through your policies. That's fine for
product photos and a leak for invoices, IDs or user uploads.
The test (2 minutes)
Make sure the Security Advisor from Check 1 shows no errors. It already flags views that bypass RLS and other risky
setups.
In Database → Functions, look for functions in the public schema marked SECURITY DEFINER, and for each one ask
whether a stranger should be able to run it.
In Storage, check which buckets are marked Public. Open one file's public URL in a private browser window. If that
file is something a stranger shouldn't see, the bucket shouldn't be public.
Fix prompt
text
Check my Supabase project for back doors around Row Level Security:1. Every view in the public schema: does it set security_invoker = true? If not, add it (Postgres 15+) or move the view out of the exposed schema.2. Every SECURITY DEFINER function in an exposed schema: explain what it can read or change, move it to a private schema if the browser doesn't need it, and set search_path = '' on every security definer function.3. Every storage bucket: list which are public and what kind of files they hold. Make buckets with private files private, serve those files with signed URLs, and add storage.objects policies so users can only read and write their own folder.Show me the SQL and the list of changes before applying them.
Using Firebase instead?
Firebase locks the pantry with Security Rules instead of RLS. Its "test mode" rules let everyone read and write, and
Google's docs warn that if you ship with open rules, anyone who guesses your
project ID can steal, change or delete your data. Rules that only check that a user is logged in let every user read
everyone's data. The fix follows Check 1:
limit each read and write to the owner, for example request.auth.uid == resource.data.author_uid.
When to run the Kitchen Check
Before you launch, and before you post your app anywhere public.
After any prompt that touched the database, auth or payments. Coding agents add tables, views and endpoints quickly,
and new tables in publiccan be reachable through the API by default.
Whenever you add a secret, like a new AI or payments key.
Want this checked automatically?
Running five checks by hand after every change gets old fast, and Check 4 gets harder with every new endpoint.
Octopoda runs security tests on your code in a sandbox, reports only the vulnerabilities it can
prove, and gives you a fix prompt for your coding agent, like the ones in this guide.