RLS is on and it still leaks: a simulator that shows who can read, insert, update and delete each table (runs in your browser) #53663
Psychevus
started this conversation in
Show and tell
Replies: 1 comment 1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Disclosure: I built this. It's part of Psychevus, where I also sell security reviews. The tool itself is free, needs no sign-up, and runs entirely in your browser: the schema you paste never leaves the page.
There are already good checks here for "is RLS off?" and for tables that answer the public key. This one targets the problem that comes after that, common in apps built with Lovable, Bolt or Cursor: RLS is on, there is a policy, and it still lets the wrong person in. So instead of matching patterns like
using (true), it evaluates the policies the way Postgres does and prints, for every exposed table and every command, who gets through: anyone with the anon key, any signed-in user, only the row's owner, or nobody.A real example from the sample schema on the page:
That reads as "protected". The simulator's answer:
Since anyone can sign up, "any signed-in user" means anyone can change or delete every invoice.
What it models
TOclause applies to PUBLIC, which includesanon.WITH CHECK(orUSINGunderFOR ALL). UPDATE is judged byUSING, and flagged when itsWITH CHECKis weaker, because then a user can move their own row to another owner.user_metadatafrom the JWT. Every user can edit that withsupabase.auth.updateUser(), so(auth.jwt() -> 'user_metadata' ->> 'role') = 'admin'lets anyone become admin.security_invoker, which ignore the RLS of the tables underneath.SECURITY DEFINERfunctions inpublic, which are callable through/rest/v1/rpc, and especially ones without a fixedsearch_path.Every finding comes with the SQL fix and a prompt you can paste into Lovable, Cursor or Claude Code, plus one prompt that fixes all of them at once.
How to use it: the page has a read-only export query for the SQL editor. It reads catalog metadata only (tables, RLS flags, policies, views, function settings), never rows. Paste the single result cell. A
supabase db dump --schema publicor your migration files work too.Limits (the result states them as well): it's static analysis. It can't see your data, grants you changed by hand, or what a helper function does inside. A function call inside a policy is assumed to scope rows to the user. Only
public,graphql_publicandstorage.objectscount as exposed.For CI and agents:
POST https://psychevus.com/api/v1/supabase-rlswith{"sql": "..."}returns the same result as JSON. It's also an MCP tool (analyze_supabase_rlsonhttps://psychevus.com/api/mcp), so a coding agent can check its own migration before you apply it.👉 https://psychevus.com/tools/supabase-rls
I'd really like to hear about policy shapes it misreads, in either direction. False positives and missed cases are both useful.
All reactions