Re: PSQL Client command line password leak when using Connection String

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Luis Díaz <luisjesusdm(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: PSQL Client command line password leak when using Connection String
Date: 2022-02-08 07:56:24
Message-ID: CABUevEyJYGt4q0mBWZUiumX8foOxywguS9a8NZgK-A+i5Ywx1Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Feb 8, 2022 at 8:52 AM Luis Díaz <luisjesusdm(at)gmail(dot)com> wrote:

> Hello,
>
> In Unix, the command line of all users is public and when using a
> connection string, sensitive data is passed unencrypted (the password)
>
> I think some Linux/Unix command-line utilities do clear the command line
> on initialization to prevent leaking sensitive information that needs to be
> passed over the command line.
>
> I have tested the PSQL Client to not be clearing the password from the
> command line string when a non-privileged user reviews the process.
>
> To reproduce:
> psql "postgresql://postgres:password(at)localhost:5432/database" -c "SELECT
> clock_timestamp(),pg_sleep(200),clock_timestamp()" &
> [220068]
> ps -f -p 220068
> /usr/lib/postgresql/12/bin/psql postgresql://postgres:password(at)localhost
> :5432/database
>
>

This is not a function of PostgreSQL, but one of your operating system. If
the operating system that shows this information, not PostgreSQL. There is
no way that psql (or other tools) could know if what you pass is sensitive
-- you could just as well have put sensitive data in the query for -c, for
example.

That said, you shouldn't be putting your password on the commandline if you
are not in a secure environment. PostgreSQL provides multiple different
ways to pass the password, such as an environment variable or the .pgpass
file.

//Magnus

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Etsuro Fujita 2022-02-08 09:09:09 Re: BUG #17355: Server crashes on ExecReScanForeignScan in postgres_fdw when accessing foreign partition
Previous Message PG Bug reporting form 2022-02-08 01:40:32 BUG #17399: Dead tuple number stats not updated on long running queries