Browser writes directly to the database
Scan rule · RSC-SEC-035
- Security
- Severity: Medium
- CWE-602
- OWASP A04-2021
Finds write calls (`insert`, `update`, `upsert`, `delete`, storage upload) in shipped code or in `use client` files.
Why this matters
This is the single most common pattern in AI-built apps: the component calls `supabase.from("table").insert(...)` and the browser talks to the database directly. In our own vibe-code audit that was the case in 5 of 12 generated features.
It is not a flaw by itself — Supabase is built for it. But it moves all access control into the database: from here on only Row Level Security decides WHO may write, and nobody checks WHAT gets written. No schema check, no rate limit, no spam protection — a contact form without a server is also an open write channel.
Check: for every table named, is there a policy binding that specific operation to `auth.uid()`? If a delete runs from the browser, doubly so. Anything that needs validation or limits (forms, payments, invitations) belongs behind its own endpoint.
Scan tier
- External scan (anonymous)
- Source code from source maps
- Repo access (deep scan)
How to fix it
Route write paths through a server endpoint with validation and rate limiting; verify an RLS policy per table and operation, scoped to the user.