{"slug": "i-reviewed-the-database-policies-of-145-ai-built-supabase-apps-16-were-wide-open", "title": "I reviewed the database policies of 145 AI-built Supabase apps. 16 were wide open.", "summary": "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.", "body_md": "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.\n\n16 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.\n\nRow Level Security was enabled. The policies existed. They just didn't restrict anything:\n\n```\nCREATE POLICY \"allow_all\" ON orders\n  FOR ALL TO authenticated\n  USING (true) WITH CHECK (true);\n```\n\nVariations I kept seeing:\n\n`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.\nThese weren't edge-case tables. They were orders, customer records, CRM data, loan records, user profiles.\n\nTwo 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.\n\nI 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.\n\nWatch 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.\n\n`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.\nAI 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.\n\n*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](https://github.com/shisanyue950901-beep/vibe-security-rules)*", "url": "https://wpnews.pro/news/i-reviewed-the-database-policies-of-145-ai-built-supabase-apps-16-were-wide-open", "canonical_source": "https://dev.to/capsagi/i-reviewed-the-database-policies-of-145-ai-built-supabase-apps-16-were-wide-open-1h81", "published_at": "2026-11-18 06:09:05+00:00", "updated_at": "2026-11-18 06:13:17.167911+00:00", "lang": "en", "topics": ["ai-safety", "ai-tools", "ai-agents", "developer-tools"], "entities": ["Supabase", "Next.js", "Cursor", "Claude Code", "CapsAGI"], "also_reported_by": [], "takeaway": "In a review of 145 AI-built Supabase apps, 16 (11%) had permissive RLS policies like USING (true) or WITH CHECK (true) exposing user data, while zero leaked service_role keys were found in frontend code.", "recommendation": {"advice": "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.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/i-reviewed-the-database-policies-of-145-ai-built-supabase-apps-16-were-wide-open", "markdown": "https://wpnews.pro/news/i-reviewed-the-database-policies-of-145-ai-built-supabase-apps-16-were-wide-open.md", "text": "https://wpnews.pro/news/i-reviewed-the-database-policies-of-145-ai-built-supabase-apps-16-were-wide-open.txt", "jsonld": "https://wpnews.pro/news/i-reviewed-the-database-policies-of-145-ai-built-supabase-apps-16-were-wide-open.jsonld"}}