Intelligence, Advanced Charting & Trading Platform
test(db security): verify PostgreSQL public role cannot execute outbox functions
davoodmehraban89 committed
Oct 22, 2026 at 23:23 UTC
da7879af88ee678bec860fa3af062f04a7045c35
1 file changed
+20
db/tests/notification_outbox_invariants.sql
+20
@@ -154,6 +154,26 @@ BEGIN
154
) THEN
155
RAISE EXCEPTION 'unexpected PUBLIC table privilege';
156
END IF;
157
+
158
+ -- PostgreSQL grants EXECUTE on newly created functions to PUBLIC unless
159
+ -- explicitly revoked; check each privileged outbox function.
160
+ IF EXISTS (
161
+ SELECT 1 FROM pg_catalog.pg_proc AS p
162
+ JOIN pg_catalog.pg_namespace AS n ON n.oid = p.pronamespace
163
+ CROSS JOIN LATERAL pg_catalog.aclexplode(
164
+ COALESCE(p.proacl,pg_catalog.acldefault('f',p.proowner))
165
+ ) AS acl
166
+ WHERE n.nspname = 'public'
167
+ AND p.proname IN (
168
+ 'notification_outbox_enqueue',
169
+ 'notification_outbox_claim',
170
+ 'notification_outbox_finish',
171
+ 'notification_outbox_acknowledge'
172
+ )
173
+ AND acl.grantee = 0 AND acl.privilege_type = 'EXECUTE'
174
+ ) THEN
175
+ RAISE EXCEPTION 'outbox function EXECUTE unexpectedly available to PUBLIC';
176
+ END IF;
177
END $$;
178
179
ROLLBACK;