About 1 in 5 public Lovable apps would leak data or keys. Here are the rules your AI should read before it writes code.
A common pattern in our studies is a few lines an AI writes to get something working that nobody comes back to: a table rule that lets everyone in, a USING (true) rule for updates or deletes, a paid AI key in a VITE_ variable. The 1-in-5 File writes those lessons as rules for the AI itself. Give it to your builder once and it reads them before it changes your code.
Priberry makes Launch Blockers, the open-source checker behind our studies. This file lives in its GitHub repo under Apache-2.0: copy it, change it, share it. Rules lower the odds of a leak; they don't prove an app is safe, so check before you ship.
The 1-in-5 File
# The 1-in-5 File: security rules for the AI that builds your app
About 1 in 5 public Lovable apps would leak data or keys ([Priberry's study](https://priberry.com/research/lovable-leaks/)). These rules come from Priberry's studies of public Lovable apps. Drop this file into your AI builder as Lovable Knowledge, CLAUDE.md, AGENTS.md, .cursor/rules or .windsurfrules.
From [Launch Blockers](https://github.com/priberry-data/launch-blockers), Apache-2.0 like the rest of the repo: copy it, change it, share it.
## Rules
Follow these rules before you write or change any code in this project. If a request would break one, say so and build the safe version instead.
### The database
- Turn on row-level security on every table before launch. Every table that holds personal data (email, phone, address, birth date, messages, payments, health) gets policies scoped to its owner, such as `auth.uid() = user_id`. About 1 in 7 public Lovable apps with a database would leave personal data open to anyone: 44 of 322 ([study](https://priberry.com/research/lovable-open-tables/)).
- Never write `USING (true)` on a table with private columns. A read policy covers every column in the row, so keep public fields (name, avatar) in their own table or in a view that selects only those columns.
- Never write `USING (true)` or `WITH CHECK (true)` for INSERT, UPDATE or DELETE. Only the row's owner, or a role you check on the server, may change a row.
- Every UPDATE policy needs `WITH CHECK` as well as `USING`, so users can't change their own `role`, `is_admin`, `plan` or `user_id` column. Keep roles in a table users can't write to.
- Never decide who someone is from `user_metadata` or `raw_user_meta_data` in a policy: users can edit it themselves.
- Create views `WITH (security_invoker = true)`. A `SECURITY DEFINER` function must check `auth.uid()` itself and set `search_path`.
- Storage buckets that hold users' files are private. Hand out signed URLs, never a public bucket.
### Keys and secrets
- Never put a paid AI key (OpenAI, Gemini, Anthropic, OpenRouter, Groq, Mistral, ElevenLabs...) in browser code or in a `VITE_`, `NEXT_PUBLIC_` or `EXPO_PUBLIC_` variable. Call the AI from an edge function or server route that checks the user is signed in, and keep the key there. About 1 in 30 public Lovable apps would ship an AI key to every visitor: 37 of 1,167 ([study](https://priberry.com/research/lovable-ai-keys/)).
- Never ship a Supabase `service_role` key or `sb_secret_` key to the client. Browser code uses only the anon or publishable key, and row-level security does the protecting.
- Never check a password, admin code or invite code in browser code. Anyone can read it in the page source.
- Never commit `.env` or any file with a secret in it. Put `.env` and `.env.*` in `.gitignore`, with `!.env.example` so you can commit an example file with empty values.
- If a key was ever in browser code, a commit or a deployed build, treat it as leaked: revoke and replace it first, then fix the code. Steps per provider: [Key Panic](https://greenlit.priberry.com/blockers/key-panic/), or `npx launch-blockers panic <provider>`.
### Server code
- In any function that uses the `service_role` key, never trust a user id, email or role sent in the request body, query or headers. Get the user from the verified token (`supabase.auth.getUser()`) and check they own the row before reading or writing it.
- Every edge function checks the caller is signed in, unless it is meant to be public. Payment webhooks verify the provider's signature before doing anything.
- Access checks run on the server or in the database. Hiding a button in the browser is not an access check.
- Before launch, run `npx launch-blockers check` and fix every blocker it reports.
## Check before you ship
Priberry makes six free, open-source tools:
- **Launch Blockers**: the leaks AI-built apps ship, checked in your code. `npx launch-blockers check`
- **Rolelock**: can your users raise their own role? Finds two holes in Supabase apps: signed-in users who can raise their own role, and edge functions that use the secret key with an id from the request. `npx rolelock@0.1.1 ./my-app`
- **Greenlit**: what a stranger can see in your live app. `npx greenlitlab yourapp.com --mine`
- **Crumple**: a crash-test lab for AI coding agents. `npx crumplelab attack`
- **Tare**: where your coding agent's tokens go. `npx tarelab`
- **MarkOS**: an AI exec team on your own computer, [markos.priberry.com](https://markos.priberry.com). `git clone https://github.com/priberry-data/markos && cd markos && ./install.sh`
Copy puts the whole file on your clipboard, exactly as shown. Or download AGENTS.md.
Where to put it
Paste it into your project's Knowledge.
Save it as CLAUDE.md in the project folder, or add it to the one you have.
Save it as AGENTS.md in the project folder.
Let the command below write .cursor/rules/launch-blockers.mdc, set to apply to every request.
Or let one command write it
npx launch-blockers rules
Run it in your project folder. It writes the rules to AGENTS.md, inside a marked block: run it again later and it replaces that block, never adds a second copy, and leaves the rest of your file alone.
npx launch-blockers rules --claudewritesCLAUDE.mdnpx launch-blockers rules --cursorwrites.cursor/rules/launch-blockers.mdcnpx launch-blockers rules --printprints the rules so you can paste them into Lovable Knowledge or.windsurfrules
Then check what's already there: npx launch-blockers check reads your code on your machine and never prints a secret.
Where the rules come from
Check before you ship
Priberry makes six free, open-source tools:
users who can raise their own role, checked in your supabase/ folder
npx rolelock@0.1.1 ./my-appMore studies: priberry.com/research · Free from Priberry: Launch Blockers, Rolelock, Greenlit, Crumple, Tare, MarkOS · Rules file: launch-blockers/rules/AGENTS.md