pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
Date: Mon, 17 Oct 2016 11:18:14 -0400
Message-ID: <20161017151814.GV13284@tamriel.snowman.net> (raw)
In-Reply-To: <4f31c7c5-817c-aa3b-ae48-a613008dc558@iki.fi>
References: <E1bw3g3-0003st-6M@gemulon.postgresql.org>
	<26591.1476715823@sss.pgh.pa.us>
	<4f31c7c5-817c-aa3b-ae48-a613008dc558@iki.fi>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

* Heikki Linnakangas (hlinnaka@iki.fi) wrote:
> On 10/17/2016 05:50 PM, Tom Lane wrote:
> >Heikki Linnakangas <heikki.linnakangas@iki.fi> writes:
> >>Replace PostmasterRandom() with a stronger way of generating randomness.
> >
> >This patch broke padmeleon:
> >
> >016-10-17 09:57:17.782 EDT [5804d8bd.57c2:1] LOG:  database system was shut down at 2016-10-17 09:57:17 EDT
> >2016-10-17 09:57:17.790 EDT [5804d8bd.57c2:2] LOG:  MultiXact member wraparound protections are now enabled
> >2016-10-17 09:57:17.807 EDT [5804d8bd.57c6:1] LOG:  autovacuum launcher started
> >2016-10-17 09:57:17.820 EDT [5804d8bd.57bf:1] LOG:  database system is ready to accept connections
> >2016-10-17 09:57:18.516 EDT [5804d8bd.57bf:2] LOG:  could not generate random query cancel key
> >2016-10-17 09:57:19.544 EDT [5804d8bd.57bf:3] LOG:  could not generate random query cancel key
> >2016-10-17 09:57:20.563 EDT [5804d8bd.57bf:4] LOG:  could not generate random query cancel key
> >2016-10-17 09:57:21.584 EDT [5804d8bd.57bf:5] LOG:  could not generate random query cancel key
> >2016-10-17 09:57:22.604 EDT [5804d8bd.57bf:6] LOG:  could not generate random query cancel key
> >
> >It's failing because this machine lacks /dev/random and /dev/urandom.
> >It does have a non-kernel entropy daemon (prngd), which OpenSSL knows how
> >to read from but the hard-wired code in pg_strong_random() does not.
> >
> >I'm not sure whether it's worth trying to make pg_strong_random() aware
> >of prngd.
> 
> Seems simple enough..

If it is, then that's certainly tempting, especially if that's the only
platform we support where we don't have a better option, and we wish to
continue supporting it.

> > The real issue here is whether we are willing to say that
> >Postgres simply does not work anymore on machines without standard entropy
> >sources.  Doesn't matter whether the user cares about the strength of
> >cancel keys, we're just blowing them off.  That seems a bit extreme
> >from here.  I think we should be willing to fall back to the old code
> >if we can't find a real entropy source.
> 
> I'm scared of having pg_strong_random() that is willing to fall back
> to not-so-strong values. We can rename it, of course, but it seems
> dangerous to use a weak random-number generator for authentication
> purposes (query cancel, MD5 salts, SCRAM nonces).
> 
> I think both for the MD5 salt and SCRAM, it doesn't have to be
> unpredictable to attackers, as long the attacker cannot influence it
> so that a particular value is chosen. For query cancel, it needs to
> be unpredictable, but the query cancel key is quite short anyway,
> and we haven't worried about it so far anyway, because an attacker
> can't do very much damage by just canceling queries.
> 
> One option would be to disable query-canceling and MD5 (and SCRAM)
> authentication, if we don't have an entropy source.

Wouldn't it be possible to make this a build-time question..?  I don't
particularly like the idea of pg_strong_random() falling back to
not-strong values, but maybe we could have a '--use-weak-random'
configure switch for platforms that don't provide a strong source.

Then again, if we wish to support this platform, then perhaps we should
put in the effort to support prngd.

Thanks!

Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

view thread (21+ messages)  latest in thread

Message-ID: <20161017151814.GV13284@tamriel.snowman.net>
Permalink:  ../20161017151814.GV13284@tamriel.snowman.net/
Also on:    postgresql.org/message-id/20161017151814.GV13284@tamriel.snowman.net

 · 

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-committers@postgresql.org
  Cc: sfrost@snowman.net, hlinnaka@iki.fi, tgl@sss.pgh.pa.us, heikki.linnakangas@iki.fi, pgsql-hackers@postgresql.org
  Subject: Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran
  In-Reply-To: <20161017151814.GV13284@tamriel.snowman.net>
  References: <E1bw3g3-0003st-6M@gemulon.postgresql.org> <26591.1476715823@sss.pgh.pa.us> <4f31c7c5-817c-aa3b-ae48-a613008dc558@iki.fi> <20161017151814.GV13284@tamriel.snowman.net>

* 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