← All guides

How to Stop Fake Signups and Bot Abuse in Supabase Auth (CAPTCHA, Rate Limits and Signup Hooks)

Updated 2026-11-19

Short answer: anyone with your Supabase project URL and anon key (both are in your frontend) can call the Auth API directly, so a CAPTCHA on your signup page does nothing unless you also turn on CAPTCHA protection in Supabase itself. To stop fake signups: enable Bot and Abuse Protection with Cloudflare Turnstile or hCaptcha and pass captchaToken to signUp, keep "Confirm email" on, set a custom SMTP provider and sensible auth rate limits, block disposable or unwanted domains with the before-user-created hook, and make sure your RLS policies do not give a brand new or anonymous account access to anything valuable.

If your Lovable, Bolt, v0 or Cursor app suddenly has hundreds of accounts with random Gmail addresses, a pile of bounced confirmation emails, or a Resend or SendGrid bill you did not expect, this is the guide for you.

Why your signup form is not the real entry point

When you call supabase.auth.signUp() from the browser, the request goes straight from the user's browser to https://<project>.supabase.co/auth/v1/signup. Your Next.js app, your form validation and any middleware never see it. A bot does not need your page at all:

curl -X POST "https://<project>.supabase.co/auth/v1/signup" \
  -H "apikey: <your-anon-key>" \
  -H "Content-Type: application/json" \
  -d '{"email":"[email protected]","password":"password123"}'

That is why fixes like "disable the button after one click" or "add a honeypot field" do not stop scripted abuse. The protection has to be enforced by Supabase Auth or by a server you control.

Step 1: Turn on CAPTCHA in Supabase, not just in the UI

Supabase Auth supports Cloudflare Turnstile and hCaptcha. Turnstile is free and usually invisible to real users.

  1. Create a Turnstile widget in the Cloudflare dashboard and copy the site key and secret key.
  2. In Supabase, go to Authentication settings, then Bot and Abuse Protection, turn on Enable CAPTCHA protection, choose Turnstile and paste the secret key.
  3. Add the widget to your form and pass the token:
"use client";
import { useRef, useState } from "react";
import { Turnstile, type TurnstileInstance } from "@marsidev/react-turnstile";
import { createClient } from "@/lib/supabase/client";

export function SignUpForm() {
  const supabase = createClient();
  const [captchaToken, setCaptchaToken] = useState<string>();
  const captcha = useRef<TurnstileInstance>(null);

  async function onSubmit(email: string, password: string) {
    const { error } = await supabase.auth.signUp({
      email,
      password,
      options: { captchaToken },
    });
    captcha.current?.reset(); // tokens are single use
    if (error) console.error(error.message);
  }

  return (
    <Turnstile
      ref={captcha}
      siteKey={process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY!}
      onSuccess={setCaptchaToken}
    />
  );
}

Once CAPTCHA is on, Supabase rejects sign up, password sign in, magic link and password reset requests that arrive without a valid token, so every form that calls those methods needs the widget. The site key is public and fine in NEXT_PUBLIC_. The secret key goes only in the Supabase dashboard; see which keys are safe in NEXT_PUBLIC_ variables.

Step 2: Keep email confirmation on

Under the Email provider settings, Confirm email should stay enabled for most apps. With it off, a bot can create an account with someone else's address and is logged in immediately, and you have no proof the address belongs to the user.

Confirmation alone does not stop bots, because the confirmation email still gets sent. Bots that sign up with real victims' addresses turn your app into a spam cannon, which hurts your sending reputation. That is why CAPTCHA comes first.

If you do not need public signups at all (an internal tool or an invite-only beta), turn off Allow new users to sign up and invite users from the dashboard or a server route with the service role key.

Step 3: Custom SMTP and auth rate limits

The built-in Supabase email service is meant for testing and only sends a small number of emails per hour, and only to addresses in your project team. Real apps should set up custom SMTP (Resend, Postmark, SendGrid, Amazon SES) under Authentication settings. Once you do, review the Rate Limits page for Auth:

If you use phone auth, SMS is the expensive one. Bots trigger thousands of OTP messages to premium numbers (SMS pumping fraud), and you pay for each. Enable CAPTCHA, keep the SMS rate limit low, and restrict allowed countries in your SMS provider if you only serve a few.

Step 4: Block unwanted signups with the before-user-created hook

Supabase Auth hooks let you run a Postgres function (or an HTTP endpoint) before a user is created and reject the signup. This is the right place for rules like "no disposable email domains" or "company emails only":

create table if not exists public.blocked_email_domains (domain text primary key);
alter table public.blocked_email_domains enable row level security;
insert into public.blocked_email_domains values ('mailinator.com'), ('10minutemail.com');

create or replace function public.hook_block_disposable_emails(event jsonb)
returns jsonb
language plpgsql
as $$
declare
  email_domain text := lower(split_part(event->'user'->>'email', '@', 2));
begin
  if exists (select 1 from public.blocked_email_domains where domain = email_domain) then
    return jsonb_build_object('error', jsonb_build_object(
      'http_code', 403,
      'message', 'Please sign up with a permanent email address.'
    ));
  end if;
  return '{}'::jsonb;
end;
$$;

grant usage on schema public to supabase_auth_admin;
grant execute on function public.hook_block_disposable_emails to supabase_auth_admin;
grant select on public.blocked_email_domains to supabase_auth_admin;
revoke execute on function public.hook_block_disposable_emails from authenticated, anon, public;

create policy "auth admin reads blocked domains"
on public.blocked_email_domains for select
to supabase_auth_admin
using (true);

Then enable it under Authentication, Hooks, as the "Before User Created" hook pointing at this function. The revoke matters: without it, anyone could call the function through the Data API. The security definer functions guide explains why exposed functions need locking down.

Step 5: Assume every new account is hostile

CAPTCHA raises the cost of fake accounts, it does not make them impossible. Someone can always solve a challenge by hand and get a real, confirmed account. So check what a fresh account can do:

If you use anonymous sign-ins

Anonymous users get the authenticated role too, so any policy to authenticated includes them. Exclude them where they should not have access:

create policy "only permanent users can post"
on public.posts for insert
to authenticated
with check (
  (select (auth.jwt()->>'is_anonymous')::boolean) is false
  and (select auth.uid()) = user_id
);

Turn on CAPTCHA if anonymous sign-ins are enabled, or a script can mint unlimited anonymous sessions.

Cleaning up fake accounts you already have

Find suspicious users in the SQL editor:

select id, email, created_at, email_confirmed_at, last_sign_in_at
from auth.users
where email_confirmed_at is null
  and created_at < now() - interval '7 days'
order by created_at desc;

Review the list, then delete users from the dashboard or with supabase.auth.admin.deleteUser(id) from a trusted server script. Check that tables referencing auth.users use on delete cascade (or clean them up first) so you do not leave orphaned rows.

Quick test

  1. Run the curl command above without a captcha_token in the body. With CAPTCHA enabled it should fail with a captcha error.
  2. Sign up with a blocked domain and confirm you get your hook's error message.
  3. Sign up normally, skip confirmation, and try to read another user's data with the fresh session. It should return nothing.

Get an automated check

PreflightPR reviews AI-built apps for missing Supabase RLS, policies that allow every authenticated user, user_metadata used for authorization, leaked keys and other launch blockers. Run a free scan on a public repo for a launch score and a prioritized fix list, or install the PreflightPR GitHub App to check every pull request before it merges.

Check your repo in about a minute

Paste a public GitHub URL and get a free launch score.

Run a free scan

More guides