Re: Possibility to disable `ALTER SYSTEM`

Поиск
Список
Период
Сортировка
От Gabriele Bartolini
Тема Re: Possibility to disable `ALTER SYSTEM`
Дата
Msg-id CA+VUV5pK4N8FaGa0y47ZFVk9qWOwWMYOAUtX0J-o4A7hHfJRYA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Possibility to disable `ALTER SYSTEM`  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi Tom and Alvaro,

On Fri, 8 Sept 2023 at 17:31, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> I don't understand Tom's resistance to this request.

It's false security.  If you think you are going to prevent a superuser
from messing with the system's configuration, you are going to need a
lot more restrictions than this, and we'll be forever getting security
reports that "hey, I found another way for a superuser to get filesystem
access".  I think the correct answer to this class of problems is "don't
give superuser privileges to clients running inside the container".

Ok, this is clearer. That makes sense now, and this probably helps me explain better the goal here. I also omitted in the initial email all the security precautions that a Kubernetes should take. This could be another step towards that direction but, you are right, it won't fix it entirely (in case of malicious superusers).

In my opinion, the biggest benefit of this possibility is on the usability side, providing a clear and configurable way to disable ALTER SYSTEM in those environments where declarative configuration is a requirement. For example, this should at least "warn" human beings that have the permissions to connect to a Postgres database (think of SREs managing a DBaaS solution or a DBA) and try to change a setting in an instance. Moreover, for those who are managing through declarative configuration not only one instance, but a Postgres cluster that controls standby instances too, the benefit of impeding these modifications could be even higher (think of the hot standby sensitive parameters like max_connections that require coordination depending whether you increase or decrease them).
 
I hope this is clearer. For what it's worth, I have done a basic PoC patch (roughly 20 lines of code), which I have attached here just to provide some basis for further analysis and comments. The general idea is to disable ALTER SYSTEM at startup, like this:

pg_ctl start -o "-c enable_alter_system=off"

The setting can be verified with:

psql -c 'SHOW enable_alter_system'
 enable_alter_system
---------------------
 off
(1 row)

And then:

psql -c 'ALTER SYSTEM SET max_connections TO 10'
ERROR:  permission denied to run ALTER SYSTEM

Thanks for your attention and looking forward to getting feedback and advice.

Cheers,
Gabriele
--
Gabriele Bartolini
Vice President, Cloud Native at EDB
Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Jeff Davis
Дата:
Сообщение: Re: Avoid a possible null pointer (src/backend/utils/adt/pg_locale.c)
Следующее
От: Magnus Hagander
Дата:
Сообщение: Re: Possibility to disable `ALTER SYSTEM`