You asked an AI tool to build your app and it works. The login works, the data shows up, the buttons do what they should. What you cannot see is whether the database behind it is locked down or standing open.
This happens more than people admit. An AI builder writes the app, wires up Supabase, and ships it with row level security off on a table, or with a policy that lets everyone through. The app looks finished. The database is not.
Eight queries
The check is eight read-only SQL queries you paste into the Supabase SQL Editor. They list every table with RLS off, every policy that lets everyone through, every SELECT grant to anonymous visitors, and every SECURITY DEFINER function that skips RLS entirely. Read-only means the audit cannot change or leak anything itself. It only reads the catalogue.
I ran all eight against a local Postgres 16 database with a dummy schema built to hold the common mistakes: a table with RLS off, a table with RLS on and no policy at all, a policy that lets anon through with USING (true), and a SECURITY DEFINER function that reads a secrets table. The audit caught every one of them. The run also caught a real bug in my first draft of the queries, which is fixed in the shipped file.
The MCP half
The second half is a small Node script. You point it at an MCP server and it lists the server's tools and saves a baseline. Run it again later and it reports what changed: tools added, inputs widened, descriptions rewritten. I ran it against the official filesystem MCP server, 16 tools, and a test server built to change. It caught the added tool and the widened input both times.
One thing the kit is honest about: the RLS audit was not run on a Supabase cloud project, because no login was available. The guide says so in three places. The queries are standard Postgres and run unchanged in the Supabase SQL Editor, but the cloud run itself is yours to do, and the guide tells you exactly how.
The one-page pre-flight checklist is free: MCP pre-flight checklist. The full kit, guide plus SQL plus script plus checklist, is $29: AI-App Security Audit Kit.
The full numbers behind this one are in the AI-App Security Audit Kit. Everything I write here stays free, that part doesn't change. — Salam
More from AheadKit: programming books, packs and AI tools. Each page lists exactly what's inside before you pay.
Top comments (14)
For the SECURITY DEFINER query, listing them isn't quite the test. What matters is
has_function_privilege('anon', fn, 'execute'). On PG17,revoke execute ... from anonstill left it true and anon read the secrets table, because EXECUTE is granted to PUBLIC by default. Only revoking from public turned it false.Listing them only says they exist, it doesn't say anon can run one — the privilege check is the real test. The PUBLIC default is the nasty bit, revoke from anon looking like it worked while nothing changed. Going to run the privilege version against the same dummy schema and see if revoke-from-public is what actually closes it. Was that a real Supabase project or a local PG17?
Local PG17, not a real project. One thing to watch on Supabase though: as far as I know the public schema there has default privileges that grant execute on new functions straight to anon, so it's not only via PUBLIC. I mimicked that locally and revoke from public alone left has_function_privilege true for anon. Only after revoking from anon as well did it go false, so I'd do both.
Local PG17 makes it cleaner, no real project to worry about breaking. The Supabase default-privilege bit is the part I missed. Revoke from public alone still leaves anon with execute, so the run has to test both revokes side by side. Going to run it that way. Is that default privilege written down anywhere on Supabase's side, or just something you found by poking at it?
Half and half. Supabase's Database Functions guide has a "Function privileges" section that says any role can run a function by default and tells you to revoke from both public and the role you're restricting, same for default privileges on future functions: supabase.com/docs/guides/database/...
The anon grant on its own is what I saw poking at it, the docs only imply it by telling you to revoke from both. So I'd still check has_function_privilege('anon', ...) on the real project after the revoke rather than trust either of us.
Half and half is the honest answer then, the docs tell you to revoke from both without ever saying the anon grant is there on its own. The check after the revoke stays in the run either way.
The MCP baseline half deserves its own post. Cursor's MCPoison bug (CVE-2025-54136) was exactly that case: an approved server entry whose command was swapped later, with no new prompt. A diff against a saved tool list would have caught it.
That's exactly the case the second half was built for and never got to show. The script in the piece catches an added tool and a widened input, but a swapped command on an approved entry is the sharper test, and MCPoison is the real version of it. I'll run that one, same baseline script, one entry whose command changes after approval, and see the diff catch it. Have you seen the same pattern anywhere outside Cursor, or is that the one example?
Same idea one layer down: Invariant Labs called it a rug pull in their April 2025 tool poisoning write-up. The server changes its tool descriptions after you approved it. Your baseline diff on tools/list would catch that one too.
That's the case the baseline half was built for, a description swap after approval is exactly what a diff on tools/list would catch. Going to run the swap against the same baseline script. Did the write-up say whether it was a one-off swap or the descriptions kept drifting?
This is a useful checklist, and being upfront that the RLS audit was not run on a live Supabase project yet makes it more trustworthy, not less. One addition I would suggest: after the catalogue queries, test as the anon role itself with a real request against a table that should be locked. Policies can read correctly in the catalogue and still behave differently in practice, especially with the default-privilege issue Sunnatulla raised. And I agree with X1Y1 that the MCP baseline half deserves its own post — a saved tool list that diffs on every run would catch exactly the kind of silent swap that worries me most.
The anon-role test is the part the piece missed — a policy can read right in the catalogue and still let anon through in practice. Going to run that against a locked table and see what actually comes back. And yeah, the MCP baseline half is getting its own post, you and X1Y1 both pointed at the same gap.
I would run those eight read-only queries before I trust any AI-built app with my data.
That's the order that matters — run them before you trust it, not after something goes wrong. Have you got an app in mind to try them on?