Guides · VibeVigil
Is My Waitlist Leaking Emails? How to Lock Down a Supabase Waitlist or Contact Form in a Lovable, Bolt or v0 App
Your landing page saves waitlist sign-ups or contact messages to Supabase. Here's how to check if a stranger can read, change or delete that list, the insert-only RLS policy that fixes it, why '.select()' and 'upsert' quietly open it up, how to slow down spam, and a prompt for Lovable, Bolt, v0 or Cursor.
Not sure your app is safe? Run a free scan first.
VibeVigil checks your live app for exposed keys, Supabase tables a stranger can read, missing security headers, SSL problems and downtime. Every issue comes with a ready-to-paste prompt for your coding agent.
Scan my app for free → (only scan apps you own)
Is My Waitlist Leaking Emails?
You asked your AI tool for a landing page with a "Join the waitlist" box, or a contact form. It works. Names and emails show up in a Supabase table.
Here is the question most people never ask: if anyone can add a row to that table, can anyone also read it?
A waitlist is a list of real people's emails. A contact form can hold names, phone numbers and private messages. This guide shows how to check your form in about 10 minutes, and how to fix it so visitors can add to the list but never see, change or delete it.
The short answer
- Your public key is supposed to be public. Your site sends a Supabase key to every visitor's browser. That is normal. What protects the table is Row Level Security (RLS) and its policies.
- A form only needs one thing: insert. Logged-out visitors should be able to add a row. That's it. No read, no update, no delete.
- The common mistake is a read policy for everyone. If the table has a policy like "anyone can select" with
true, anyone with your public key can download the whole list. .select()after.insert()is often how it happens. Asking for the new row back makes Postgres check read rules too. When that fails, AI tools often "fix" it by letting everyone read the table.- You don't need a read policy to see your own list. The Supabase dashboard (Table Editor) can show you every row without one.
Why this happens
Supabase gives each table two locks:
- Grants decide if a role, like
anon(logged-out visitors), can touch the table at all. - RLS policies decide which rows that role can read, add, change or delete.
With RLS on and no policy, Postgres says no to everything: "If no policy exists for the table, a default-deny policy is used" (PostgreSQL: CREATE POLICY). So when your AI tool builds a form, it has to add at least one policy. Here is where it can go wrong:
Problem 1: the code asks for the row back. In supabase-js, an insert does not return anything by default. Supabase's docs say: "By default, inserted rows are not returned. To return it, chain the call with .select()" (Supabase: insert). If the code does .insert(...).select(), Postgres also checks the read rules. Postgres says that if the new row does not pass the SELECT policies, "an error will be thrown" (PostgreSQL: CREATE POLICY). The form breaks with a "new row violates row-level security policy" error. The quick "fix" is a read policy for everyone. Now the list is public.
Problem 2: the code uses upsert to skip duplicates. An upsert can turn into an update when the email is already there. That needs read and update rules too. So the AI adds them, and now strangers can read and change rows.
Problem 3: one policy for "ALL". A policy written for all ... using (true) means anyone can read, change and delete every row, not just add one.
Problem 4: RLS was never turned on. If RLS is off, anyone with your public key can read and change the table. Supabase's Security Advisor flags this (Supabase: Database Advisors).
How to check your form
You only need the Supabase dashboard. Do this for each table a public form writes to (for example waitlist, subscribers, leads, contact_messages).
Step 1: Look at the policies
In the Supabase dashboard, open the Policies page (or open the table in the Table Editor and look at its RLS policies). For a safe form table you want to see:
- RLS is enabled.
- One policy for INSERT, for the
anonrole (andauthenticatedif logged-in users use the form too). - No SELECT, UPDATE, DELETE or ALL policy for
anon,publicorauthenticated.
You can also run this in the SQL Editor. Change waitlist to your table name:
select policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public' and tablename = 'waitlist';Any row where cmd is SELECT, UPDATE, DELETE or ALL, and roles includes anon or public, needs a closer look.
Step 2: Try to read the list like a stranger
Find your project URL and your public key (the publishable key, or the older anon key) in your project's API settings. Then run this in a terminal, with your own values:
curl "https://YOUR-PROJECT.supabase.co/rest/v1/waitlist?select=*" \
-H "apikey: YOUR_PUBLIC_KEY"[](an empty list) or a "permission denied" error: good. Strangers can't read it.- Real emails come back: anyone can download your list right now. Go to the fix below.
This is a read-only test. Only test projects you own.
Step 3: Run the Security Advisor
In the dashboard, open Advisors → Security Advisor. Fix anything that says RLS is disabled on a table in public.
How to fix it
The insert-only setup
Run this in the SQL Editor. It turns on RLS, removes old policies you name, and lets visitors add rows and nothing else. Change the table and column names to match yours.
-- 1. Make sure RLS is on
alter table public.waitlist enable row level security;
-- 2. Remove risky policies (use the names you saw in Step 1)
-- drop policy "Enable read access for all users" on public.waitlist;
-- 3. Visitors can add a row, nothing else
create policy "Anyone can join the waitlist"
on public.waitlist
for insert
to anon, authenticated
with check (true);
-- 4. Make sure visitors are allowed to insert
grant insert on public.waitlist to anon, authenticated;Your table may also have a SELECT grant for anon. On its own, that does not leak anything: with RLS on and no SELECT policy, a stranger gets zero rows back. The policy is what opens the door, so that is what to remove.
Then make sure the app code does a plain insert, with no .select() after it:
const { error } = await supabase
.from('waitlist')
.insert({ email });If your project's new tables need a GRANT before the Data API can reach them, our 42501 guide explains that change. The rule still holds: grant insert, not everything.
Stop junk and duplicates in the database
Your public key can be copied, so anyone can call your table directly and skip your form's checks. Put the important checks in the database, where they can't be skipped:
-- Keep values short and email-shaped
alter table public.waitlist
add constraint email_length check (char_length(email) between 3 and 254),
add constraint email_shape check (email ~* '^[^@\s]+@[^@\s]+\.[^@\s]+$');
-- One sign-up per email (case-insensitive)
create unique index waitlist_email_unique on public.waitlist (lower(email));Postgres check constraints reject any row that breaks the rule (PostgreSQL: Constraints). Do the same for contact forms: set a max length on the message and name.
With the unique index, a second sign-up with the same email fails with an error. That's fine. Show "You're already on the list!" instead of using upsert.
Don't store anything a visitor shouldn't control in the form table, like is_approved, invite_sent or priority. Set those from your own admin tools.
Slow down spam bots
The steps above stop leaks. They don't stop a bot from adding thousands of fake rows. If spam becomes a problem:
- Add a hidden "honeypot" field to the form. People can't see it, but simple bots fill it in. Ignore rows where it has a value.
- For stronger protection, add a CAPTCHA like Cloudflare Turnstile and check the token on a server, not in the browser. Cloudflare says the token must be checked server-side with its Siteverify API (Cloudflare: Turnstile server-side validation). A Supabase Edge Function can do this, then save the row.
- If you move the insert into an Edge Function, you can drop the
anoninsert policy so the table can't be reached from the browser at all.
If you want to see the list inside your app
Seeing the list in the Supabase dashboard is enough for most people. If you build an admin page, add a SELECT policy that allows only admins, never true. See How to Protect Admin Routes and Roles.
If your form sends you an email
Many forms also send a "New sign-up!" email through Resend, SendGrid or similar. That email API key is a secret. It must live in server code (like an Edge Function), never in a VITE_ or NEXT_PUBLIC_ variable. See How to Check if Your Vibe-Coded App Is Leaking API Keys.
Prompt for your coding agent
Paste this into Lovable, Bolt, v0 or Cursor. Change the table name if yours is different.
My landing page saves waitlist / contact form entries to the Supabase table public.waitlist.
Logged-out visitors must be able to ADD a row, and nothing else.
1. Make sure RLS is enabled on public.waitlist.
2. List every policy on this table. Remove any SELECT, UPDATE, DELETE or ALL policy for anon, public or authenticated.
3. Add one INSERT policy for anon and authenticated with "with check (true)".
4. Make sure anon and authenticated have the INSERT grant on this table. Do not grant UPDATE or DELETE to them.
5. In the frontend, use a plain .insert() with NO .select() after it, and do not use upsert.
6. Add check constraints: email between 3 and 254 characters and shaped like an email; message and name with a max length.
7. Add a unique index on lower(email). If the insert fails because the email already exists, show "You're already on the list!".
8. Make sure the Supabase service role key and any email API key (Resend, SendGrid) are only in server code, never in VITE_ or NEXT_PUBLIC_ variables.
9. Give me a curl command to test, with only the public key, that reading the table returns [] or an error.
Do not add a SELECT policy with "using (true)" to fix an insert error.Quick checklist
- [ ] RLS is on for every table a public form writes to
- [ ] Only an INSERT policy for visitors, no SELECT / UPDATE / DELETE / ALL
- [ ] Visitors have the INSERT grant, and no UPDATE or DELETE grant
- [ ] The code uses a plain
.insert(), no.select(), noupsert - [ ] The stranger test (
?select=*with the public key) returns[]or an error - [ ] Length, email-shape and unique-email checks live in the database
- [ ] Email and service role keys are only on the server
- [ ] Security Advisor shows no "RLS disabled" warnings
Related guides
- How to Check if Supabase RLS Is Enabled (and Actually Working)
- Supabase "permission denied for table" (Error 42501): What Changed on October 30 and How to Fix It Safely
- Can Strangers Sign Up to My "Private" Lovable or Supabase App? How to Check and Close the Door
- How to Check if Your Vibe-Coded App Is Leaking API Keys
Sources
- Supabase docs, JavaScript
insert()(rows are not returned unless you chain.select()): https://supabase.com/docs/reference/javascript/insert - Supabase docs, JavaScript
upsert(): https://supabase.com/docs/reference/javascript/upsert - Supabase docs, Row Level Security: https://supabase.com/docs/guides/database/postgres/row-level-security
- Supabase docs, Securing your API: https://supabase.com/docs/guides/api/securing-your-api
- Supabase docs, Database Advisors (Security Advisor): https://supabase.com/docs/guides/database/database-advisors
- Supabase changelog, tables not exposed to the Data API automatically: https://supabase.com/changelog/45329-breaking-change-tables-not-exposed-to-data-and-graphql-api-automatically
- PostgreSQL docs, CREATE POLICY (default deny; RETURNING rows must pass SELECT policies): https://www.postgresql.org/docs/current/sql-createpolicy.html
- PostgreSQL docs, Constraints (check constraints): https://www.postgresql.org/docs/current/ddl-constraints.html
- Cloudflare docs, Turnstile server-side validation: https://developers.cloudflare.com/turnstile/get-started/server-side-validation/
Want a check on the public side of your app? VibeVigil looks for exposed keys, open Supabase tables, headers, SSL and uptime, and gives you a fix prompt for each issue. Run a free scan → (only scan apps you own)
Scan your app free. It checks the public page of a site you own. No account.