Re: Delegating superuser tasks to new security roles (Was: Granting control of SUSET gucs to non-superusers)

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>, Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Jacob Champion <pchampion(at)vmware(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, "chap(at)anastigmatix(dot)net" <chap(at)anastigmatix(dot)net>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, "tgl(at)sss(dot)pgh(dot)pa(dot)us" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>
Subject: Re: Delegating superuser tasks to new security roles (Was: Granting control of SUSET gucs to non-superusers)
Date: 2021-10-20 17:20:28
Message-ID: 833ef7d4227192fdb33a79d43bf5e980392b8340.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 2021-10-19 at 18:52 -0400, Stephen Frost wrote:
> > The implementation in the patch set does this, but with finer
> > grained precision, because the universe of roles is divided into
> > more than just superuser vs. non-superuser.
>
> This last point is particularly important. Non-super users may be
> able to become superuser and those roles which are able to need to
> also be protected. Only protecting superuser roles themselves is
> *not* enough.

I'm trying to suggest an approach that is flexible enough (not limited
to superusers), but also addresses Noah's complaint that ordinary role
membership should not implicitly control event trigger firing.

The most direct way to address Noah's complaint is to make a new
explicit user option BYPASS_EVENT_TRIGGERS, which controls whether
event triggers fire or not.

To create an event trigger, a user would still need to be a member of
predefined role pg_create_event_trigger, which would still be a highly
privileged user that can essentially take over any user without
BYPASS_EVENT_TRIGGER. In practice, the members of
pg_create_event_trigger would be pseudo-superusers, or highly-
privileged roles that come along with a C extension that needs event
triggers.

Details:
* Event triggers created by a superuser would never be bypassed.
* Superusers would always bypass event triggers unless the event
trigger is owned by another superuser.
* If a role is highly privileged and/or can become superuser, it
should have BYPASS_EVENT_TRIGGERS specified so that members of
pg_create_event_trigger can't escalate to that role.
* Normal users should not have BYPASS_EVENT_TRIGGERS.

Another benefit of this is that it makes this event trigger change
independent of the Role Self-Administration discussion, so it could
potentially be committed sooner.

A downside is that with my suggestion, event triggers would still be
for the highly-privileged roles only. Allowing unprivileged users to
create event triggers that have limited scope might allow some really
interesting use cases. There might be some options here, like allowing
any user to create an event trigger that only affects that user.

Regards,
Jeff Davis

(Aside: I'm not really sure where the line is between adding a
predefined role and adding a user option. Are user options just the old
way, and predefined roles the new way?)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Dilger 2021-10-20 17:32:51 Re: Delegating superuser tasks to new security roles (Was: Granting control of SUSET gucs to non-superusers)
Previous Message Anders Kaseorg 2021-10-20 17:09:51 Re: [PATCH] Prefer getenv("HOME") to find the UNIX home directory