Commit 9fb64b3
fix(security): restrict new SECURITY DEFINER functions to authenticated (#509)
Functions created in `public` carry a default PUBLIC execute grant, so the
explicit grants to `authenticated` left both new helpers reachable over
PostgREST as `anon` — flagged by the Supabase security advisor as
`anon_security_definer_function_executable`.
Neither leaks anything (`is_tenant_staff()` reports only on the caller and
returns false for anon; `get_published_lesson_counts()` returns counts and
is tenant-scoped), but neither has any anon caller either: the public
catalog reads lesson metadata through the service-role client. Revoking
PUBLIC/anon keeps them off the REST surface.
Applied to the cloud database and re-applied locally; grants now match on
both (`{postgres, authenticated, service_role}`).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P8ZG2FwbBprWLvFF4V8SVx1 parent 704f233 commit 9fb64b3
1 file changed
Lines changed: 8 additions & 1 deletion
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| |||
134 | 138 | | |
135 | 139 | | |
136 | 140 | | |
137 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
0 commit comments