Repository navigation
fix(action-center): scope the write policies to the admin client - #813
Merged
Merged
Conversation
00081 created five policies named "Service role can insert/delete ...", but created them the way an unqualified `create policy` creates anything: `to public`, predicate `true`. service_role bypasses RLS altogether and never consulted them; the roles that did are anon and authenticated, both of which hold INSERT and DELETE grants on these tables. The effect was the opposite of the name — every signed-in user could insert and delete rows on actions, action_tasks and action_events regardless of which organization owned them. Reads were never affected: the select and update policies are scoped to the caller's organization and are untouched here. The commands are closed outright rather than scoped, because nothing legitimate went through them. Both writers — the nightly generator and the backfill script — use the admin client, whose role carries BYPASSRLS, and the web tier only selects and updates. Deny-all policies rather than no policy at all: RLS already denies where no policy matches, but an explicit `false` shows the next reader a decision instead of an omission. action_tasks reopens to members, scoped to their organization, when the Tasks tab learns to add and remove tasks. Applied to the hosted database. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj
This was referenced Sep 15, 2026
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
The Action Center's write policies granted to every signed-in user what their names said was reserved for the service role.
00081created five policies called "Service role can insert/delete …", but created them the way an unqualifiedcreate policycreates anything:to public, with the predicatetrue.service_rolecarriesBYPASSRLSand never consulted them. The roles that did areanonandauthenticated, both of which hold INSERT and DELETE grants on these tables — so the policies had the opposite effect of their name, letting any signed-in user insert and delete rows onactions,action_tasksandaction_eventsregardless of which organization owned them.Reads were never affected. The select and update policies are scoped to the caller's organization and are untouched here.
The change
The five commands are closed outright rather than scoped, because nothing legitimate went through them:
BYPASSRLS(verified against the database, not assumed);So closing them is the narrowest fix that keeps current behaviour exactly as it is.
Deny-all policies rather than no policy at all. With RLS enabled a missing policy already denies, but an explicit
falseshows the next reader a decision where they would otherwise see an omission, and each table keeps one policy per command.action_tasksreopens to members, scoped to their own organization, in a later migration — when the Tasks tab learns to add and remove tasks.Related issue
None — found while reading these policies before extending them.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsDatabase
00082_action_center_write_policies— already applied to the hosted database. Policy-only; no table, column or data changes.Self-hosted installs that have run
00081should apply this one.How to test
After applying,
pg_policiesshowsfalsefor every insert/delete on the three tables, and the member select/insert/update policies are unchanged:Then confirm nothing regressed:
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdsupabase/schema.sqlregenerated withbash supabase/build-schema.sh🤖 Generated with Claude Code
https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj