Over the past week I read through the public code of 145 recently shipped web apps built on Supabase — most of them Next.js, the stack AI coding tools reach for by default. I wasn't running scanners against anyone's servers. I read what the repos themselves publish: migration files, schema dumps, config. No repos are named here, and nothing was probed or tested live.
16 of the 145 — 11% — had at least one serious, exploitable-by-design problem sitting in plain sight. Here's what they were, because the patterns repeat almost word for word.
Pattern 1: The policy that lets everyone in (13 of the 16)
Row Level Security was enabled. The policies existed. They just didn't restrict anything:
CREATE POLICY "allow_all" ON orders
FOR ALL TO authenticated
USING (true) WITH CHECK (true);
Variations I kept seeing:
-
FOR SELECT USING (true)on tables holding names, emails, and phone numbers — any signed-in user can read every row. -
INSERT/UPDATEpolicies withWITH CHECK (true)— any signed-in user can write or modify anyone's data. - Policies with no
TOclause at all, which means they apply to the anonymous role too — no account needed.
These weren't edge-case tables. They were orders, customer records, CRM data, loan records, user profiles.
Pattern 2: Real secrets committed where they don't belong (3 of the 16)
Two were .env.example files containing values in real secret formats — auth secrets, webhook secrets, cron secrets, a database URL with the password in it. The filename says "example." The contents say otherwise. The third was a hardcoded secret-key default sitting in a config file — harmless only if production remembers to override it. Anything committed to a public repo should be treated as published, whether the filename sounds harmless or not.
The interesting zero
I found zero cases of a service_role key shipped in frontend code in this sample. A year of warnings about that one seems to have landed. The failure mode has moved: the keys are fine now — the policies are the open door.
Why AI keeps writing it this way
Watch what happens during an AI-assisted build. A query fails with a permission error. The fastest fix that makes the error go away is a permissive policy. The app works, the demo passes, the policy stays. Nobody in that loop ever asks the follow-up question: who else can read this table now? The code does exactly what it was optimized to do — stop erroring.
Check your own app in five minutes
-
Look at your policies. In the Supabase dashboard (Table Editor → your table → RLS policies), or in SQL:
SELECT policyname, cmd, qual, with_check FROM pg_policies WHERE schemaname = 'public';— anyqualthat is justtrueon a user-data table is a finding, not a convenience. - Test as a stranger. Create a second account, sign in as that user, and use your app's own public anon key to select rows from your users/orders table. If you get back other people's data, so can anyone.
-
Grep your history. Search your repo — including old commits — for
SERVICE_ROLE,SECRET, and real-looking values in.env*files. If a real secret ever landed in a public commit, rotate it; deleting the file doesn't unpublish it.
The short version
AI builders are very good at making apps that work and noticeably worse at making apps that refuse. If your RLS policies say true, your database is a public document with extra steps.
Disclosure: I run CapsAGI — fixed-price security checkups for AI-built apps. The checks above are the first things we look for. I also maintain a free, open-source rules pack that teaches Cursor and Claude Code not to write these patterns in the first place: https://github.com/shisanyue950901-beep/vibe-security-rules
Top comments (0)