Repository navigation
fix(db): lock Supabase's Data API out — RLS on every table, no grants to anon - #12
Merged
Merged
Conversation
… to anon Supabase exposes `public` over PostgREST and grants anon/authenticated full access to new tables; the anon key is public by design. After the first migration every table had RLS off and anon could SELECT and INSERT — password hashes readable, ledger writable, bypassing the API entirely. - migration: ENABLE ROW LEVEL SECURITY on every table (no policies), REVOKE from anon/authenticated incl. default privileges; the revoke is guarded so plain Postgres (local, CI) skips it - tests/integration/rls.test.ts fails on any table without RLS - applied and verified on Supabase: RLS on, anon/authenticated denied, future tables not granted, app still reads its data - ADR 54
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Supabase publishes every table in
publicthrough its REST Data API and grantsanon/authenticatedfull access to new tables. The anon key is public by design. Checked after the first migration: all 12 tables had RLS off andanoncould SELECT and INSERT —Userpassword hashes readable,Transactionledger writable, without going through our API. We never use the Data API.What
20260923160000_lock_down_supabase_data_apipostgres/BYPASSRLS on Supabase, table owner elsewhere)REVOKE ALLfromanon,authenticatedon tables/sequences/functions + default privileges for future tables — guarded, so plain Postgres skips ittests/integration/rls.test.ts— fails if any table lacks RLS (shown failing on all 12 tables before the migration)Verified on Supabase (already applied, same file)
rls = true, anon/authenticated SELECT/INSERT =false454 backend tests pass.