Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bwC3V-0002XA-Au for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Oct 2016 17:50:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bwC3U-0007ui-Th for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Oct 2016 17:50:32 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bwC26-0004wF-21 for pgsql-hackers@postgresql.org; Mon, 17 Oct 2016 17:49:06 +0000 Received: from mail-lf0-x22f.google.com ([2a00:1450:4010:c07::22f]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bwC22-0002G6-Fy for pgsql-hackers@postgresql.org; Mon, 17 Oct 2016 17:49:04 +0000 Received: by mail-lf0-x22f.google.com with SMTP id l131so252111477lfl.2 for ; Mon, 17 Oct 2016 10:49:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=zeYHalAuOxPQ2k6OC0h4De+0UPU8SNUv3SoSluRS4SU=; b=e9ilSRiP/elC+gkiuI90iILj/+MGQKPD4Unp55PKkWRRWk9mzL6tThv9ZXhZPJ/FYb SCz5UNJKEwDSfmjHmqzwuZ8yIAFD/ScRK8bKgQuiPQoJvL+rMHG4Jx8+bme3+eujUaqC aRlqEOa2sUt+8viaL0NoA//kSXLy+5DlzClmycokJdZev2QbDghYBL3agQHS7UjlzF4V vqfOk+TyCtD+cESaOUuKwRDbNtQpSl2XKAUlaSJX5ATaJcYkUOrJdJwAcy9AvszTCw1o 8s1WjTLi0C88tuwdegFh2ZLnDCRvYyTTNoUfTYcYt86n95dXhgjkRwobgAYZgeJqwhYf 1Tag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=zeYHalAuOxPQ2k6OC0h4De+0UPU8SNUv3SoSluRS4SU=; b=D6fiV2vZ6LDFFvbT7ilqBzB8rh6zNsi0zYT/IxB+J2ht4vqRo4nYoEC0btO5KdfSP9 F+g2Jn5AKcZFKmaUdcL7uv9T511upM3NxH1rMsV7cqC2sjIQVETwDhFXT3liuxov4GLk cGr2C0uGN9xUnMRGh6sTb7zw3WS4jsqMSJV+PuAw5a/3oHSML7zl6wTu6982jF1BC0AG fnwGgy7ZmogQOn+6dxH7PzgFJDVuVH9NPGneuRxtDhJITWsfm61qYGKnk2IeuspmLDym A6eZcANehuzZ1g7LvlQHFkSqIdPLybp5sF2dpN+zhMsSrsmFlE9XobXxl/zYCn5tykWk vVgQ== X-Gm-Message-State: AA6/9RkoFTmzptR7ReS5oMo9Jml7Doed0apNmHxRWV2GruR01732shBidBscCcXJJuWccw== X-Received: by 10.25.76.131 with SMTP id z125mr14429242lfa.28.1476726539853; Mon, 17 Oct 2016 10:48:59 -0700 (PDT) Received: from [192.168.1.111] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by smtp.gmail.com with ESMTPSA id c202sm1567876lfc.32.2016.10.17.10.48.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Oct 2016 10:48:59 -0700 (PDT) Subject: Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran To: Tom Lane References: <26591.1476715823@sss.pgh.pa.us> <4f31c7c5-817c-aa3b-ae48-a613008dc558@iki.fi> <28173.1476717663@sss.pgh.pa.us> Cc: pgsql-hackers@postgresql.org From: Heikki Linnakangas Message-ID: Date: Mon, 17 Oct 2016 20:48:58 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 In-Reply-To: <28173.1476717663@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 10/17/2016 06:21 PM, Tom Lane wrote: > Heikki Linnakangas writes: >> On 10/17/2016 05:50 PM, Tom Lane wrote: >>> 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 that it's probably moot on all modern platforms, and even on > platforms as old as pademelon, the answer for people who care about > strong security is "--with-openssl". What I'm on about here is whether > we should make people who don't care about that jump through hoops. > Not caring is a perfectly reasonable stance for non-exposed postmasters; > otherwise we wouldn't have the "trust" auth method. > > I would be satisfied with making it a non-default build option, eg > add this to pg_strong_random: > > if (random_from_file("/dev/random", buf, len)) > return true; > > +#ifdef ALLOW_WEAK_SECURITY > + ... old PostmasterRandom method here ... > +#endif > + > /* None of the sources were available. */ > return false; I also changed pgcrypto to use pg_strong_random(). Using a strong random number generator is even more important for pgcrypto, since it might be used for generating encryption keys. Would we allow a weak generator for pgcrypto too, with ALLOW_WEAK_SECURITY? If we don't, then pgcrypto test cases will still fail on pademelon. If we consider the option to be just for testing, never for production use, then we could allow it, but it feels a bit dangerous, and I'm not sure what's the point of testing a configuration that you should never use in production. I'm going to try implementing prngd support. It seems easy enough, and prngd can be run on modern systems too, which is important for testing it. In addition to that, I'm going to see if we can make postmaster to work sensibly without query cancel keys, if pg_strong_random() fails. That way, you could still run on platforms that don't have /dev/[u]random or prngd, just without support for query cancels, MD5 authentication, and pgcrypto key generation functions. I'd consider that similar to --disable-spinlocks; it would be a helpful step when porting to a new platform, but you wouldn't want to use it in production. One more thing: in hindsight I think would be better to not fall back to /dev/ random, if compiled with OpenSSL support. It really shouldn't fail, and if it does, it seems better to complain loudly. - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers