"RLS is enabled" is not "RLS works": 6 bugs I found in production Supabase apps
I maintain several Next.js + Supabase apps that real people use every day: staff, members and their families, four roles per app. Every week I run the same checks on them. Here are six real bugs those checks caught, with
I maintain several Next.js + Supabase apps that real people use every day: staff, members and their families, four roles per app. Every week I run the same checks on them. Here are six real bugs those checks caught, with names and data removed, and the fix for each.
None of them would have been caught by a scanner that only asks "is RLS enabled on this table?"
1. Staff could grant themselves admin rights
A staff user with "manage staff" permission opened their own row in the permissions screen, switched on Billing and Accounts, and saved. It worked.
The server action checked one thing: can this user manage staff? It never asked is the target this user? or does this user hold the permission they're granting?
Fix: on the server, reject self-edits and only allow granting permissions the current user already has.
2. A design-preview page shipped with a real admin password
/login-preview was a mock login screen used during design. It went to production pre-filled with a real admin username and password.
Fix: delete the route, rotate the password, add a build check that fails if preview routes exist outside development.
3. "Delete all" deleted rows the user never saw
A list was grouped into collapsed sections. Expand one, tick "Select all", delete: every row in every section was gone. The selection was built from the full dataset, not the rendered rows.
Fix: build the ID list from what is on screen, and show the exact count in the confirm dialog.
4. Half an emoji dropped a notification to 101 people
The notification preview was text.slice(0, 50). When the 50th character was an emoji, the slice left half a surrogate pair. The database API rejected the whole 101-row insert, and nobody was told.
Fix: Array.from(text).slice(0, 50).join(''), and log failed inserts.
5. One deleted account broke a weekly send for four weeks
A weekly message went to a saved list of user IDs. One of those users was deleted. From then on, a foreign-key error rejected the entire 100-row batch every week, silently.
Fix: filter IDs against existing users before inserting; fall back to row-by-row when a batch fails.
6. A form saved next year's date by default
The year dropdown had no default and listed four years. 19 real submissions were saved a year in the future and never showed up in staff's "today" view.
Fix: default to today, limit the choices, validate on the server.
How to test the one that matters most
The most common Supabase hole I see in AI-built apps is a policy like this:
create policy "read orders" on orders
for select to authenticated
using (true); -- should be: auth.uid() = user_id
RLS is "enabled", so a scanner is happy. But any signed-in user can read every order.
To catch it: create two test users, sign in as user A, and request user B's rows directly through the REST API:
curl "https://YOUR_PROJECT.supabase.co/rest/v1/orders?user_id=eq.USER_B_ID" \
-H "apikey: YOUR_ANON_KEY" \
-H "Authorization: Bearer USER_A_ACCESS_TOKEN"
If you get rows back, you have the bug.
For the anonymous case (no login at all), I made a free check that runs in your browser and shows only row counts, never contents: flyready-audit.vercel.app/check.html
If you'd rather have someone else run all of this on your app, here's what my written audit looks like: sample report.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.