Re: Allow database owners to CREATE EVENT TRIGGER

From: Steve Chavez <steve(at)supabase(dot)io>
To: Isaac Morland <isaac(dot)morland(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Allow database owners to CREATE EVENT TRIGGER
Date: 2025-05-07 00:34:04
Message-ID: CAGRrpzY-68J9t=1EEkMJ+bVPqvStgaCPVey_zMvrxT=cx-Q34w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Isaac,

> Can somebody remind me why triggers don't run as their owner in the first
place?
> It would make triggers way more useful, and eliminate the whole issue of
trigger owners escalating to whomever tries to access the object on which
the trigger is defined.

Just noted this is already possible when marking the event trigger function
as SECURITY DEFINER (instead of having the SECURITY INVOKER default), it
will fire for every role but keeping the privilege of the event trigger
creator.

Seeing that we have a problem with membership-based event triggers, how
about if we require that regular user event triggers can only have SECURITY
DEFINER functions? We can enforce this at `create event trigger` time.

Best regards,
Steve Chavez

On Wed, 5 Mar 2025 at 11:17, Isaac Morland <isaac(dot)morland(at)gmail(dot)com> wrote:

> On Wed, 5 Mar 2025 at 10:28, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> I wrote:
>> > Or in other words: not-superuser to superuser is far from the only
>> > type of privilege escalation that we need to prevent.
>>
>> After reflecting on that for a moment: maybe say that an event trigger
>> fires for queries that are run by a role that the trigger's owning
>> role is a member of? That changes nothing for superuser-owned
>> triggers.
>>
>
> Can somebody remind me why triggers don't run as their owner in the first
> place?
>
> It would make triggers way more useful, and eliminate the whole issue of
> trigger owners escalating to whomever tries to access the object on which
> the trigger is defined.
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2025-05-07 01:17:15 Re: PG 18 release notes draft committed
Previous Message Ian Lawrence Barwick 2025-05-07 00:18:28 Re: regdatabase