Securing Supabase: what actually matters
Supabase hands your browser a key on purpose, and one thing behind it keeps your data private. The Security Advisor will approve a policy that lets strangers post as you, and the official guide skips storage, auth settings and views entirely.
Supabase hands your browser a key on purpose. Everything that keeps your data private depends on one thing being right behind it, and the dashboard will happily tell you it is fine when it is not.
What follows is the short version of what matters, drawn from Supabase's own security walkthrough, with the parts they skipped marked clearly.
Know which key is which
There are two, and the rule for telling them apart is pleasingly simple. If the dashboard shows the key without asking, it is meant to be public. If it hides it behind a Reveal button with a red badge, it is not.
- anon, now being renamed publishable. Safe in the browser. It identifies your project and nothing more. Its safety is entirely conditional on your access policies.
- service_role, now renamed secret. It ignores every access policy you have written. In Supabase's own words, if someone gets hold of it “they can do anything, they can read all the data, they can delete all the data”.
The secret key belongs on a server. In Supabase terms that means an Edge Function, with the value stored in the secrets manager and read at runtime rather than written into your source. Keys committed to a repository are exposed even after you delete them, because history keeps them.
One audit worth doing right now: copy your secret key, then search your entire repository for that exact string. If it appears anywhere, rotate it before you do anything else.
Row level security, and the three patterns that cover most apps
With RLS off, a table in the public schema is readable by anyone holding the publishable key, which is to say anyone. The dashboard marks it with a red lock and states the consequence plainly:
When row level security is disabled for a table, any users can access this table any way they want, which is terrible. It's not acceptable. If you find this in your dashboard, immediately enable row level security.
Policies come in four kinds, one per operation, and three patterns handle most cases:
- No policy means denied. If a table has no DELETE policy, nobody can delete through the API. Absence is a decision, and a reasonable one.
truemeans always allowed. Occasionally correct for reading genuinely public data. Rarely correct for writing.auth.uid() = owner_columnis the ownership check, and the one you will use most.
The mistake the advisor will not catch
Supabase ships a Security Advisor that flags the obvious failures, and it is worth checking. It is also, by their own admission, not sufficient. Their demonstration is the clearest warning in the whole video: they changed an INSERT policy to true, and the advisor reported nothing wrong.
If we just say true, it doesn't mean that anybody can insert the data. It means that anybody can insert any kind of data in a database. So people can pretend to be other people. I can insert data as if I'm someone else, like Elon Musk or something. That's not great, right? That's like actual hacking.
And the general caveat, from the vendor: “Security advisors are great for picking up some of the obvious pitfalls, but it's not going to pick up everything.” A clean advisor means no policy is missing. It does not mean your policies are right.
Test your policies instead of trusting them
The genuinely useful part of their walkthrough is a repeatable way to prove a policy works, rather than reading it and nodding. The shape is this:
- Run Supabase locally. Never test against production, and note that every local instance ships the same keys, so seeing a service_role key in your terminal is expected rather than alarming.
- Put your schema in a migration, not a loose SQL file, or a local reset will not apply it.
- Reset the database before each test, so results do not depend on what the last run left behind.
- Sign up user one. Have them write something.
- Sign up user two. Have them attempt to modify user one's record.
- Read the record back using an admin client and assert it is unchanged.
That last step is the one people get wrong, and there is a specific technical reason why. Reading back through the normal client would itself be filtered by your policies, so you could not tell a blocked write from a row that was never there.
The detail that breaks naive tests. When a write is blocked by row level security, Supabase does not return an error. It silently does nothing, which is how Postgres behaves. An assertion that expects a failure will therefore pass whether your policy works or not. Assert on the data instead: read the row back and confirm the original values survived.
What the official guide leaves out
Worth being explicit, because a video from the vendor reads as complete when it is not. None of the following is covered, and all of it matters:
- Auth configuration: email confirmation, signup settings, password policy, leaked-password protection, OTP expiry.
- Verifying sessions on the server with
getUser()rather than trusting the cookie. - Storage buckets and their policies, which are a separate permission system from your tables.
- Database functions, and whether they run as the definer or the invoker.
- Views, which can quietly bypass the policies on the tables beneath them.
- Which schemas are exposed through the API at all.
There is also one claim worth treating sceptically. The video says AI tools generally do a good job of enabling row level security. Sometimes they do. The incidents that make the news are the times they did not, and it costs you nothing to check rather than assume.
The short version
Confirm your secret key is nowhere in your repository. Turn on row level security everywhere. Read the Security Advisor, then ignore its approval. Write one test that proves user two cannot touch user one's data, and assert on the data rather than on an error. Then go and look at storage and auth settings, because the official guide will not take you there.
Find out which of those apply to you
Fourteen questions, about three minutes, runs entirely in your browser. You get a ranked list of what's actually open, with the fix for each.
Run the free checkSources
- Vibe Hacking: How AI Is Helping Hackers · David Bombal with Pascal Geenens, Radware
- How Hackers Use “Vibe Coding” to Create AI Malware · Cybernews with Dr Katie Paxton-Fear
- The Devil Reviews Xanthorox · Trend Micro
- HexStrike Exploit Raises Cyber Stakes · Communications of the ACM
Quotations from the two interviews are transcribed from the published videos and lightly condensed for readability.
