cd /news/ai-safety/i-reviewed-the-database-policies-of-… Β· home β€Ί topics β€Ί ai-safety β€Ί article
[ARTICLE Β· art-171603] src=dev.to β†— pub= topic=ai-safety verified=true sentiment=↓ negative

I reviewed the database policies of 145 AI-built Supabase apps. 16 were wide open.

A developer who runs CapsAGI reviewed the public repositories of 145 recently shipped Supabase apps, most built with Next.js by AI coding tools, and found that 16 (11%) contained at least one serious, exploitable-by-design flaw. The dominant pattern was Row Level Security enabled with permissive policies such as USING (true) and WITH CHECK (true), sometimes with no TO clause, exposing orders, customer records, CRM data, loan records and user profiles to any signed-in or anonymous user. The reviewer found zero service_role keys in frontend code, concluding the failure mode has shifted from leaked keys to open policies, and published a free open-source rules pack to stop Cursor and Claude Code from writing these patterns.

recommendation

Audit pg_policies for any qual or with_check of true on user-data tables and add explicit TO clauses, since 11% of reviewed AI-built Supabase apps exposed data this way.

more in playbook: Securing agents and AI tools
by read3 min views2 publishedNov 18, 2026

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.

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 / UPDATE policies with WITH CHECK (true) β€” any signed-in user can write or modify anyone's data.TO clause 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.

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.

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.

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.

SELECT policyname, cmd, qual, with_check FROM pg_policies WHERE schemaname = 'public'; β€” any qual that is just true on a user-data table is a finding, not a convenience.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. 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

── more in #ai-safety 4 stories Β· sorted by recency
── more on @supabase 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/i-reviewed-the-datab…] indexed:0 read:3min 2026-11-18 Β· β€”