Guide · Supabase · Updated
Supabase service_role key exposed? What to do in the next hour
Rather check your own app first and read later? Paste its address, prove it’s yours, and the free scan shows you the worst thing a stranger can reach. Run the free scan
The anon key in your page is meant to be public. This one isn’t. If you’ve just found your Supabase service_role key, or the newer secret key that replaces it, in your JavaScript, in a public repo, or in an env variable that starts with NEXT_PUBLIC_ or VITE_, you’re right to worry. That key ignores every row level security policy you wrote, and it can list, change and delete your users. Here is the order we’d go in, with nothing skipped: make sure it really is that key, find every copy, move the code that needed it to your server, rotate it the way Supabase documents today, then read your logs for anyone who used it.
New to this? Our vibe coding security checklist has eleven checks for any AI-built app. If the key turns out to be the public one, you want Supabase anon key exposed? instead. For Stripe, OpenAI and other keys in your bundle, see leaked API keys in your frontend bundle.
If someone may be using it right now
Then don’t wait for the rest of this page. Supabase’s guide to rotating a leaked key says that if someone is actively using it, you should retire it right away, “even though components that still use it stop working until you replace it.” A broken admin page for an hour is a better day than someone else holding the master key. Go to step 4, do the retire part first, and come back.
Why this is so much worse than the anon key
With your public key, a stranger is treated like a signed-out visitor, and your RLS policies decide what they see. With this key, they’re treated like your own server. Supabase’s API keys guide puts it in one line: the secret key “bypasses Row Level Security, so it must never leave your control.” Both the secret key and the older service_role key act as the service_role Postgres role, which “has the BYPASSRLS attribute, so it skips every Row Level Security policy you attach.” The same page has a warning box titled “A leaked secret key exposes all of your project’s data.”
Here is what that means in practice, all from Supabase’s own docs:
- Every table the API can reach, every row. Reading, writing and deleting, whatever your policies say. Supabase notes that a missing table grant still stops it, but no policy you wrote will.
- Your users. The JavaScript reference says every method under
supabase.auth.adminrequires a secret key. Supabase Auth’s API description lists those admin endpoints under/auth/v1/admin/: list users, update a user’s account, delete a user, and generate links. That last one returns the magic link or password-reset link for an email address straight in the response, asaction_link, along with the one-time code. - Your files. Supabase’s Storage access control page says service keys “entirely bypass RLS policies, granting you unrestricted access to all Storage APIs.”
- The map. Supabase stopped handing your schema description to the anon key this year, but its change notice says the endpoint “remains accessible” with the
service_roleor secret keys. So whoever has the key also gets the full list of your tables and columns. - Time. The old
eyJkeys don’t age out on their own. Supabase’s signing keys page lists, among the reasons it moved away from them, that those JWTs “had 10-year expiry duration.” Nothing about a leaked one gets better by waiting.
The newer secret keys have one extra guard. Supabase returns a 401 when a secret key is used from a browser, going by the User-Agent header. Don’t lean on it. The API keys guide says in the same breath that “an attacker can still use the key from other tools,” and the migration guide lists that browser check as one of the protections “the service_role key doesn’t have.”
We wanted to see how it usually happens, so we built two small apps the way an AI builder might write them: a Next.js 16.4.4 app and a Vite 7.3.7 app, each with a “Delete my account” button that called supabase.auth.admin.deleteUser() from the browser with the service_role key in a browser-prefixed variable. We used fake keys signed with a made-up secret, never real ones. In both builds the key landed in a JavaScript file anyone can download, and in neither did the word service_role appear in those files, because the role sits base64-encoded inside the key. We then fixed it and ran the fixed version against a stand-in for Supabase Auth. Each step below says what we saw.
The six steps
Steps 1 and 2 tell you what you’re dealing with. Step 3 makes sure the new key won’t leak the same way, which Supabase asks you to do before you rotate. Step 4 is the rotation. Steps 5 and 6 are about what already happened and what happens next.
- Make sure it really is the secret key
- Find every copy, and how it got there
- Move the admin calls to your server first
- Rotate the key with Supabase’s steps
- Read your logs for anyone who used it
- Make the next leak harder
01
Make sure it really is the secret key
Don’t go by the variable name. A variable called SERVICE_ROLE_KEY can hold the public key, and a secret key can end up in one called ANON_KEY. Go by the value. Supabase has two key formats, and its API keys guide says the new ones “are short strings, not JWTs”:
sb_secret_…is a secret key. This is the bad one.sb_publishable_…is a publishable key. It’s meant to be in your page. Head to the anon key guide instead.- A long key starting with
eyJis a legacy key, and a JWT. It could beanonorservice_role, and the only way to tell is to read theroleclaim inside. Supabase’s JWT docs describe that claim as “the Postgres role to use when applying Row Level Security policies.”
This checks all three. Paste it into the Console of your own browser, or save it as a file and run it with node. It decodes the key on your machine and sends it nowhere:
// Paste into the Console of your own browser (or run with node). The key never leaves your machine.
const key = "PASTE_THE_KEY_HERE".trim();
if (key.startsWith("sb_secret_")) console.log("Secret key. This one must never be public.");
else if (key.startsWith("sb_publishable_")) console.log("Publishable key. Meant to be public.");
else if (key.startsWith("eyJ")) {
const payload = JSON.parse(atob(key.split(".")[1].replace(/-/g, "+").replace(/_/g, "/")));
console.log(`Legacy JWT key, role "${payload.role}"`); // "service_role" is the one that must never be public
} else console.log("Not a Supabase API key format we know.");Run against our four fake keys, it printed:
Legacy JWT key, role "service_role"
Legacy JWT key, role "anon"
Secret key. This one must never be public.
Publishable key. Meant to be public.If it says service_role or secret key, keep going. If it says anon or publishable, breathe out: that key is designed to be public, and what matters is your RLS. The RLS checklist and our free Supabase RLS checker are the next stop.
02
Find every copy, and how it got there
You need to know every place the key lives before you rotate, or you’ll break something you forgot about, and you need to know how it got out, or the new one will follow it. These are the usual ways.
A browser prefix. Next.js’s environment variables docs say that a variable starting with NEXT_PUBLIC_ is inlined “at build time, into the js bundle that is delivered to the client.” Vite’s env docs say VITE_* variables “should not contain sensitive information such as API keys” because they are “bundled into your source code at build time.” Supabase’s own example .env in the API keys guide says it plainly: “Server-only. Never prefix these, or your bundler will ship the key.” Its JWT docs name NEXT_PUBLIC_, VITE_ and PUBLIC_ as the prefixes that cause this.
One detail that catches people: Next.js says that after a build, “all NEXT_PUBLIC_ variables will be frozen with the value evaluated at build time.” Deleting the variable in your host’s dashboard changes nothing in builds that already ran. Only rotating the key makes those copies useless.
Admin code in the browser. This is the one we reproduced. A feature like “delete my account”, “invite a teammate” or an admin dashboard fails with the public key, because it needs the admin API. The builder makes the error go away by swapping in the key that works:
"use client";
import { createClient } from "@supabase/supabase-js";
// What an AI builder writes when "delete my account" fails with the public key:
// it reaches for the service_role key and puts it where the browser can read it.
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_SERVICE_ROLE_KEY!
);
export default function DeleteAccount() {
async function onDelete() {
const { data } = await supabase.auth.getUser();
if (data.user) await supabase.auth.admin.deleteUser(data.user.id);
}
return <button onClick={onDelete}>Delete my account</button>;
}Supabase’s JavaScript reference says the admin methods “should be called on a trusted server. Never expose your secret key in the browser.” In our Next.js build, that one file put the full service_role key into a chunk under .next/static/chunks/. In the Vite build it was in dist/assets/index-….js. A plain search for the word service_role found nothing in either, because the role is base64-encoded inside the key. A secret key we read only on the server (no prefix) wasn’t in either build at all.
To find it in your own code, run this in your project folder. The second part prints variable names, not values:
# Run in your project folder.
# 1. Code that names the secret key or calls the admin API. If the file has "use client"
# at the top, or it's a Vite/React component, it runs in the browser.
grep -rnE "SERVICE_ROLE|SECRET_KEY|sb_secret_|auth\.admin" . \
--include='*.js' --include='*.jsx' --include='*.ts' --include='*.tsx' --include='*.vue' --include='*.svelte' \
--exclude-dir=node_modules --exclude-dir=.next --exclude-dir=dist
# 2. Env variables with a browser prefix and a secret-sounding name (prints names, not values).
grep -rnoE "(NEXT_PUBLIC|VITE|PUBLIC)_[A-Z_]*(SERVICE|SECRET)[A-Z_]*" . --include='.env*' --exclude-dir=node_modulesOn our two leaky apps it listed the browser file, the admin call, and the prefixed variable in .env.local and .env. Any hit in a file that runs in the browser is a leak, even if the page is “only for admins”: the JavaScript downloads for everyone.
Your build and your live site. Our leaked keys guide has a script that searches your build output and decodes every eyJ key it finds, and another that downloads every script your live site serves, including the ones that only load after a click. Run both. The live one tells you whether the key is public right now.
Git history. A .env committed once and deleted later is still in the history. This reads every commit on every branch and decodes what it finds:
# Run in your project folder. Reads every commit on every branch, including files you later deleted.
# 1. New-style secret keys (prints only the first 16 characters)
git log --all -p | grep -oE 'sb_secret_[A-Za-z0-9_-]+' | cut -c1-16 | sort -u
# 2. Old-style eyJ keys, decoded. The role is base64 inside the key,
# so a plain search for "service_role" never finds them.
git log --all -p | grep -oE 'eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+' | sort -u |
node -e '
for (const t of require("fs").readFileSync(0, "utf8").split("\n").filter(Boolean)) {
let role = "(not readable)";
try { role = JSON.parse(Buffer.from(t.split(".")[1], "base64url")).role ?? "(no role)"; } catch {}
console.log(role, "ends in", t.slice(-12));
}'Then, to see which commits added or removed one:
# Which commits added or removed it? Use the last 12 characters it printed
# (or the first 16 of an sb_secret_ key).
git log --all -S'PASTE_THOSE_CHARACTERS' --format='%h %ad %an %s' --date=shortWe tested both on a small repo where a .env with a service_role key was committed and then untracked, and a secret key was added and deleted on a side branch. A case-sensitive search of the whole history for service_role found zero lines. The scripts found both keys and the commits:
sb_secret_LABFAK
anon ends in OOdBl_tMLMoM
service_role ends in LZddD5jn8ZeU
# then, with when.sh:
2026-11-02 lab stop tracking .env
2026-11-02 lab add envIf the repo is public, or was at any point, treat the key as taken. GitHub’s list of supported secret scanning patterns includes “Supabase Secret Key”, with partner alerts, user alerts and push protection, but we found no entry there for the older service_role JWT. Under its partner program, GitHub tells the provider when it finds a key in a public repository, and the provider “decides whether they should revoke the secret, issue a new secret, or contact you directly.” Useful, but not something to wait for.
Should you rewrite your history to get the key out? GitHub’s own guide to removing sensitive data says the first step is to revoke or rotate the secret, and that once you have, rewriting history “may not be warranted.” It also says commits can stay reachable in clones and forks. Rotate first, then decide. If the key was in a .env your site served, our exposed .env and .git guide covers taking that file offline.
Everywhere else you pasted it. Supabase’s list of places a secret key must never go includes chat, email, URLs and logs, and source control “including CI scripts.” If you pasted the key into a chat with an AI tool or a teammate, count that as a copy too.
03
Move the admin calls to your server first
Supabase’s rotation guide starts with: “Fix the root cause of the leak before you rotate anything. Otherwise the new key can leak the same way.” For most vibe-coded apps the root cause is step 2’s admin call in the browser. So before touching the dashboard, move it.
First ask whether the feature needs the key at all. Reading and changing the signed-in user’s own rows doesn’t: that’s what the normal client and an RLS policy are for. The admin key is for things only your server should decide, like deleting an account from auth.users, inviting users, or a nightly job. For those, three small files. A server-only admin client:
// lib/supabase/admin.ts
import "server-only";
import { createClient } from "@supabase/supabase-js";
// Server only. The secret key has no NEXT_PUBLIC_ prefix, and the import above
// makes the build fail if a Client Component ever imports this file.
export const supabaseAdmin = createClient(
process.env.SUPABASE_URL!,
process.env.SUPABASE_SECRET_KEY!,
{ auth: { persistSession: false, autoRefreshToken: false } }
);The import "server-only" line is from Next.js’s Server and Client Components docs: if a Client Component ever imports this file, “there will be a build-time error.” We tried exactly that, and the build stopped with You’re importing a module that depends on "server-only", naming the client file that did it. The user’s own client, as in Supabase’s server-side client docs, with the publishable key:
// lib/supabase/server.ts
import { createServerClient } from "@supabase/ssr";
import { cookies } from "next/headers";
// The signed-in user's client, with the publishable key. RLS applies to it.
export async function createClient() {
const cookieStore = await cookies();
return createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!,
{
cookies: {
getAll() {
return cookieStore.getAll();
},
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) => cookieStore.set(name, value, options));
} catch {
// Called from a Server Component; the proxy refreshes the session instead.
}
},
},
}
);
}And the route that does the admin work, for the person asking and nobody else:
// app/api/delete-account/route.ts
import { createClient } from "@/lib/supabase/server";
import { supabaseAdmin } from "@/lib/supabase/admin";
export async function POST() {
// 1. Who is asking? Verified on the server, not taken from the request body.
const supabase = await createClient();
const { data } = await supabase.auth.getClaims();
const userId = data?.claims?.sub;
if (!userId) return Response.json({ error: "Sign in first" }, { status: 401 });
// 2. Only now use the secret key, and only for this one user.
const { error } = await supabaseAdmin.auth.admin.deleteUser(userId);
if (error) return Response.json({ error: "Could not delete the account" }, { status: 500 });
return Response.json({ deleted: userId });
}The browser now calls your route and never sees the secret key:
// app/account/page.tsx
"use client";
export default function Account() {
async function onDelete() {
// In the browser: ask your own route. No Supabase key beyond the publishable one.
const res = await fetch("/api/delete-account", { method: "POST" });
if (!res.ok) alert("Could not delete your account");
}
return <button onClick={onDelete}>Delete my account</button>;
}Two things in the route matter. The user ID comes from getClaims(), not from the request body. Supabase’s server-side docs say to “always use supabase.auth.getClaims() to protect pages and user data” and never to trust getSession() in server code, because it “reads the session out of the cookie without revalidating it.” And the admin client stays its own client that never signs anyone in. Supabase’s RLS docs explain why: a secret key bypasses RLS “only when the request carries no user access token.” Mix the two and you get confusing results either way.
We built this with Next.js 16.4.4, supabase-js 2.118.0 and @supabase/ssr 0.12.7, pointed at a small stand-in for Supabase Auth that knew one user and logged every request. With no cookie, the route said 401. With a session cookie whose token had the wrong signature, 401. Signed in as Ana with a body asking to delete Ben, it deleted Ana:
1 no cookie: 401 {"error":"Sign in first"}
2 forged token (wrong signature): 401 {"error":"Sign in first"}
3 Ana signed in, body asks for Ben: 200 {"deleted":"0a5e2c1d-…-00000000a0a0"}
auth server saw one admin call: DELETE /auth/v1/admin/users/0a5e2c1d-…-00000000a0a0, with the secret keyIf your admin work runs in a Supabase Edge Function, Supabase’s API keys guide shows the same idea with its @supabase/server package, which gives you the admin client on ctx.supabaseAdmin without reading the key yourself. Check 9 of our anon key guide shows how to make a function check who is calling and test it as a stranger, and our API route authentication guide covers routes in general. Or hand it to your builder:
Find every place in this project that uses the Supabase service_role key or a secret key (sb_secret_), or calls supabase.auth.admin. For each one, tell me whether that code runs in the browser or on the server.
Then move every browser use to the server:
- create lib/supabase/admin.ts that starts with import "server-only", reads SUPABASE_SECRET_KEY (no NEXT_PUBLIC_ or VITE_ prefix) and exports one admin client with persistSession: false,
- for each admin action, add a route handler (or Edge Function) that first gets the signed-in user with supabase.auth.getClaims() on the normal server client, returns 401 if there is none, and only then uses the admin client, for that user's own id taken from the claims, never from the request body,
- make the browser call that route instead,
- if an action can be done with the normal client and a row level security policy instead, do that and don't use the admin client at all.
Delete every env variable whose name has a browser prefix and holds a secret. Show me the list of changes before you make them.Then run the search from step 2 again. The only hits left should be on the server.
04
Rotate the key with Supabase’s steps
Everything here is from Supabase’s rotation guide, read on 2 November 2026. Dashboards change, so if a button has moved, trust that page over this one. We didn’t click through these steps in a real project for this guide. Which path you take depends on what step 1 told you.
If it’s a secret key (sb_secret_).
- Create a new secret key in the Settings > API Keys section of the dashboard. Supabase says every key lives there, and there is no separate Settings > API page.
- Put the new key everywhere the old one was used: your server’s environment, Edge Function code, jobs, CI. One catch from the guide: an Edge Function that checks keys with
withSupabase({ auth: 'secret' })only accepts the secret key nameddefault, so point it at the new key by name, for exampleauth: 'secret:rotated_secret_key'. - Confirm every part of your app works on the new key.
- Delete the leaked key, in the same Settings > API Keys section. Supabase warns that deleting a secret key can’t be undone, so it goes last, unless someone is using it right now.
If it’s a legacy service_role key (eyJ…). There’s no “new service_role key” button. You move to the new key system and switch the old keys off.
- Open Settings > API Keys and the Publishable and secret API keys tab. Supabase’s migration guide says older projects show a Create new API keys button, and that creating them is safe: your legacy keys keep working alongside.
- Put the new secret key on your server in place of the
service_rolekey. Then replace theanonkey with the publishable key in your browser and mobile code too, because, in the rotation guide’s words, “retiring the compromised key deactivates both legacy keys.” If a Database Webhook orpg_netcall sends theservice_rolekey asAuthorization: Bearer, send the new secret key on theapikeyheader instead. Secret keys aren’t JWTs, so the Bearer header rejects them. - Confirm nothing uses the old keys. The migration guide says there’s no automatic usage indicator and lists the easy ones to miss: app versions already on people’s phones, CI and deploy scripts, third-party integrations, cron jobs, workers and webhooks.
- Deactivate the legacy keys in Settings > API Keys. If you find a client you missed afterwards, the rotation guide says to move it to a new key rather than switching the legacy keys back on, “because re-enabling restores the compromised key.”
- Revoke the legacy JWT secret as well. The rotation guide explains that the old keys are JWTs signed by that secret, “so anything that still trusts the secret can accept the leaked key.” This happens on the JWT signing keys page: per the signing keys guide, click Migrate JWT secret, then Rotate keys, then revoke the legacy secret, which now sits under Previously used. Before you rotate, check that none of your code verifies tokens against the legacy secret itself and that no Edge Function relies on the Verify JWT setting. Supabase says either can break, and points to
getClaims()instead. To avoid signing people out, wait at least your access token expiry plus 15 minutes before revoking (1 hour 15 minutes for a 1-hour expiry). In an active incident, Supabase says you may want to revoke immediately.
After that, the leaked key gets nothing. If you can, try it once from a terminal against your own project to see the refusal with your own eyes. Don’t paste it anywhere else while you do.
05
Read your logs for anyone who used it
Rotating stops future use. It doesn’t tell you what happened while the key was out. For that you have your project’s logs, and two honest limits to keep in mind before you start:
- Supabase’s log field reference lists what it records for each API Gateway request: method, path, status, the caller’s IP address and country, the referer, the client library header, and so on. We found no field there that says which API key a request used. So you can’t filter for “requests made with my secret key.” You look for things only that key can do, or things your own app never does.
- How far back you can see depends on your plan, per Supabase’s Logs page, which also says “an empty result does not establish that the user had no activity.” And its logging configuration page says changes to logging “cannot recover past activity.” If you want a record, export it now.
Without SQL: open Logs in your dashboard, set the time range to cover the whole time the key was exposed, pick API Gateway as the log type, and filter by Method for DELETE, PATCH and POST. Select a row to see its details. Download logs gives you CSV or JSON, up to 1,000 rows at a time.
With SQL, Supabase’s Query logs with SQL guide says to open Explorer, choose Run SQL, pick Logs as the query source and set the time range there. Start with the admin API, since only a secret or service_role key can call it:
-- Calls to the Auth admin endpoints: listing, creating, changing or deleting users,
-- and generating sign-in links. Only a secret or service_role key can make these.
select timestamp,
log_attributes['request.method'] as method,
log_attributes['request.path'] as path,
toInt32OrZero(log_attributes['response.status_code']) as status,
log_attributes['request.headers.cf_connecting_ip'] as ip,
log_attributes['request.cf.country'] as country,
log_attributes['request.headers.x_client_info'] as client
from logs
where source = 'edge_logs'
and log_attributes['request.path'] like '/auth/v1/admin/%'
order by timestamp desc
limit 100;Your own server may show up here, if it deletes accounts or invites people. What you’re looking for is an IP or country that isn’t your server, or an admin call you don’t recognise, especially GET /auth/v1/admin/users (someone listing your users) or anything to /auth/v1/admin/generate_link. If it returns nothing at all, take out the line that filters on the path and look at a few rows to see how paths appear in your project before you conclude anything. Then writes and deletes on your tables:
-- Who wrote to or deleted from your tables through the Data API, by address and country.
-- Your own server should be a handful of rows you recognise. Anything else, look closer.
select log_attributes['request.headers.cf_connecting_ip'] as ip,
log_attributes['request.cf.country'] as country,
log_attributes['request.method'] as method,
count() as requests,
min(timestamp) as first_seen,
max(timestamp) as last_seen
from logs
where source = 'edge_logs'
and log_attributes['request.path'] like '/rest/v1/%'
and log_attributes['request.method'] in ('POST', 'PATCH', 'PUT', 'DELETE')
group by ip, country, method
order by requests desc
limit 50;And what Supabase Auth itself recorded about accounts:
-- Account changes Supabase Auth recorded: deleted, invited and changed users, new passwords.
select timestamp, event_message
from logs
where source = 'auth_audit_logs'
and match(event_message, 'user_deleted|user_invited|user_modified|user_updated_password')
order by timestamp desc
limit 100;Those action names come from Supabase’s Auth audit logs page, which says audit logs are captured automatically and can also be written to the auth.audit_log_entries table if you turn on “Write audit logs to the database”. For uploads and file access, pick Storage as the log type in Logs.
We ran all three queries in ClickHouse 26.10, the engine Supabase’s logs guide says it uses, against a made-up logs table shaped like the one Supabase documents, to make sure they parse and pick out the right rows. We didn’t run them against a hosted project. Supabase’s guide says its log queries reject select * and count(*), so neither appears here.
If you find requests you can’t explain, keep the export, note the times and addresses, and work out what that data was and whose it was. What you owe the people in it depends on where you and they are. That part is beyond this guide.
06
Make the next leak harder
- One secret key per backend part. Supabase’s API keys guide recommends “a separate secret key for each backend component,” so that if one leaks, “you only rotate that one.” The migration guide shows how to read a named key in an Edge Function.
- Never a browser prefix on a secret. Not
NEXT_PUBLIC_, notVITE_, notPUBLIC_. Keep theimport "server-only"line in the admin file, so a mistake fails the build instead of shipping. - Move off the legacy keys. Supabase is deprecating
anonandservice_roleby the end of 2026, and GitHub’s scanning list covers the new secret key format, with push protection, while we couldn’t find the old JWT there. With push protection on for your repo, GitHub blocks a push that contains ansb_secret_key. - Check the outside after every change. Re-run step 2’s search and the live-site script from the leaked keys guide after any change your builder makes to auth or admin features.
- Then look at the wall. Once only the publishable key is in your page, RLS is what protects your data. Our free Supabase RLS checker runs one read-only query and tells you which tables and functions are open to the public key. It runs in your browser and sends nothing anywhere.
Where LockShip fits
We built LockShip to catch this from the outside before someone else does. You paste your app’s address, prove you own it, and the scan reads the JavaScript your live site serves, including files it only loads later. It looks for Supabase secret keys by their sb_secret_ prefix and decodes every eyJ key it finds to read the role, the same check as step 1. Either one is reported as critical and links to this guide. It keeps only a short fingerprint of the key and never uses it against your project.
The honest limit: it only sees what your site serves. It can’t read your git history, your host’s environment variables, your server code or your Supabase logs, so steps 2 and 5 are still yours. A clean result means “no secret key in your public JavaScript right now,” not “nobody ever had it.”
The summary is free: a score and the single worst thing we found. The $39 Launch Safe certificate includes every finding with a fix prompt you can paste into your builder, the RLS SQL, a PDF, and seven days of re-scans while you fix things. A passing re-scan gives you a badge you can put on your site. Monitor, at $9 a month, re-runs the scan every week and emails you once when a new critical or high issue shows up, like a secret key that comes back after your builder rewrites a page. The pricing page has the details.
Is your secret key in your JavaScript right now?
Paste your app’s address, prove you own it, and see what a stranger can download. The summary is free.
Run a free scanBefore you rely on a result, read the disclaimer.
Questions people ask
Is the Supabase service_role key the same as the secret key?
They do the same job. The service_role key is the older, long key that starts with eyJ. The secret key starts with sb_secret_ and is what Supabase wants you to use now. Both act as the service_role Postgres role, which has the BYPASSRLS attribute, so neither one is held back by your row level security policies. Supabase says it is deprecating the anon and service_role keys by the end of 2026.
Can someone use my Supabase secret key from a browser?
A secret key that starts with sb_secret_ gets a 401 from Supabase when the request looks like it comes from a browser, judged by the User-Agent header. That doesn’t protect you: Supabase’s own docs say an attacker can still use the key from other tools, like curl or a script. Supabase lists that browser check as something secret keys add over the older service_role key, so don’t count on it for an eyJ key at all.
If I remove the key from my code and redeploy, am I safe?
No. Anyone who downloaded your JavaScript, cloned your repo or read your git history may already have a copy, and removing the file in a new commit leaves it in the old ones. A NEXT_PUBLIC_ value is also baked into a build when it runs, so it stays in every build made before you changed it. Rotating the key is what stops a copy from working. Fix the code first so the new key doesn’t leak the same way, then rotate.
Will rotating the Supabase service_role key sign my users out?
Replacing a secret key doesn’t touch user sessions: Supabase says publishable and secret keys are no longer based on the JWT signing key. For a legacy service_role key, the step to be careful with is revoking the legacy JWT secret. Supabase says to wait at least your access token expiry plus 15 minutes after rotating to a new signing key, for example 1 hour and 15 minutes, so signed-in users aren’t forced out. During an active incident you may choose to revoke it right away and accept that.
How do I know if someone used my leaked Supabase key?
Look in your project’s logs. The fields Supabase lists for API Gateway events don’t include which API key a request used, so look for things only that key can do or that your own app never does: calls to /auth/v1/admin/, writes and deletes from addresses that aren’t your server, and account changes in the Auth audit logs. How far back you can look depends on your plan, and Supabase is clear that an empty result doesn’t prove nothing happened.
Keep reading
- Vibe coding security checklist: what to check before you launch an AI-built app
- Supabase anon key exposed? What a stranger can see and call with it
- Leaked API keys in your frontend bundle: how to find them and what to do
- A Supabase RLS checklist for vibe-coded apps
- Exposed .env and .git files: how they get served, how to check, what to do
- Supabase Auth settings to check before you launch
- Free Supabase RLS checker
Sources
We read each of these on 2 November 2026. Supabase is changing its keys fast, so if something here disagrees with its docs, trust Supabase and tell us at hi@lockship.dev. We tested the leaks with Next.js 16.4.4 and Vite 7.3.7, the fixed route with supabase-js 2.118.0 and @supabase/ssr 0.12.7 against a stand-in for Supabase Auth, the git scripts on a throwaway repo, and the log queries in ClickHouse 26.10 against a made-up table, all with fake keys. We didn’t test against Supabase’s hosted service, and the rotation steps are Supabase’s, not something we clicked through for this guide.
- API keys, Supabase docs
- Rotate a leaked or compromised API key, Supabase docs
- Migrating to publishable and secret API keys, Supabase docs
- JWT signing keys, Supabase docs
- JSON Web Token (JWT), Supabase docs
- Row Level Security (bypassing RLS), Supabase docs
- Storage access control, Supabase docs
- Auth admin methods, Supabase JavaScript reference
- openapi.yaml (admin endpoints), Supabase Auth on GitHub
- Breaking change: removing access to the OpenAPI spec via the anon key, Supabase changelog
- Creating a Supabase client for SSR, Supabase docs
- Logs in Studio, Supabase docs
- Query logs with SQL, Supabase docs
- Log sources and fields, Supabase docs
- Configure logging, Supabase docs
- Auth audit logs, Supabase docs
- Environment variables, Next.js docs
- Server and Client Components (server-only), Next.js docs
- Env variables and modes, Vite docs
- Supported secret scanning patterns, GitHub docs
- Secret scanning for partners, GitHub docs
- Removing sensitive data from a repository, GitHub docs