executing Linux commands from the PostgreSQL server

From: Matthias Apitz <guru(at)unixarea(dot)de>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: executing Linux commands from the PostgreSQL server
Date: 2025-09-23 11:55:00
Message-ID: aNKKlFQ2QL1CDBwu@pureos
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hello,

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?

matthias

--
Matthias Apitz, ✉ guru(at)unixarea(dot)de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub

Annalena Baerbock: "We are fighting a war against Russia ..." (25.1.2023)

I, Matthias, I am not at war with Russia.
Я не воюю с Россией.
Ich bin nicht im Krieg mit Russland.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message hubert depesz lubaczewski 2025-09-23 13:05:01 Re: executing Linux commands from the PostgreSQL server
Previous Message Álvaro Herrera 2025-09-23 10:30:18 Re: Quick questions about postgres name?