A Supabase secret API key is the server-side key for a Supabase project. It replaces the older service_role key and gives full access to the project’s database, which means it bypasses the row-level security policies that normally limit what each user can read and write. Whoever holds it can read or change every table, call the storage and auth administration APIs, and create accounts. This is one of the most serious leaks for an application backend, because it is the key to the whole project. Revoke it first, then check the data.
Check your GitHub account for leaked secrets — free
- Provider
- Supabase
- Severity
- Critical
- Impact
- Cloud infrastructure access
- Checked live by LeakWatch
- No
What a Supabase Secret API Key looks like
Supabase secret keys start with sb_secret_, followed by a block of letters, digits, underscores and hyphens. The whole value is a single string:
sb_secret_… Supabase secret API key (masked)
The distinction from the publishable key is essential. Supabase issues a publishable key with the prefix sb_publishable_, which is designed to ship in browser and mobile code and is not covered by this rule. The secret key must never appear in any of those places. Older projects may still use the legacy service_role JWT, which carries the same power but is not matched by this prefix, so check your environment variables for it as well.
How Supabase Secret API Keys get leaked
- Front-end environment variables. A secret key stored with a public prefix in a web framework, so the build embeds it into the JavaScript that every visitor downloads.
- Environment files. A
.envfile with the secret key committed next to the project URL. - Edge and serverless functions. A function configuration that writes the key into a file in the repository.
- Logs. A server that prints its environment when a request fails, or a debug statement that logs the request headers.
- Pasted examples. A snippet posted in a forum or a chat while debugging a permissions error.
What to do in the first hour
- Delete the key. Open the account settings for your Supabase project, go to the API keys area and delete the secret key that leaked. Deleting is irreversible, so first confirm that your services have the replacement. If you cannot switch yet, rotate the legacy key and plan the change.
- Create a replacement secret key, and store it in your hosting provider’s secret settings or a server-side environment. Keep it out of anything that is built for the browser.
- Review the data. Check recent changes to the main tables, especially those that hold user accounts, permissions and payments. Look for rows you did not expect.
- Check the auth users. Review the list of accounts for new users, new admin roles and password resets you did not trigger.
- Check storage. Look at the storage buckets for new or deleted files, and check whether any bucket is public when it should not be.
- Review the logs. Check the API and database logs for the period since the exposure, and look for requests from unfamiliar addresses.
- Look at other secrets in the same file, such as database passwords and third-party keys. See I accidentally pushed an API key to GitHub for the order of steps.
- Clean the code. Remove the key from the front end and from the repository, and confirm the publishable key is the only one the browser receives.
Not sure what else leaked? Run a free scan.
Revoke it at Supabase
Keys are listed in the API keys section of the project’s settings. Open account settings, select the project, and delete the secret key that leaked, after your services have the new one. Supabase’s documentation says that the secret key adds checks to prevent misuse, and that deleting it cannot be undone, so make sure the replacement is deployed first. Check that you are in the correct project, since projects in the same account have separate keys.
How LeakWatch detects it
The rule is called Supabase Secret API Key. It looks for the prefix sb_secret_ followed by 31 letters, digits, underscores or hyphens, with a boundary, a line break or a quote after it. Publishable keys with the sb_publishable_ prefix are not matched, and the older service_role JWT is handled by its own rule. The severity is critical, with the impact class for infrastructure and cloud access. This type is not checked live: LeakWatch does not send a request to Supabase with the value it found.
LeakWatch detects this format but does not check it live: it can tell you the key is exposed, not whether it still works. Assume it does until you have revoked it.
FAQ
Is the publishable key also a secret?
No. It is designed to be public and is used in the browser. The secret key is the one that bypasses row-level security, and it must stay on the server.
Why does the secret key matter if I have row-level security?
Because the secret key bypasses those policies. Row-level security protects data from ordinary users, but it does not stop a holder of the secret key.
Can I keep the legacy key running for now?
Only as a short transition. Both the legacy and new keys carry similar power, so revoke the leaked one and move your services as quickly as possible.