pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Arthur Zakirov <a.zakirov@postgrespro.ru>
Cc: rhpatrick@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15961: psql should be able to read password from stdin
Date: Mon, 19 Aug 2019 10:07:25 -0400
Message-ID: <20826.1566223645@sss.pgh.pa.us> (raw)
In-Reply-To: <174993ee-33da-4b5a-8568-7575b7f9e9dc@postgrespro.ru>
References: <15961-a17e673003b92f17@postgresql.org>
	<174993ee-33da-4b5a-8568-7575b7f9e9dc@postgrespro.ru>

Arthur Zakirov <a.zakirov@postgrespro.ru> writes:
> On 16.08.2019 17:20, PG Bug reporting form wrote:
>> My use case is that I am writing terraform scripts to standup Sonarqube in
>> AWS.  After creating the AWS RDS PostgreSQL database, I need to be able to
>> create the sonarqube user and grant access to the sonarqube database that
>> was created with the RDS instance.  I can work around this using the
>> PGPASSWORD environment variable but that seems to be deprecated.  I don't
>> want to use the .pgpass solution since I don't want/need the postgres user's
>> credentials in my EC2 instance where the Sonarqube server will be running...

> Is PGPASSWORD really deprecated?

It's insecure on some platforms (where other users can see a process's
environment variables).  AWS may not be like that, not sure.

> I guess passing a password by command-line might have similar security 
> problems. If it suits you then PGPASSWORD should work for you too.

Yeah, this.  It's not very clear to me how such a feature wouldn't just
move the security problem somewhere else.  Where is the program on the
front end of the pipe going to get the password from?

I don't think that Peter's objection has much force.  We could just
say that a password-from-stdin feature is only allowed in combination
with -f and/or -c, so that there's no conflict as to what stdin should
provide.  So given a bulletproof use-case, I wouldn't be averse to
adding such a feature.  But if it's just moving the problem elsewhere,
I'm not in favor of it.  We try to steer people away from insecure
password usage --- that's why there's no put-the-password-on-the-
command-line option.  (I'm afraid that password-from-stdin would
encourage people to do "echo $PASSWORD | psql" and thereby be
completely vulnerable to command-line exposure hazards.)

In any case, that would be a new feature not a bug fix, so the very
earliest you could hope to see it would be v13 next year.  For
shorter-term fixes, you could consider:

* Run psql in an environment where /dev/tty is a pseudo-tty that
you can feed input to.  This fails to avoid any of the security
questions mentioned above, but at least it's a solution available
today.

* Don't use passwords.  PG offers a bunch of other authentication
technologies that are way friendlier to use in scripts.

			regards, tom lane





view thread (6+ messages)  latest in thread

Message-ID: <20826.1566223645@sss.pgh.pa.us>
Permalink:  ../20826.1566223645@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20826.1566223645@sss.pgh.pa.us

 · 

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 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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, a.zakirov@postgrespro.ru, rhpatrick@gmail.com
  Subject: Re: BUG #15961: psql should be able to read password from stdin
  In-Reply-To: <20826.1566223645@sss.pgh.pa.us>
  References: <15961-a17e673003b92f17@postgresql.org> <174993ee-33da-4b5a-8568-7575b7f9e9dc@postgrespro.ru> <20826.1566223645@sss.pgh.pa.us>

* 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