From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Jan Bilek <jan.bilek@eftlab.com.au>
To: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: PCI:SSF - Safe SQL Query & operators filter
Date: Tue, 08 Nov 2022 04:19:48 +0100
Message-ID: <5d4b5fcba15b2c871d83e99cae974c01c7bfc1dd.camel@cybertec.at> (raw)
In-Reply-To: <e3cb6a78-8ff2-dcf1-2fdd-26e3093d3106@eftlab.com.au>
References: <e3cb6a78-8ff2-dcf1-2fdd-26e3093d3106@eftlab.com.au>
On Tue, 2022-11-08 at 01:24 +0000, Jan Bilek wrote:
> I am leading PCI:SSF audit on our payment switch platform product and having a issue where our QSA
> just came with multiple ways how to escalate privileges and get a shell to the remote host through
> our built-in Reporting system which runs on PostgreSQL (12-14).
> So these - pg_read_server_files, pg_write_server_files and pg_execute_server_program roles are
> inherited from the Superuser and are also super sensitive for us, but our application user apparently
> still needs to be superuser for multiple reasons. Would there be any way to go around this?
Your application user doesn't need to be a superuser.
> 1/ What we need is to create a postgresql user who would be pg_database_owner but not superuser ...
> but apparently we still need our user to be superuser to be able to carry on with some operations
> (picking one of more then few) ....
> CREATE OR REPLACE LANGUAGE plpython3u;
> HINT: Must be superuser to create this extension.
Your application user doesn't need to create PL/Python functions. It only has to use them.
If your application has to access the operating system, it has to do that in a controlled
fashion:
1. through well-written SECURITY DEFINER functions that belong to a highly privileged user
2. through PL/Python functions or other untrusted language functions that are created
by a superuser
> 2/ Second option is to introduce some sort of limitation of allowed SQL queries and operators
> for our Reporting engine, but all that white-listing / blacklisting comes with its own
> problems where we are DB agnostic...
That shouldn't be necessary. If your application user has restricted privileges as it should,
it is automatically limited in the damage it can do.
Yours,
Laurenz Albe
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: laurenz.albe@cybertec.at, jan.bilek@eftlab.com.au
Subject: Re: PCI:SSF - Safe SQL Query & operators filter
In-Reply-To: <5d4b5fcba15b2c871d83e99cae974c01c7bfc1dd.camel@cybertec.at>
References: <e3cb6a78-8ff2-dcf1-2fdd-26e3093d3106@eftlab.com.au> <5d4b5fcba15b2c871d83e99cae974c01c7bfc1dd.camel@cybertec.at>
* 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