PostgreSQL Event Triggers without superuser access
Supabase's supautils extension lets non-superusers create Postgres Event Triggers by intercepting `create event trigger` from a "privileged role" via ProcessUtility_hook, temporarily elevating to superuser for creation, then assigning ownership back to the privileged role. Because event triggers fire for every role with the invoking role's privileges, this alone would allow privilege escalation, such as a trigger that runs `alter role ... superuser` when a superuser executes DDL. To prevent that, the extension uses fmgr_hook to replace user event trigger functions with a no-op (`version()`) whenever a superuser or reserved role is executing. The feature is live for new Supabase projects, and upstream patches proposing more restricted user event triggers in Postgres core are under discussion.
Related posts
- Protecting reserved roles with PostgreSQL Hooks
Supabase hardMasterSupabase grants customers the CREATEROLE privilege while preventing them from altering or dropping its internal service roles (like supabase_storage_admin) via a C extension, SupaUtils, that hooks PostgreSQL's ProcessUtility_hook. The hook chains any previously installed hook, reads a reloadable GUC parameter supautils.reserved_roles, and inspects AlterRoleStmt and DropRoleStmt nodes to raise an insufficient-privilege error when a reserved role is targeted. The walkthrough covers the PGXS Makefile, _PG_init registration, DefineCustomStringVariable, and testing via shared_preload_libraries, mirroring how Amazon RDS's rdsutils protects rds-prefixed roles.
- Postgres Event Triggers Are Now Supported in Neon
Neon mediumAdept
Neon now supports Postgres event triggers through the neon_superuser role, and they behave exactly as in vanilla Postgres. Unlike row-level triggers, event triggers fire on DDL commands such as CREATE, ALTER and DROP. They can audit schema changes on ddl_command_end, automate metadata updates or alerts, and feed schema changes to sync engines like Zero via pg_event_trigger_ddl_commands(). Short examples show blocking DROP TABLE for non-admin roles and cleaning up orphaned pg_cron jobs on sql_drop using pg_event_trigger_dropped_objects().
- Supabase Auth: Identity Linking, Hooks, and HaveIBeenPwned integration
Supabase mediumAdeptSupabase Auth adds four features: manual Identity Linking via linkIdentity()/unlinkIdentity() for OAuth identities, session controls (time-boxed sessions, inactivity timeouts, single session per user on Pro and above), leaked password protection using the HaveIBeenPwned Pwned Passwords API with configurable password requirements, and Auth Hooks. Auth Hooks are Postgres functions that run synchronously at points such as access token generation, MFA verification and password verification, so they can add custom JWT claims or enforce custom security rules. Webhook-based hooks via Standard Webhooks are planned for Q1 2024. The GoTrue fork is also being renamed to Auth, with no breaking changes.
- Supabase Security Retro: 2025
Supabase easyNoviceSupabase's 2025 security work centered on safer defaults around Postgres Row Level Security and API exposure. Changes include RLS enabled by default for dashboard-created tables, event triggers to enforce RLS on tables created elsewhere, and alerts plus Splinter-based Security Advisors for misconfigurations. Long-lived JWT anon/service_role keys are being replaced by publishable and revocable secret keys, with asymmetric JWT signing and automatic revocation of keys leaked to GitHub. Legacy keys will be removed in late 2026, and pg_graphql will be disabled by default on new projects. The HackerOne VDP has resolved 139 reports with a median first response of 8 hours, and paid bounties are planned for 2026.
- Postgres Roles and Privileges
Supabase mediumAdeptPostgres access control rests on objects, privileges, roles and ownership: an object's owner holds all privileges on it and is the one who can grant them, so even an admin-like role such as Supabase's non-superuser postgres gets permission denied when granting on a table it neither owns nor holds privileges on. A psql walkthrough with junior_dev and senior_dev roles shows granting CREATE on a schema, reading ACLs with \dn+, \dp and \ddp, delegating with WITH GRANT OPTION, and using ALTER DEFAULT PRIVILEGES so tables created later are automatically shared.