Menu

All my Supabase RLS tests passed. A review still found 6 problems.
📰

All my Supabase RLS tests passed. A review still found 6 problems.

DEV Community: postgres·Masaru Nishino·4 days ago
#FzTfM3SK
#devtopostgresql#devto#dev#client#every
Long article (1497 words) — no AI summary yet.
Reading 0:00
15s threshold

I built a client portal with Next.js, Supabase and Stripe, mostly with AI help. Each client company sees only its own projects, payments and files.

I had RLS tests, and every one of them passed.

Then I reviewed it the way I would review a client's app. I found six problems. None of them showed up in the tests.

This post is what I checked, what I found, and the queries you can run on your own project.

Why passing tests is not enough

RLS tests check the cases you thought of. "Client A can't read client B's projects" is a good test. But RLS is only one layer. Three other things decide what a user can do:

Grants : what each role is allowed to do at all, before RLS runs

Functions : some run with the owner's rights and skip RLS

Server code : anything that uses the service_role key skips RLS completely

My tests covered RLS well. The problems were in the other three.

Part 1: Look at the live database, not just the policies

1.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.