Re: Hardening PostgreSQL via (optional) ban on local file system access

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Hardening PostgreSQL via (optional) ban on local file system access
Дата
Msg-id CAKFQuwZopC-EeJZZHRuykjA4tU9hntxFkPrd_-KiKr16Kzg8vg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Hardening PostgreSQL via (optional) ban on local file system access  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
On Fri, Jun 24, 2022 at 4:13 PM Andres Freund <andres@anarazel.de> wrote:
Hi,

On 2022-06-25 00:08:13 +0200, Hannu Krosing wrote:
> Currently the file system access is controlled via being a SUPREUSER
> or having the pg_read_server_files, pg_write_server_files and
> pg_execute_server_program roles. The problem with this approach is
> that it will not stop an attacker who has managed to become the
> PostgreSQL  SUPERUSER from  breaking out of the server to reading and
> writing files and running programs in the surrounding container, VM or
> OS.

If a user has superuser rights, they automatically can execute arbitrary
code. It's that simple. Removing roles isn't going to change that. Our code
doesn't protect against C functions mismatching their SQL level
definitions. With that you can do a lot of things.


Using only psql connected by the postgres role, without touching the filesystem to bootstrap your attack, how would this be done?  If you specify CREATE FUNCTION ... LANGUAGE c you have to supply filename references, not a code body and you won't have been able to put that code on the server.

We should be capable of having the core server be inescapable to the filesystem for a superuser logged in remotely.  All such access they can do with the filesystem would be mediated by controlled code/APIs.

C-based extensions would be an issue without a solution that does provide an inescapable sandbox aside from going through our API.  Which I suspect is basically impossible given our forked process driven execution model.

David J.


David J.

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

Предыдущее
От: Hannu Krosing
Дата:
Сообщение: Re: Hardening PostgreSQL via (optional) ban on local file system access
Следующее
От: Gurjeet Singh
Дата:
Сообщение: Re: Hardening PostgreSQL via (optional) ban on local file system access