security(db): enable RLS on all tables + harden functions#6
Open
StockerMC wants to merge 1 commit into
Open
Conversation
…function search_path Captures the security hardening already applied to the live Supabase DB (2026-05-30) as a reproducible migration: - Enable RLS on all 18 public tables. Previously RLS was OFF everywhere and the anon key ships in the browser bundle, so anyone could read/write every table directly via PostgREST — including creator_tokens and shopify_oauth_tokens (OAuth credentials). - Add minimal anon policies for the surfaces the frontend uses directly (creator_videos / product_creator_matches SELECT; reel_interactions SELECT+DELETE; waitlist INSERT-only). - Pin search_path=public on the four SECURITY-relevant functions. Server routes use the service-role key (bypasses RLS) so they are unaffected.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Captures, as a reproducible migration, the security hardening already applied to the live Supabase DB. Previously RLS was disabled on all 18 public tables — and because the anon key ships in the browser bundle, any visitor could read/write every table directly via PostgREST, including OAuth credentials.
What changed (
backend/data/enable_rls_security.sql)creator_videos,product_creator_matches— SELECTreel_interactions— SELECT + DELETEwaitlist— INSERT only (emails stay non-readable)search_path=publicon the 4 SECURITY-relevant functions.Everything else becomes server-only — API routes use the service-role key, which bypasses RLS.
Verification (live DB, anon-role impersonation)
Supabase security advisor: all ERROR-level lints (RLS-disabled + sensitive-columns-exposed) cleared.
Known follow-ups (not blockers)
reel_interactionsDELETE andwaitlistINSERT use(true)predicates — inherent to the demo having no real per-user auth yet (getCurrentUser()is mocked). Tighten once Supabase Auth is wired in.