From: Bryn Llewellyn <bryn@yugabyte.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: Is it possible to stop sessions killing eachother when they all authorize as the same role?
Date: Mon, 12 Sep 2022 18:08:23 -0700
Message-ID: <2F078227-5EEF-4553-89FF-046A6AF12F25@yugabyte.com> (raw)
In-Reply-To: <CAKFQuwYr78FAFX4dFL3Mp4qiBZHzQtChTmO91d9FvYn09GzCfw@mail.gmail.com>
References: <10F360BB-3149-45E6-BFFE-10B9AE31F1A6@yugabyte.com>
<CAKFQuwYr78FAFX4dFL3Mp4qiBZHzQtChTmO91d9FvYn09GzCfw@mail.gmail.com>
> david.g.johnston@gmail.com wrote:
>
>> bryn@yugabyte.com wrote:
>>
>> …I'm troubled by the notion that (as it seems) one session that authorizes as the role "r1" can easily list all other concurrent sessions that are also authorized as "r1"—and kill them all without restriction. (The doc does say "Use of these functions is usually restricted to superusers, with noted exceptions." So I s'pose that I'm talking about one of these noted exceptions.)
>
> You can always choose to limit that function to explicitly granted roles if you wish. And write security definer functions if you desire some different rules… There are only a couple of relevant functions so revoking default privileges and granting them explicitly gives you the same outcome as adding the pg_signal_backend predefined role… I'll agree it is an insecure default…
This sounds like exactly what I want—and what I was asking about. But how do I "limit pg_terminate_backend() to explicitly granted roles?" Out of the box, any role can execute it. So yes… "revoking default privileges and granting them explicitly" is what I want. But how? I'd already tried authorizing as a superuser and doing this:
revoke execute on function pg_terminate_backend(int, bigint) from public;
It ran without error. But even so, a freshly created non-super role was still able to kill sessions that had authorized as the same role. So I assumed that there was something hard-wired about the accessibility of "pg_terminate_backend()".
In other words, where can I read about this and learn how to do what you propose? (Of course I see that with this achieved, "security definer" subprograms would then bring their usual value.)
> having a login privilege for the database comes with power and responsibility
I can't accept that having a login privilege will give any session that logs on unlimited power to act. The notions of object ownership, privileges, "security definer" subprograms, and so on support my stance.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: bryn@yugabyte.com, david.g.johnston@gmail.com
Subject: Re: Is it possible to stop sessions killing eachother when they all authorize as the same role?
In-Reply-To: <2F078227-5EEF-4553-89FF-046A6AF12F25@yugabyte.com>
References: <10F360BB-3149-45E6-BFFE-10B9AE31F1A6@yugabyte.com> <CAKFQuwYr78FAFX4dFL3Mp4qiBZHzQtChTmO91d9FvYn09GzCfw@mail.gmail.com> <2F078227-5EEF-4553-89FF-046A6AF12F25@yugabyte.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox