Skip to content

Supabase's October 30 change: new public tables need a grant for Data API access. What to doSupabase's October 30 change is live: new public tables need a grant for Data API access. What broke and how to fix it

25 tools · 142 fixes · 43 issue guides · Sources: Supabase, GitHub, Vercel, postgresql.org + 56

Issues

Secret keys shipped in the frontend

A Supabase secret key, Stripe secret key, or model API key in the browser bundle is public. Anyone can copy it and use it as your server.

Share link · Share on X

By ShipSecurely Editorial · Updated · How we make these guides

criticalSecretsSecrets and API keys

Shows up in: Supabase, Next.js, Vercel, Stripe, Firebase

What it is

Anything bundled into a web page can be read. That includes JavaScript, source maps, and environment variables that the framework inlines because their names start with NEXT_PUBLIC_, VITE_, or a similar public prefix.

Supabase's API key guide draws the line by where the code runs. Code you ship (browser, mobile app, CLI) gets the publishable key. Code you control (server, Edge Function, cron) may use the secret key, because that key bypasses row level security. The legacy service_role key is the same class of secret. Supabase also says a secret key must never appear in a browser, including on localhost, and that their API returns 401 when a secret key is sent with a browser user agent. That block is not a reason to ship the key. A request from curl or a script is not a browser.

The same rule covers a Stripe secret key, an OpenAI or Anthropic key, a Firebase service account, and a database connection string. A user session token in localStorage is a different leak: it acts as that user, not as your server. See Session tokens stored in localStorage.

If you build apps for clients, Security checklist for AI client work covers whose account each key lives in and who rotates it.

Supabase service_role key leaked to the browser: what to do now

Rotate or revoke the key, move the privileged calls to a server, and switch that server to a secret key. The API keys guide's rotation procedure covers a leaked secret key and a leaked service_role key. Fix the place the key leaked, then create a new secret key in Settings, then API Keys. Replace the compromised key everywhere it is used. If the leaked key is the JWT-based service_role key, the replacement is the new secret key. After every component uses the new key, delete the leaked secret key, or deactivate the legacy service_role key on that same screen. Deleting a secret key cannot be undone. Deactivating a legacy key can be turned back on if a caller was missed. The same guide says to delete a leaked key immediately: the browser block returns HTTP 401, and an attacker can still use the key from other tools.

Privileged calls stay on a server you control. The API keys guide says anything you ship, including a browser, gets the publishable key, because anyone can read it and it only reaches what row level security allows. A secret key bypasses row level security. It belongs on a server, an Edge Function, or a cron job. The service_role key is the legacy secret key. Secret keys use the service_role Postgres role, which has the BYPASSRLS attribute, so policies never apply to that key.

Migrating to publishable and secret API keys maps the old keys onto the new ones. Replace anon in public code with a publishable key (sb_publishable_...). Replace service_role on a server with a secret key (sb_secret_...). Creating the new keys adds them beside the legacy keys, and the legacy keys keep working until you deactivate them after nothing still uses them. The publishable key has the same low privileges as the anon key, so row level security policies behave the same. A secret key returns HTTP 401 when it is sent with a browser user agent. That response is a block on browser use, and the key still has to be rotated if it reached a browser.

How to check in 5 minutes

  1. Search the repo for service_role, sb_secret_, SUPABASE_SERVICE_ROLE, sk_live_, sk_test_, BEGIN PRIVATE KEY, and api.openai.com keys. Then search for those strings next to NEXT_PUBLIC_ or VITE_.

  2. Open the built site, view source, and search the JavaScript files for sb_secret_, service_role, and sk_live_. A production build is the honest check. Dev mode can hide things the bundler will still inline.

  3. In the browser network panel, look at the apikey header on requests to Supabase. It should be the publishable key, not the secret key.

  4. Check framework config. In Next.js, only variables prefixed with NEXT_PUBLIC_ are exposed to the browser. If the secret uses that prefix, it is in the bundle.

How to fix

Supabase

Keep two variables, matching Supabase's own example:

NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=sb_publishable_...

SUPABASE_SECRET_KEY=sb_secret_...

Create the browser client with the publishable key. Create an admin client only in a file that is imported by server code, and never from a Client Component. If the secret key has already shipped, rotate it in Settings, then API Keys, and disable the legacy service_role key as well. Creating a new secret key does not revoke the old JWT-based key. Supabase's rotation steps say to replace every use first, then retire the compromised key.

Next.js

Assume every NEXT_PUBLIC_ value is public. Do not pass a secret as a prop into a client component. Server Actions and Route Handlers can read process.env.SUPABASE_SECRET_KEY. A client component cannot, unless you made it public.

Store that secret in the host's server environment, not in a name the bundler ships. A service variable is available to the running service. The same rule on Fly.io, Railway, Render, and Vercel, including preview deploys and private networking, is in How to deploy your vibe-coded app securely. Railway disclosed a security incident on Oct 21, 2026 involving stored environment variables.

Vercel

Put the secret in the project's environment variables for Production, Preview, and Development as needed. Do not prefix it with NEXT_PUBLIC_. Redeploy after rotating. The old deployment keeps the old value until it is replaced.

Stripe and model providers

The Stripe secret key and webhook secret stay on the server. The browser may use a publishable key (pk_...). Model keys stay on the server. See unbounded model spend.

Firebase

The Firebase web config (apiKey, projectId, and similar) is designed to live in the client. Security rules are the control. A service account JSON file is not the web config. It must not be imported by frontend code.

Copy the fix prompt

Paste this into Cursor, Lovable, Bolt, or Claude Code. Read the diff before you merge it.

You are removing secrets from client-side code. Do not add features.

Search this repo for service_role, sb_secret_, SUPABASE_SERVICE_ROLE, Stripe secret keys (sk_live_ and sk_test_), webhook secrets, and LLM provider keys.

Rules:
1. Any variable prefixed NEXT_PUBLIC_ or VITE_ is public. A secret must not use that prefix.
2. The Supabase browser client may use the publishable key only. The secret key may appear only in server modules that client components do not import.
3. If a secret was exposed, do not only rename the variable. Tell me to rotate it in the provider dashboard, including the legacy Supabase service_role key if that was the value that leaked.
4. Do not print secret values in logs, comments, or the pull request description.

Show every file you changed and the env var names the host needs. Do not include the secret values.

Questions

Supabase service_role key leaked to the browser: what to do now

Rotate or revoke it, and move privileged calls to a server. The API keys guide covers a leaked secret key and a leaked service_role key: fix the leak, create a new secret key in Settings, then API Keys, replace the compromised key everywhere, then delete the leaked secret key or deactivate the legacy service_role key. Deleting a secret key cannot be undone. The browser block returns HTTP 401, and the key still works from other tools, so a key that reached a browser has to be retired.

The same guide says anything you ship, including a browser, gets the publishable key. A secret key bypasses row level security and stays on a server, an Edge Function, or a cron job. service_role is the legacy secret key. Migrating to publishable and secret API keys says to replace anon in public code with a publishable key (sb_publishable_...) and service_role on a server with a secret key (sb_secret_...). Creating the new keys does not deactivate the legacy keys. The publishable key has the same low privileges as the anon key.

The anon key is in my JavaScript. Is that a leak?

The legacy anon key and the publishable key are low-privilege identifiers. Supabase says they are safe to expose if row level security is on and you review policies for the anon and authenticated roles. Treat service_role and sb_secret_ as passwords.

Supabase blocks secret keys in the browser. Can I rely on that?

No. Their docs say the browser block returns HTTP 401, and an attacker can still use the key from other tools. If it reached a browser, rotate it.

Sources

Related

Need someone to fix it for you? See /help.

The weekly fix

The weekly fix: 3 real security mistakes in vibe-coded apps and how to fix them, every Tuesday.

One email, every Tuesday. A welcome note follows the first signup.