mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-11-29 15:51:52 +00:00
security: lock blog backup table, revoke trigger/default EXECUTE (#259)
Some checks failed
CI / build (push) Has been cancelled
Deploy to dev2 / deploy (push) Has been cancelled
test / test (push) Has been cancelled
Some checks failed
CI / build (push) Has been cancelled
Deploy to dev2 / deploy (push) Has been cancelled
test / test (push) Has been cancelled
Applied to prod by hand. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7cc95b8e1f
commit
ced6c5ac20
1 changed files with 30 additions and 0 deletions
30
supabase/migrations/20261026230000_secdef_lockdown.sql
Normal file
30
supabase/migrations/20261026230000_secdef_lockdown.sql
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
-- Function defaults and a stray backup table (2026-10-26 fleet audit).
|
||||||
|
--
|
||||||
|
-- The one exposed SECURITY DEFINER function is the rls_auto_enable event
|
||||||
|
-- trigger; it is revoked from anon/authenticated with every trigger function.
|
||||||
|
-- blog_posts_bak_20261014 had RLS off and full anon/authenticated grants, so
|
||||||
|
-- the anon key could read, rewrite or delete it.
|
||||||
|
|
||||||
|
-- Trigger and event-trigger functions are never RPCs.
|
||||||
|
do $$
|
||||||
|
declare f regprocedure;
|
||||||
|
begin
|
||||||
|
for f in
|
||||||
|
select p.oid::regprocedure
|
||||||
|
from pg_proc p join pg_namespace n on n.oid = p.pronamespace
|
||||||
|
where n.nspname = 'public'
|
||||||
|
and p.prorettype in ('trigger'::regtype, 'event_trigger'::regtype)
|
||||||
|
and not exists (select 1 from pg_depend d where d.classid = 'pg_proc'::regclass and d.objid = p.oid and d.deptype = 'e')
|
||||||
|
loop
|
||||||
|
execute format('revoke execute on function %s from public, anon, authenticated', f);
|
||||||
|
end loop;
|
||||||
|
end $$;
|
||||||
|
|
||||||
|
-- New functions are not executable by PUBLIC/anon/authenticated by default.
|
||||||
|
-- A new function the browser calls (or an RLS policy uses) needs an explicit
|
||||||
|
-- GRANT EXECUTE ... TO anon, authenticated.
|
||||||
|
alter default privileges for role postgres revoke execute on functions from public;
|
||||||
|
alter default privileges for role postgres in schema public revoke execute on functions from public, anon, authenticated;
|
||||||
|
|
||||||
|
alter table public.blog_posts_bak_20261014 enable row level security;
|
||||||
|
revoke all on public.blog_posts_bak_20261014 from anon, authenticated;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue