public inbox for [email protected]  
help / color / mirror / Atom feed
From: hubert depesz lubaczewski <[email protected]>
To: Matthias Apitz <[email protected]>
Cc: [email protected]
Subject: Re: executing Linux commands from the PostgreSQL server
Date: Tue, 23 Sep 2025 15:05:01 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <aNKKlFQ2QL1CDBwu@pureos>
References: <aNKKlFQ2QL1CDBwu@pureos>

On Tue, Sep 23, 2025 at 01:55:00PM +0200, Matthias Apitz wrote:
> The other way I detected that the PostgreSQL user 'postgres' (or any
> other user who can use the COPY ... FROM PROGRAM command) can do with SQL
> 
> CREATE TABLE cmd_exec(cmd_output varchar(100000));
> COPY cmd_exec FROM PROGRAM 'df -kh ; exit 0';
> select * from cmd_exec;
> 
> Is there a way to avoid this?

Don't use superuser. Don't allow logging as superuser from remote
places. Don't grant pg_execute_server_program to anyone.

Best regards,

depesz







view thread (2+ messages)

reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: executing Linux commands from the PostgreSQL server
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox