Repository navigation
Description
Summary
On 2026-11-10, anon could run three SECURITY INVOKER notification RPCs on production: get_channel_notif_state, get_unread_notifications_paginated and get_workspace_notifications. The maintainer ruled the fix on #327 the same day. It is not built. The newest migration at HEAD 0b302b222 is 20261103120000.
This issue ships one paired change: packages/supabase/scripts/ plus one migration. It grants EXECUTE to authenticated and revokes it from anon and public. Part of #327. Priority P1.
Accepted: service_role may lose EXECUTE on the three RPCs (ruling 2026-11-11). It is recorded as a control column, with no bar.
Push by . The maintainer sets the date. Recommended: before 2026-11-15, so the #325 window can start after a clean 24 h.
Order. Push #755. Wait for a clean 24 h GlitchTip read (the Guard). Then start the #325 reset and the #324 window. The #325 window bans any db push. It must also land before the #322 baseline.
Why
Result of the read-only check, 2026-11-10, production SQL editor (#327 comment):
| Function | anon |
authenticated |
|---|---|---|
get_channel_notif_state |
true | true |
get_unread_notifications_paginated |
true | true |
get_workspace_notifications |
true | true |
- All three are
SECURITY INVOKER, because none sets a security clause (packages/supabase/scripts/10-functions.sql:552and:711,packages/supabase/scripts/07-1-notification-functions.sql:20). has_function_privilege('anon', …)is true through thePUBLICgrant. So the revoke must namepublictoo.packages/supabase/scripts/check-grants.sqlnever covers invoker functions (packages/supabase/CLAUDE.md). Its clean production run on 2026-11-03 says nothing about these three.- What
anongets back from each call is not measured yet. The fix does not depend on it.
Callers, read from code on 2026-11-10:
get_channel_notif_state:apps/webapp/src/components/chatroom/hooks/useNotificationToggle.ts. The query runs only with a signed-inuserId(enabled: Boolean(channelId && userId)).get_unread_notifications_paginated:apps/webapp/src/components/notificationPanel/feed/useNotificationPanelFeed.ts. Every call returns early without auserId.get_workspace_notifications: onlyapps/webapp/src/api/notification/getLastReadNotification.ts. Nothing imports that wrapper except theapi/notificationbarrel, so it has no live caller.- No other app, extension or package calls them.
apps/webapp/cypress/support/chatroomFixtures.tsstubs them.
So no signed-out path breaks when anon loses EXECUTE.
Maintainer ruling, 2026-11-10 (copied from #327)
On the three SECURITY INVOKER RPCs with browser callers: get_unread_notifications_paginated, get_channel_notif_state and get_workspace_notifications. Answer: "agree".
The deeper look, read from code and not checked on production:
- All three are
SECURITY INVOKER, because none sets a security clause (packages/supabase/scripts/10-functions.sql:552and:711,packages/supabase/scripts/07-1-notification-functions.sql:20). - The local seed grants all three to
authenticatedthrough theuser_facing_nameslist inpackages/supabase/scripts/29-lint-hardening.sql§6. packages/supabase/scripts/check-grants.sqldoes not cover invoker functions. So its clean production run on 2026-11-03 says nothing about these three.
The ruling:
- First, run one read-only
has_function_privilegequery on production, foranonandauthenticated, on each of the three. - If
anoncan run any of them, add one paired change inscripts/and a migration: grant EXECUTE toauthenticated, and revoke it fromanonandpublic. - If
anoncannot, close this item as covered.
Notes for the builder (copied from #327, 2026-11-10)
- The functions are
SECURITY INVOKER, so the revoke must namepublictoo.has_function_privilege('anon', …)is also true through thePUBLICgrant. - The grant to
authenticatedalready sits in29-lint-hardening.sql§6. The migration must carry it too, because production never ran the local sweep. - Run
packages/supabase/scripts/check-grants.sqland this same query on production after the push. Expectanonfalse andauthenticatedtrue on all three. get_workspace_notificationshas no live caller. Dropping it with its wrapper is a separate question. It is not part of this change.
What to change
-
Agent in the repo. Check the base:
ls packages/supabase/migrations | tail -1prints20261103120000_email_payload_drop_document_slug.sql. If a newer migration exists, read it first. -
Agent in the repo. In
packages/supabase/scripts/10-functions.sql, beside the named invoker grants (:922-928), add for the two functions defined in that file:revoke execute on function public.get_unread_notifications_paginated(character varying, text, integer, integer) from public, anon; grant execute on function public.get_unread_notifications_paginated(character varying, text, integer, integer) to authenticated; revoke execute on function public.get_channel_notif_state(character varying) from public, anon; grant execute on function public.get_channel_notif_state(character varying) to authenticated;
-
Agent in the repo. In
packages/supabase/scripts/07-1-notification-functions.sql, after theALTER FUNCTIONat:129, add the same pair forpublic.get_workspace_notifications(uuid, character varying, integer, integer, boolean). -
Agent in the repo. Add one migration,
packages/supabase/migrations/<timestamp>_revoke_anon_invoker_notification_rpcs.sql, with the same six statements. End it with aDOblock that raises an exception ifanoncan still run any of the three, orauthenticatedcannot. The block does not assert onservice_role. Copy the assert shape of migration20261014121000. -
Agent in the repo. Apply it locally without a reset:
docker exec -i supabase_db_docsplus_supabase psql -U postgres -d postgres < packages/supabase/migrations/<timestamp>_revoke_anon_invoker_notification_rpcs.sql
Run the query in the Benchmark section locally. Expect
anonfalse andauthenticatedtrue on all three. -
Agent in the repo. Run
bun run --filter @docs.plus/supabase_back check(functions parity and grant allowlists). Runbun run --filter @docs.plus/supabase_back typesand include any change toapps/webapp/src/types/supabase.tsin the same change. Do not editpackages/supabase/seed.sql. Ask the maintainer whether this change regenerates it. -
Agent in the repo. Local UX check, signed in: open the notification panel and toggle chat notifications on a scratch pad you created. As a guest, open that pad's chat and read only. The console shows no 401, 403 or
42501. Delete the scratch pad after. Then stop at a review checkpoint. -
Maintainer. Commit through the
commit-reviewskill. Before the push, run the Benchmark query read-only, with itsservice_rolecolumn, and post it here as the before. This before can only be read before the push. Also runpackages/supabase/scripts/check-grants.sqlread-only as a baseline. Followpackages/supabase/CLAUDE.md§db pushhistory divergence: runbunx supabase migration listfirst. Then push this one migration. -
Maintainer. After the push, run
check-grants.sqland the Benchmark query on production, read-only. Post aMeasuredcomment here and tick the row on [Tracking] Supabase prod security and performance review, 2026-09-28 #327.
Benchmark
| Field | Value |
|---|---|
| Metric | Notification RPCs that anon can EXECUTE on production, out of 3 (has_function_privilege). Control: RPCs that authenticated can EXECUTE, out of 3. Control: RPCs that service_role can EXECUTE, out of 3, recorded only |
| Before | anon 3 of 3, authenticated 3 of 3. Read 2026-11-10, production SQL editor, #327 comment. service_role: not read yet. The maintainer reads it before the push (step 8) |
| After | not measured yet |
| Condition | Supabase production project, Postgres 15.8 (before #322). Read-only SQL editor session, within 1 hour of the push |
| How to run | select p.proname, has_function_privilege('anon', p.oid, 'EXECUTE') as anon, has_function_privilege('authenticated', p.oid, 'EXECUTE') as authenticated, has_function_privilege('service_role', p.oid, 'EXECUTE') as service_role from pg_proc p join pg_namespace n on n.oid = p.pronamespace where n.nspname = 'public' and p.proname in ('get_channel_notif_state', 'get_unread_notifications_paginated', 'get_workspace_notifications') order by 1; Then packages/supabase/scripts/check-grants.sql |
| Pass rule | anon 0 of 3, authenticated 3 of 3, and check-grants.sql returns 0 rows. service_role: recorded before and after, no bar. Stop rule: if authenticated reads false on any row, or a signed-in user gets 42501 or 403 from one of the three, push a fix migration that grants authenticated again, the same day. A fix push restarts the clean 24 h before the #325 reset may start. Never grant anon back without a maintainer ruling |
| Guard | Step 7 UX check, again on production after the push. GlitchTip shows no new 42501 or permission denied for function event in 24 h |
| Owner | Steps 1-7: agent in the repo. Steps 8-9: maintainer |
| Claim | Security ledger: "Signed-out visitors can no longer call 3 of 3 notification functions on the docs.plus production database: 3 → 0, verified ." |
Out of scope
- Dropping
get_workspace_notificationsand its wrapper. - A
check-grants.sqlarm for invoker functions.refuse_connected_app_requestandhook_block_password_tokensare invoker on purpose, and revokinganonfrom the first fails every Data API request (packages/supabase/CLAUDE.md).
Related
#327 (parent tracker; its ledger row "Notification RPCs anon can EXECUTE"). #325 and #324 (push before their windows start). #322 (push before its baseline). #570 (pgmq and storage default rights).
Activity
HMarzban commentedon Nov 11, 2026
Maintainer ruling, 2026-11-11
Accept that revoking
EXECUTEfrompublicmay also remove it fromservice_roleon the three RPCs. No server code calls them; the only callers are signed-in webapp hooks and a Cypress stub. Addservice_roleas a control column in the before and after read, so the change is recorded. The migration still lands before the #325 reset.fix(supabase): close three notification RPCs to anon
docs(changelog): cover each v2.3.6 change in its own package
HMarzban commentedon Nov 12, 2026
Measured, 2026-11-12: production after the push.
The maintainer pushed migration
20261112120000to production on 2026-11-12 (supabase db push --remote; it was the only pending migration). The migration's own assert block passed inside production. Read-only read in the Dashboard SQL Editor afterwards (prod-read.sql, query 1):get_channel_notif_stateget_unread_notifications_paginatedget_workspace_notificationsanoncan EXECUTEauthenticatedcan EXECUTEservice_role(recorded, no bar)scripts/check-grants.sqlrowsservice_rolekept EXECUTE, so the accepted loss in the 2026-11-11 ruling did not happen. The commit isfbff54d6d, deployed withd4f80009c.Left before close: a clean 24 h GlitchTip read (no
42501from a live signed-in session) on 2026-11-13.HMarzban commentedon Nov 13, 2026
Measured, 2026-11-13: clean 24 h GlitchTip read
Result. 0 events contain
42501in GlitchTip, from 2026-11-12 13:00Z to 2026-11-13 14:35Z. That window starts before the migration push and runs past 24 h. So no signed-in session lost access to the three notification functions.How. Read-only SQL on the GlitchTip database: every event with
timestamp >= '2026-11-12 13:00Z'whose payload text contains42501. Both browser and server events were in scope.The Guard holds, and the pass rule was met on 2026-11-12 (
anon0 of 3,authenticated3 of 3,check-grants.sql0 rows). Closing this issue. The #325 reset and the #324 window may start from here.chore(release): docs.plus 2.3.6
docs(hocuspocus): record the 2.3.6 migration
fix(supabase): rebuild seed.sql and gate seed drift