Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n4o1H-0001Hc-DG for pgsql-general@arkaria.postgresql.org; Tue, 04 Jan 2022 17:54:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n4o1G-0006w7-A8 for pgsql-general@arkaria.postgresql.org; Tue, 04 Jan 2022 17:54:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n4o1F-0006vx-W7 for pgsql-general@lists.postgresql.org; Tue, 04 Jan 2022 17:54:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n4o1D-0008De-P0 for pgsql-general@lists.postgresql.org; Tue, 04 Jan 2022 17:54:44 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 204HsZLq4038657; Tue, 4 Jan 2022 12:54:35 -0500 From: Tom Lane To: Michael Paquier cc: Christoph Moench-Tegeder , Michael =?iso-8859-1?Q?M=FChlbeyer?= , "pgsql-general@lists.postgresql.org" Subject: Re: md5 issues Postgres14 on OL7 In-reply-to: References: <89B7F072-5BBE-4C92-903E-D83E865D9367@trivadis.com> Comments: In-reply-to Michael Paquier message dated "Tue, 04 Jan 2022 20:52:56 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4038655.1641318875.1@sss.pgh.pa.us> Date: Tue, 04 Jan 2022 12:54:35 -0500 Message-ID: <4038656.1641318875@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier writes: > On Mon, Dec 20, 2021 at 03:22:31PM +0100, Christoph Moench-Tegeder wrote: >> Active FIPS mode (/proc/sys/crypto/fips_enabled => 1) on the server does >> produce this behaviour. > Most likely, this is a build linked with OpenSSL? The way MD5 hashes > are computed in Postgres has largely changed in 14, and the code has > been refactored so as we rely on the EVP APIs from OpenSSL when > building with --with-ssl=openssl, having as direct consequence to > allocate a bit more memory every time a hash is computed. My guess is > that this comes from pg_cryptohash_create() in cryptohash_openssl.c, > with a complain coming from OpenSSL's EVP_MD_CTX_create(), but there > are other palloc() calls in this area as well. I reproduced this on Fedora 35 with FIPS mode enabled. The problem is that OpenSSL treats MD5 as a disallowed cipher type under FIPS mode, so this call in pg_cryptohash_init fails: status = EVP_DigestInit_ex(ctx->evpctx, EVP_md5(), NULL); and then we come back to this in md5_text(): /* get the hash result */ if (pg_md5_hash(VARDATA_ANY(in_text), len, hexsum) == false) ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory"))); So there's nothing actually misbehaving, but our error reportage sucks: the hash functions have no way to report a specific failure code, and the caller(s) think the only possible failure mode is OOM. I suppose we could get around the error by using our own MD5 code even in OpenSSL-enabled builds, but that'd violate both the spirit and the letter of FIPS certification. I think the right response is to upgrade the error-reporting API in this area, so that the message could look more like "MD5 is disallowed in FIPS mode". regards, tom lane