What is Row Level Security?
Database rules that decide which rows each user may see or change. With it off, anyone with your public key can read everything.
Where Row Level Security goes wrong in real apps
Each of these is a short scenario built from a real failure in an app made with AI. Read the answer here, or walk through it yourself in about four minutes.
Who may see what · 4 minutes · Pro
Permission denied for table
Your AI created a new 'invoices' table. Every page that reads it now fails, for every user, even you. RLS looks fine.
Read the fixWhy does Supabase say permission denied for table?
The message 'permission denied for table' (error 42501) means the role making the request has no grant to use that table at all, so Row Level Security never runs. Since 30 October 2026, new Supabase tables are not exposed to the API until you grant access. Grant only the access each role needs, such as select to authenticated, and keep RLS policies on.
Who may see what · 5 minutes · Pro
The table anyone can read
Your app uses Supabase straight from the browser. A stranger posts a screenshot of your whole users table on X.
Read the fixWhy can anyone read my Supabase table?
Your Supabase publishable (anon) key ships to every browser on purpose. Row Level Security decides which rows that key may read or change. If RLS is off on a table, or a policy uses (true), anyone can query every row. Turn RLS on and write policies around auth.uid().
Teams and sharing · 4 minutes · Pro
The export with everyone's data
A customer clicked 'Export orders to CSV'. The file had 40,000 rows. Their team has 300 orders. The rest belong to your other customers.
Read the fixDoes the Supabase service role bypass RLS?
Yes. The service role key bypasses every row level security policy by design, so any server code using it must check permissions itself. Leaks happen when that code also takes the team or user id from the URL or request body. Query with the signed-in user's client so RLS applies, and derive the team from their session.
Money and secrets · 5 minutes · Pro
The fix that made it worse
A customer with orders sees 'No orders yet'. You asked your AI to fix the orders page. It says: 'Fixed! Everything works now.'
Read the fixHow do I check that an AI code fix is safe?
Read the diff, not the summary. Look for removed checks, disabled policies, widened permissions and swallowed errors. Ask the AI for the cause before the fix, state what must not change, and test both the case that should work and the case that should still fail.
AI inside your app · 4 minutes · Pro
Another customer's document
Your 'chat with your documents' app answered a question by quoting a contract. The user has never uploaded a contract. Another customer has.
Read the fixHow do I keep RAG data separate per user?
Filter by user or team inside the search itself, before results reach the model. Similarity search returns the closest chunks from everything it can see, so an unfiltered query mixes customers. In Supabase, avoid security definer match functions that skip RLS, use security invoker, filter by owner, and test with two accounts.
Teams and sharing · 4 minutes · Free
Removed, but still inside
You removed a contractor from your team at 2:00pm. At 2:40pm they downloaded the customer list.
Walk it, freeWhy can a removed user still access data?
If your security rules read the user's role from their sign-in token (JWT claims), the old role stays valid until that token expires, an hour by default in Supabase. Signing them out doesn't revoke a token already issued. Check team membership in the database inside your RLS policies, so every request sees the current team list.
Related terms
- Table, row, column
- A table is like one spreadsheet (orders). Each row is one item (one order); each column is one detail (price, date).
- Supabase
- A popular hosted database with sign-in and file storage built in. Many AI app builders use it behind the scenes.
- Request
- A message your browser (or any program) sends to a server asking for something: 'give me invoice 105' or 'save this profile'.
- Server
- A computer that runs your app's code out of sight. Users can't change what happens there, which is why checks belong there.
- Policy
- One rule in Row Level Security, such as 'people can read only their own orders'.
- Authorization
- Checking what someone is allowed to do once you know who they are. Signed in does not mean allowed.