From b8e1cae3a5f09cd3d781cfbd88c3f4669a6d650e Mon Sep 17 00:00:00 2001 From: Heni Date: Tue, 3 Nov 2026 12:06:20 -0600 Subject: [PATCH] Stop exposing hack verification contacts to anon verification_contact_info is creator PII. To be safe, we need to stub out permissions and not just stub out the display data, since an attacker could otherwise start running commands manually using extracted public/anonymous credentials powering the public app. --- ...estrict_hack_verification_contact_info.sql | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 supabase/migrations/20261103000000_restrict_hack_verification_contact_info.sql diff --git a/supabase/migrations/20261103000000_restrict_hack_verification_contact_info.sql b/supabase/migrations/20261103000000_restrict_hack_verification_contact_info.sql new file mode 100644 index 0000000..19e6bbd --- /dev/null +++ b/supabase/migrations/20261103000000_restrict_hack_verification_contact_info.sql @@ -0,0 +1,35 @@ +-- verification_contact_info is creator PII. The public hacks policy only checks +-- approved = true, so anon can select the column directly through PostgREST even +-- though the app nulls it after a service-role read. +-- +-- A column-level REVOKE alone does not subtract from a table-level SELECT grant, +-- so first drop the table grant, then grant SELECT on every column except +-- verification_contact_info. The app reads this column with the service-role client +-- and every anon/authenticated hacks query names its columns explicitly, so this +-- does not change application behavior. + +revoke select on table public.hacks from anon, authenticated; + +do $$ +declare + allowed_columns text; +begin + select string_agg(quote_ident(attname), ', ' order by attnum) + into allowed_columns + from pg_attribute + where attrelid = 'public.hacks'::regclass + and attnum > 0 + and not attisdropped + and attname <> 'verification_contact_info'; + + if allowed_columns is null then + raise exception 'public.hacks has no selectable columns'; + end if; + + execute format( + 'grant select (%s) on table public.hacks to anon, authenticated', + allowed_columns + ); +end $$; + +notify pgrst, 'reload schema';