Signed-in people can read their wedding again on the hosted project - #21
Merged
Merged
Conversation
The hosted project had drifted from the migrations: is_wedding_member ran
as its caller and, with delete_my_account, could not be executed by
authenticated. Every read of a wedding was refused (403, "permission
denied for function is_wedding_member") and deleting an account failed.
Granted again, the check recursed through the policy it serves ("stack
depth limit exceeded"), so it is a security definer again too.
Both migrations are applied to the hosted project under the versions it
recorded, and change nothing where the functions never drifted. The
trigger function is taken from anon and authenticated. A PGlite test
models the drift and the fix; the harness grants the auth schema to the
API roles, as Supabase does. The self-hosting guide warns against the
Security Advisor's remedies for these functions; the review records D8.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HozwaQN87Fzg985EBm6MY1
Contributor
|
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.
Summary
The hosted Supabase project no longer matched the migrations, and no signed-in person could read their wedding. This PR brings into the repository the two migrations that fixed it. Both are already applied to the hosted project, under the versions it recorded, so merging changes nothing there. It keeps
supabase/migrations/in step with the project's migration history, so a latersupabase db pushdoesn't find versions it lacks.What was wrong
is_wedding_member(uuid)could not be executed byauthenticated, and ran as its caller (security invoker).delete_my_account()could not be executed byauthenticatedeither.Every migration says otherwise, and none changes them. These are two of the Security Advisor's own remedies for its warnings on these functions. What applied them isn't in the project's logs, which go back to 2026-09-20.
The effect is in the logs. After signing in on 2026-09-29 at 07:45 UTC, every
GET /rest/v1/wedding_membersreturned 403, with Postgres loggingpermission denied for function is_wedding_member. Deleting an account failed for the same reason.With the grant restored, the check still ran as its caller. It asked the
wedding_memberspolicy, which asks the check again, so reads failed withstack depth limit exceededuntil the second migration made itsecurity defineragain.Changes
supabase/migrations/20260930155142_member_grants.sqlis_wedding_member(uuid)anddelete_my_account()toauthenticatedagain;announce_wedding_document()fromanonandauthenticated. Postgres already refused to run it outside a trigger; this takes it off the API.supabase/migrations/20260930155610_member_definer.sqlmakesis_wedding_member(uuid)security defineragain.suite/lib/documents/history.migrations.test.tsadds a PGlite test that reproduces the drift, asserts both refusals, applies the two migrations, and checks the member reads their wedding and can delete their account. The anon-grants test also covers the trigger function.suite/lib/testing/database.ts: the harness grantsusageon itsauthschema toanonandauthenticated, as Supabase does.docs/SELF-HOSTING.mdwarns against the Security Advisor's remedies for these functions: the 16 callable by signed-in people, and the 3 link functions open to anyone. Those warnings describe the design.docs/superpowers/specs/2026-09-29-database-review.mdrecords this as D8.Verification
On the hosted project, after both migrations:
Every other function's definition matches the migrations exactly, once the dashboard's
\r\nline endings are ignored.Locally: 1,906 suite tests, typecheck and lint pass. The new test fails when the definer migration is blanked.
🤖 Generated with Claude Code
https://claude.ai/code/session_01HozwaQN87Fzg985EBm6MY1
Generated by Claude Code