Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tlp0M-002BHX-LV for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Feb 2025 12:53:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tlp0L-00AknN-DQ for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Feb 2025 12:53:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tlp0L-00AknF-1h for pgsql-hackers@lists.postgresql.org; Sat, 22 Feb 2025 12:53:13 +0000 Received: from mail1.dalibo.net ([51.159.93.128] helo=mail.dalibo.com) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tlp0I-0009PN-14 for pgsql-hackers@lists.postgresql.org; Sat, 22 Feb 2025 12:53:12 +0000 Received: from [192.168.1.131] (35.108.220.81.rev.sfr.net [81.220.108.35]) by mail.dalibo.com (Postfix) with ESMTPSA id 1D3C426335 for ; Sat, 22 Feb 2025 13:53:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1740228789; bh=pCHeCe1FqzfW2q8YE3ee4Tn6PHjDDXm3yvh6kXaQrNs=; h=Date:Subject:To:References:From:In-Reply-To:From; b=cQcYEZYZe5IiHwZ92xIrCXKFRj5iX6XqF2fnHPCHaPGDtgITOIial/xdYlYLMTCB+ RLa48nTxlRVqhkuQ0Z6SrY0IvIiub5HTKygkVFd5dgt2/hwW2VNbhN+aFZE8ZEEmei w2flca6s24g3Tt01hsnnkgOMRTYu/m0HjDLErrbs= Message-ID: <99ba5653-b234-48b4-9bc5-4d2fad13eac4@dalibo.com> Date: Sat, 22 Feb 2025 13:53:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: PATCH: warn about, and deprecate, clear text passwords To: pgsql-hackers@lists.postgresql.org References: Content-Language: fr From: Guillaume Lelarge Organization: Dalibo In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 22/02/2025 09:07, Guillaume Lelarge wrote: > On 21/02/2025 23:33, Greg Sabino Mullane wrote: >> There have been a few complaints lately about the fact that we >> cavalierly allow clear text passwords to be sent when doing CREATE >> USER or ALTER USER. These, of course, can end up in many places, such >> as pg_stat_activity, pg_stat_statements, .psql_history, and the server >> logs. It is a genuinely valid complaint, and for security purposes, >> there is little recourse other than telling users "don't do that". The >> canonical recommendation is to use psql's awesome \password feature. >> Second best is to use your application/driver of choice, which >> hopefully has support for not sending passwords in the clear. >> >> Please find attached a patch to implement a new GUC called >> cleartext_passwords_action as an attempt to solve these problems. It >> is an enum and accepts one of three values: >> >> 1. "warn" (the new default) >> >> This issues a warning if a clear text password is used, but allows the >> change to proceed. The hint can change to recommend \password if the >> current application_name is 'psql'. By keeping this as a warning, we >> let people know this is a bad idea, and give people time to modify >> their applications. >> >> Examples: >> >> ALTER USER alice PASSWORD 'mynewpass'; >> WARNING:  using a clear text password >> DETAIL:  Sending a password using plain text is deprecated and may be >> removed in a future release of PostgreSQL. >> HINT:  Use a client that can change the password without sending it in >> clear text >> >> ALTER USER eve PASSWORD 'anothernewpass'; >> WARNING:  using a clear text password >> DETAIL:  Sending a password using plain text is deprecated and may be >> removed in a future release of PostgreSQL. >> HINT:  If using psql, you can set the password with \password >> >> 2. "allow" >> This does nothing, and thus emulates the historical behavior. >> >> 3. "disallow" >> This prevents the use of plain old text completely, by throwing an >> error if a password set or change is attempted. So people who want to >> prevent clear text can do so right away, and at some point we can make >> this the default (and people can always change to hint or allow if >> desired) >> >> Bike shedding welcome. I realize the irony that 'disallow' means valid >> attempts will now show up in the database logs that otherwise would >> not, but I'm not sure how to work around that (or if we should). >> > > I'm obviously +1 on this patch since I sent kinda the same patch two > weeks ago (https://www.postgresql.org/message- > id/8f17493f-0886-406d-8573-0fadcb998b1d%40dalibo.co). The only major > difference is that your patch can completely disable plain text > passwords. More options, that sounds better to me. > It applies cleanly, compiles without errors or even warnings. I did some tests, and I only found one small issue: set password_encryption to 'md5'; create user u4 password 'md5u1'; WARNING: using a clear text password DETAIL: Sending a password using plain text is deprecated and may be removed in a future release of PostgreSQL. HINT: If using psql, you can set the password with \password WARNING: setting an MD5-encrypted password DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL. HINT: Refer to the PostgreSQL documentation for details about migrating to another password type. CREATE ROLE It complains that I'm using a plain text password and a MD5-encrypted password. Can't be both. (Probably not an issue with this patch, but rather an issue with the commit that implemented MD5-password warnings.) If I use a real md5 password, it only complains about MD5 encrypted password: create user u5 password 'md58026a39c502750413402a90d9d8bae3c'; WARNING: setting an MD5-encrypted password DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL. HINT: Refer to the PostgreSQL documentation for details about migrating to another password type. CREATE ROLE Other tests were successful. Thanks Greg! -- Guillaume Lelarge Consultant https://dalibo.com