Can anyone call your Supabase Edge Function? verify_jwt, the public key and checking the user
By Abbi Labs · Last updated 1 December 2026
Scan your app free and see what a stranger can reach with your public key.
Abbi Labs checks Supabase tables readable with your public key, secret keys in your JavaScript, exposed .env and .git files, source maps, security headers, CORS (including Edge Functions found in your JavaScript), cookie flags and TLS. Read-only. No sign-up for the quick check.
No app handy?
Example result · our deliberately broken demo app
6 issues found: 3 critical, 1 high, 1 medium, 1 low
- Critical: Stripe live secret key in public JavaScript
- Critical: /.env file readable by anyone
- High: Git repository exposed (/.git/HEAD)
The demo's problems are planted on purpose. Paste your own URL above to see yours.
No sign-up. Read-only public-resource and protocol metadata checks. No model prompts or tool execution. Scan only sites you own or are allowed to test.
Run on every deploy or use from Cursor / Claude Code via MCP →
Weekly AI-app security checklist
One short email a week: a practical check for apps built with Supabase, Next.js and AI tools (RLS, leaked keys, headers and more). Unsubscribe anytime.
Your AI builder writes a Supabase Edge Function to send an email, call OpenAI or update a user's plan. You call it from the app with supabase.functions.invoke and get a 401. The suggested fix is to redeploy with --no-verify-jwt. The 401 goes away, and so does the only thing standing between that function and anyone on the internet.
Even if you never touched the setting, the default check is weaker than most people think. Facts below are from Supabase's Securing Edge Functions, Authorization headers and Function configuration docs and their Edge Function 401 troubleshooting page.
What verify_jwt actually checks
Every Edge Function request goes through a platform check called verify_jwt before your code runs. It's on by default. It looks at the Authorization header and returns a 401 if the token is missing, malformed or signed with a different key.
Here's the catch. Supabase's docs say that, for migration compatibility, the check also accepts your publishable and secret keys on either header, and that "the check alone doesn't authenticate a caller that sends only an API key." Your publishable key (sb_publishable_...) or legacy anon key is in your frontend by design (that part is fine). So anyone who copies it from DevTools gets past verify_jwt. Signed in or not.
In other words, verify_jwt on means "this caller has something from your project". It doesn't mean "this caller is a signed-in user", and it says nothing about which user.
And with verify_jwt off, it's open to anyone
There are three ways to turn the platform check off: verify_jwt = false for the function in supabase/config.toml (or config.jsonc), deploying with supabase functions deploy NAME --no-verify-jwt, or the JWT verification toggle on the function's page in the dashboard. Supabase's own docs warn that this "will allow anyone to invoke your Edge Function without a valid JWT."
That's correct for a few functions. A Stripe webhook has to be reachable without your tokens, and a health check is meant to be public. It's a problem for everything else, and it's an easy state to end up in. Supabase's 401 troubleshooting page says the legacy check only understands the legacy key format, and its fix is to turn the check off "and optionally handle auth in your function code." AI builders tend to do the first half.
What an open function costs you
- It calls a paid API. A function that forwards prompts to OpenAI or Anthropic with your key is now a free endpoint for whoever finds it. You pay.
- It uses the service role key. That client bypasses Row Level Security. Supabase warns that a handler querying a shared table with it, without filtering by the caller's ID, returns every user's rows.
- It trusts a user ID from the body. If the function does
update profiles set plan = 'pro' where id = body.userId, anyone can upgrade anyone. Same shape as changing an ID to see someone else's data. - It sends email or SMS. Your sending reputation and your bill, used by someone else.
Check yours in 3 minutes
- Find functions with the check off. Search your repo:
Then open Edge Functions in the Supabase dashboard and look at each function's JWT verification setting. The dashboard is what's live. Your repo might not match it.grep -n -B1 "verify_jwt" supabase/config.toml supabase/config.jsonc 2>/dev/null grep -rn "no-verify-jwt" . --include=*.json --include=*.sh --include=*.yml --include=*.md 2>/dev/null - Check each function's code for a user check. Open
supabase/functions/NAME/index.ts. Look forwithSupabase({ auth: 'user' }),auth.getClaims()orauth.getUser()on the caller's token, and whether the function rejects the request when that fails. Passing the caller'sAuthorizationheader into a Supabase client makes RLS apply to that client's queries, but anything else the function does (calling OpenAI, sending email, using the service role client) still runs for whoever called. - Test it signed out, on your own project only. With your project ref, function name and publishable key (the public one already in your frontend):
A function meant for signed-in users should return 401 before it does anything. If you get a 200, data, or a 400 complaining about a missing field, your code ran for a stranger. Pick an empty body or a harmless function, because this really does run your code (it can send that email).curl -i -X POST "https://YOUR_REF.supabase.co/functions/v1/FUNCTION_NAME" \ -H "apikey: YOUR_PUBLISHABLE_KEY" \ -H "Content-Type: application/json" \ -d '{}'
The fix: check the caller in the function
For functions your app calls on behalf of a signed-in user, leave verify_jwt on and verify the user in code. Supabase's current docs use the @supabase/server wrapper:
import { withSupabase } from 'npm:@supabase/server@1'
export default {
fetch: withSupabase({ auth: 'user' }, async (req, ctx) => {
// ctx.supabase runs as the caller, so your RLS policies apply
const userId = ctx.userClaims?.id
const { data, error } = await ctx.supabase
.from('profiles').select('*').eq('id', userId).single()
if (error) return Response.json({ error: error.message }, { status: 400 })
return Response.json(data)
}),
}- Callers without a valid user JWT get a 401 from the wrapper, so a publishable key alone no longer works.
- Prefer
ctx.supabase(the user's own permissions) overctx.supabaseAdmin(bypasses RLS). If you need the admin client, filter by the ID fromctx.userClaims, never one sent in the request. - For admin-only actions, check the user's role from somewhere they can't edit themselves (where to store roles safely).
Functions that really have no user
- Stripe, GitHub and other webhooks. Keep
verify_jwt = false, useauth: 'none', and verify the provider's signature on the raw body before doing anything. On Deno, Stripe needsconstructEventAsyncwith a SubtleCrypto provider. Details in the Stripe webhook guide. - Cron jobs, pg_net and other functions. Turn
verify_jwtoff for that function, send a secret key on theapikeyheader (never put a secret key in the frontend), and useauth: 'secret'so only that key gets in. - Genuinely public endpoints like a health check:
auth: 'none'is fine, as long as the function doesn't touch user data or anything that costs money.
A function that serves both users and internal jobs can take auth: ['user', 'secret'] and branch on ctx.authMode.
Paste this into your AI builder
Audit every Supabase Edge Function in supabase/functions.
For each one, tell me:
1. Is verify_jwt off (config.toml, config.jsonc or --no-verify-jwt)?
2. Who should be allowed to call it: a signed-in user, a webhook
provider, a cron job or anyone?
3. Does the code verify that caller before doing any work?
Then fix them:
- User functions: keep verify_jwt on and wrap the handler in
withSupabase({ auth: 'user' }) from npm:@supabase/server@1. Use
ctx.supabase for queries. Take the user id from ctx.userClaims,
never from the request body.
- Webhooks: verify the provider's signature before anything else.
- Cron/internal: auth: 'secret', secret key on the apikey header.
Don't fix a 401 by turning verification off without adding a check.
Show me the list and the diff before applying.What Abbi Labs checks
Honest scope: the free quick check finds up to two Supabase Edge Functions referenced in the JavaScript your site serves and sends each one an OPTIONS preflight with a foreign Origin, to catch CORS problems. It never sends a GET or POST to your functions, so it can't tell whether one checks the user. That needs the curl test above. What the scan does cover is the rest of what a stranger can do with your public key, starting with Supabase tables that answer anonymous reads.
FAQ
Does verify_jwt mean only signed-in users can call my Edge Function?
No. Supabase's docs say the verify_jwt platform check also accepts publishable and secret keys, on either the Authorization or apikey header, for migration compatibility, and that the check alone doesn't authenticate a caller who sends only an API key. Your publishable key (and the legacy anon key) is in your frontend, so anyone who opens DevTools has it. If the function should only serve signed-in users, check the user inside the function.
Is it safe to deploy with --no-verify-jwt?
Only if the function checks the caller itself. --no-verify-jwt, verify_jwt = false in supabase/config.toml and the JWT toggle in the dashboard all remove the platform check, and Supabase's docs warn this lets anyone invoke the function. That's right for a Stripe webhook that verifies Stripe's signature, or a health check. It's wrong for a function that reads user data, sends email or calls a paid API without its own check.
Why did my Edge Function start returning 401?
Supabase's 401 troubleshooting page lists a few causes: a missing Authorization header, an invalid or expired token, or an incompatible key format, because the legacy check only understands the legacy JWT format. Their suggested fix for the key format case is to turn the built-in check off and handle auth in your function code. The second half of that sentence is the part that gets skipped.
How do I check the user inside an Edge Function?
Supabase's current docs use the withSupabase wrapper from npm:@supabase/server@1 with auth: 'user'. It rejects callers without a valid user JWT and gives you ctx.supabase, a client that runs as that user so your RLS policies apply, plus ctx.userClaims with the user's id. Leave verify_jwt on for user-facing functions as well.
My function uses the service role key. Is that a problem?
Only if it trusts the caller. The service role client (ctx.supabaseAdmin in the wrapper) bypasses Row Level Security. Supabase's docs warn that a handler that queries a shared table this way without filtering by the caller's ID returns every user's rows. Use the user-scoped client where you can, and take the user ID from the verified claims, never from the request body.
How should webhooks and cron jobs authenticate?
Webhooks from Stripe or GitHub don't send Supabase credentials, so keep verify_jwt off and verify the provider's signature inside the handler. Cron jobs, pg_net and other internal callers should send a secret key on the apikey header, and the function should use auth: 'secret' so it accepts only that key.
Does Abbi Labs check this?
Not directly. The free quick check finds up to two Supabase Edge Functions referenced in your site's JavaScript and sends each one an OPTIONS preflight to test CORS. It never sends a GET or POST to them, so it can't tell whether a function checks the user. Use the curl test in this guide on your own project for that.
Related guides
- Is your Supabase anon key safe to expose? Yes, until your RLS says otherwise
- Stripe webhook signature verification (Next.js, Express and Supabase Edge Functions)
- Supabase service_role key exposed? Do this in the next 15 minutes
- Supabase RPC functions: revoke execute from anon and public
- OpenAI, Claude or Gemini API key exposed in your frontend? What to do now
- CORS misconfiguration: is your API readable by any website?