pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feedPATCH: warn about, and deprecate, clear text passwords
33+ messages / 12 participants
[nested] [flat]
* PATCH: warn about, and deprecate, clear text passwords
@ 2025-02-21 22:33 Greg Sabino Mullane <htamfids@gmail.com>
2025-02-22 08:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Guillaume Lelarge <guillaume.lelarge@dalibo.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
0 siblings, 2 replies; 33+ messages in thread
From: Greg Sabino Mullane @ 2025-02-21 22:33 UTC (permalink / raw)
To: pgsql-hackers
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).
--
Cheers,
Greg
--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support
Attachments:
0001-Add-new-server-config-cleartext_passwords_action.patch (application/octet-stream, 17.5K) download
From 93b52db71255b0ac10458a6b8f37bdc5e658f095 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane <greg@turnstep.com>
Date: Fri, 21 Feb 2025 16:16:12 -0500
Subject: [PATCH] Add new server config cleartext_passwords_action
This controls what happens when someone sends a clear text password
to the server via CREATE USER or ALTER USER. Three states are allowed:
1. "warn" The current default, this issues a warning if a clear
text password is used, but allows the change to proceed. The hint
changes to recommend \password if the current application_name is 'psql'
2. "allow" This does nothing, and thus emulates the historical behavior.
3. "disallow". This prevents the use of plain text completely, by throwing
an error if a password set or change is attempted.
---
.../passwordcheck/expected/passwordcheck.out | 6 ++++
doc/src/sgml/config.sgml | 18 ++++++++++
src/backend/libpq/crypt.c | 34 +++++++++++++++++++
src/backend/utils/misc/guc_tables.c | 17 ++++++++++
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/libpq/crypt.h | 19 +++++++++++
.../ecpg/test/expected/connect-test5.stderr | 16 ++++++---
src/test/regress/expected/create_role.out | 3 ++
src/test/regress/expected/password.out | 33 ++++++++++++++++++
9 files changed, 143 insertions(+), 4 deletions(-)
diff --git a/contrib/passwordcheck/expected/passwordcheck.out b/contrib/passwordcheck/expected/passwordcheck.out
index 83472c76d27..602e91c50ac 100644
--- a/contrib/passwordcheck/expected/passwordcheck.out
+++ b/contrib/passwordcheck/expected/passwordcheck.out
@@ -3,6 +3,9 @@ LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
ALTER USER regress_passwordcheck_user1 PASSWORD 'a_nice_long_password';
+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
-- error: too short
ALTER USER regress_passwordcheck_user1 PASSWORD 'tooshrt';
ERROR: password is too short
@@ -10,6 +13,9 @@ DETAIL: password must be at least "passwordcheck.min_password_length" (8) bytes
-- ok
SET passwordcheck.min_password_length = 6;
ALTER USER regress_passwordcheck_user1 PASSWORD 'v_shrt';
+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
-- error: contains user name
ALTER USER regress_passwordcheck_user1 PASSWORD 'xyzregress_passwordcheck_user1';
ERROR: password must not contain user name
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 007746a4429..fc37b4473ad 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1104,6 +1104,24 @@ include_dir 'conf.d'
</listitem>
</varlistentry>
+ <varlistentry id="guc-cleartext-passwords-action" xreflabel="cleartext_passwords_action">
+ <term><varname>cleartext_passwords_action</varname> (<type>enum</type>)
+ <indexterm>
+ <primary><varname>cleartext_passwords_action</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Controls what action to take when a password is sent unencrypted
+ (i.e. in clear text) to the server via the <command>CREATE ROLE</command>
+ or <command>ALTER ROLE</command> command. Valid options are
+ <literal>allow</literal>, <literal>warn</literal>, or
+ <literal>disallow</literal>.
+ The default value is <literal>warn</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="guc-password-encryption" xreflabel="password_encryption">
<term><varname>password_encryption</varname> (<type>enum</type>)
<indexterm>
diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c
index cbb85a27cc1..b093aa9fef7 100644
--- a/src/backend/libpq/crypt.c
+++ b/src/backend/libpq/crypt.c
@@ -21,12 +21,16 @@
#include "libpq/crypt.h"
#include "libpq/scram.h"
#include "utils/builtins.h"
+#include "utils/guc.h"
#include "utils/syscache.h"
#include "utils/timestamp.h"
/* Enables deprecation warnings for MD5 passwords. */
bool md5_password_warnings = true;
+/* Action to take when clear text passwords are used. */
+int cleartext_passwords_action = CLEARTEXT_ACTION_WARN;
+
/*
* Fetch stored password for a user, for authentication.
*
@@ -131,6 +135,36 @@ encrypt_password(PasswordType target_type, const char *role,
}
else
{
+
+ /*
+ * We are sending clear text passwords to the server. What should we
+ * do about that?
+ */
+ if (cleartext_passwords_action == CLEARTEXT_ACTION_WARN)
+ {
+ ereport(WARNING,
+ (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
+ errmsg("using a clear text password"),
+ errdetail("Sending a password using plain text is deprecated and may be removed in a future release of PostgreSQL."),
+ strncmp(application_name, "psql", 5) == 0
+ ? errhint("If using psql, you can set the password with \\password")
+ : errhint("Use a client that can change the password without sending it in clear text")));
+ }
+ else if (cleartext_passwords_action == CLEARTEXT_ACTION_DISALLOW)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PASSWORD),
+ errmsg("using a clear text password"),
+ errdetail("Sending a password using plain text is not allowed."),
+ strncmp(application_name, "psql", 5) == 0
+ ? errhint("If using psql, you can change the password with \\password")
+ : errhint("Use a client that can change the password without sending it in clear text")));
+ }
+ else
+ {
+ /* Silently accept this bad practice. */
+ }
+
switch (target_type)
{
case PASSWORD_TYPE_MD5:
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 03a6dd49154..9288c23a507 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -409,6 +409,13 @@ static const struct config_enum_entry password_encryption_options[] = {
{NULL, 0, false}
};
+static const struct config_enum_entry cleartext_action_options[] = {
+ {"allow", CLEARTEXT_ACTION_ALLOW, false},
+ {"warn", CLEARTEXT_ACTION_WARN, false},
+ {"disallow", CLEARTEXT_ACTION_DISALLOW, false},
+ {NULL, 0, false}
+};
+
static const struct config_enum_entry ssl_protocol_versions_info[] = {
{"", PG_TLS_ANY, false},
{"TLSv1", PG_TLS1_VERSION, false},
@@ -5298,6 +5305,16 @@ struct config_enum ConfigureNamesEnum[] =
NULL, NULL, NULL
},
+ {
+ {"cleartext_passwords_action", PGC_SIGHUP, CONN_AUTH_AUTH,
+ gettext_noop("Action to take when clear text passwords are used."),
+ },
+ &cleartext_passwords_action,
+ CLEARTEXT_ACTION_WARN, cleartext_action_options,
+ NULL, NULL, NULL
+ },
+
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, 0, NULL, NULL, NULL, NULL
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 5362ff80519..bea94e65d87 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -97,6 +97,7 @@
#password_encryption = scram-sha-256 # scram-sha-256 or md5
#scram_iterations = 4096
#md5_password_warnings = on
+#cleartext_passwords_action = warn # can be allow, warn, or disallow
# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
diff --git a/src/include/libpq/crypt.h b/src/include/libpq/crypt.h
index dee477428e4..d5d0d8af26e 100644
--- a/src/include/libpq/crypt.h
+++ b/src/include/libpq/crypt.h
@@ -28,6 +28,9 @@
/* Enables deprecation warnings for MD5 passwords. */
extern PGDLLIMPORT bool md5_password_warnings;
+/* Specifies action when clear text passwords are used. */
+extern PGDLLIMPORT int cleartext_passwords_action;
+
/*
* Types of password hashes or secrets.
*
@@ -44,6 +47,22 @@ typedef enum PasswordType
PASSWORD_TYPE_SCRAM_SHA_256,
} PasswordType;
+/*
+ * Actions to take when clear text passwords are used.
+ *
+ * Passwords that are sent in clear text via the CREATE/ALTER USER
+ * command can cause a reaction by the server. We can either allow
+ * (the old behavior), warn (throw a warning and hint), or simply
+ * disallow (throws an exception).
+ */
+typedef enum CleartextAction
+{
+ CLEARTEXT_ACTION_ALLOW = 0,
+ CLEARTEXT_ACTION_WARN,
+ CLEARTEXT_ACTION_DISALLOW,
+} CleartextAction;
+
+
extern PasswordType get_password_type(const char *shadow_pass);
extern char *encrypt_password(PasswordType target_type, const char *role,
const char *password);
diff --git a/src/interfaces/ecpg/test/expected/connect-test5.stderr b/src/interfaces/ecpg/test/expected/connect-test5.stderr
index 037db217586..d74cc1f1e81 100644
--- a/src/interfaces/ecpg/test/expected/connect-test5.stderr
+++ b/src/interfaces/ecpg/test/expected/connect-test5.stderr
@@ -4,16 +4,24 @@
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 24: query: alter user regress_ecpg_user2 encrypted password 'insecure'; with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 24: using PQexec
+[NO_PID]: ECPGnoticeReceiver: using a clear text password
[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 0
+[NO_PID]: sqlca: code: 0, state: 01P01
+[NO_PID]: ecpg_execute on line 24: using PQexec
+[NO_PID]: sqlca: code: 0, state: 01P01
[NO_PID]: ecpg_process_output on line 24: OK: ALTER ROLE
-[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: sqlca: code: 0, state: 01P01
[NO_PID]: ecpg_execute on line 25: query: alter user regress_ecpg_user1 encrypted password 'connectpw'; with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 25: using PQexec
+[NO_PID]: ECPGnoticeReceiver: using a clear text password
[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 0
+[NO_PID]: sqlca: code: 0, state: 01P01
+[NO_PID]: ecpg_execute on line 25: using PQexec
+[NO_PID]: sqlca: code: 0, state: 01P01
[NO_PID]: ecpg_process_output on line 25: OK: ALTER ROLE
-[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: sqlca: code: 0, state: 01P01
[NO_PID]: ECPGtrans on line 26: action "commit"; connection "main"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection main closed
diff --git a/src/test/regress/expected/create_role.out b/src/test/regress/expected/create_role.out
index 46d4f9efe99..8347205e4aa 100644
--- a/src/test/regress/expected/create_role.out
+++ b/src/test/regress/expected/create_role.out
@@ -64,6 +64,9 @@ CREATE ROLE regress_login LOGIN;
CREATE ROLE regress_inherit INHERIT;
CREATE ROLE regress_connection_limit CONNECTION LIMIT 5;
CREATE ROLE regress_encrypted_password ENCRYPTED PASSWORD 'foo';
+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
CREATE ROLE regress_password_null PASSWORD NULL;
-- ok, backwards compatible noise words should be ignored
CREATE ROLE regress_noiseword SYSID 12345;
diff --git a/src/test/regress/expected/password.out b/src/test/regress/expected/password.out
index 9bb3ab2818b..ec76afcbcef 100644
--- a/src/test/regress/expected/password.out
+++ b/src/test/regress/expected/password.out
@@ -14,16 +14,25 @@ SET password_encryption = 'scram-sha-256'; -- ok
SET password_encryption = 'md5';
CREATE ROLE regress_passwd1;
ALTER ROLE regress_passwd1 PASSWORD 'role_pwd1';
+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
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 regress_passwd2;
ALTER ROLE regress_passwd2 PASSWORD 'role_pwd2';
+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
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.
SET password_encryption = 'scram-sha-256';
CREATE ROLE regress_passwd3 PASSWORD 'role_pwd3';
+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
CREATE ROLE regress_passwd4 PASSWORD NULL;
-- check list of created entries
--
@@ -63,6 +72,9 @@ ALTER ROLE regress_passwd2_new RENAME TO regress_passwd2;
SET password_encryption = 'md5';
-- encrypt with MD5
ALTER ROLE regress_passwd2 PASSWORD 'foo';
+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
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.
@@ -75,6 +87,9 @@ ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
+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
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
WARNING: setting an MD5-encrypted password
@@ -83,15 +98,27 @@ HINT: Refer to the PostgreSQL documentation for details about migrating to anot
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
+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
-- These may look like valid MD5 secrets, but they are not, so they
-- should be hashed with SCRAM-SHA-256.
-- trailing garbage at the end
CREATE ROLE regress_passwd7 PASSWORD 'md5012345678901234567890123456789zz';
+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
-- invalid length
CREATE ROLE regress_passwd8 PASSWORD 'md501234567890123456789012345678901zz';
+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
-- Changing the SCRAM iteration count
SET scram_iterations = 1024;
CREATE ROLE regress_passwd9 PASSWORD 'alterediterationcount';
+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
SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+/=]+)\$([a-zA-Z0-9+=/]+):([a-zA-Z0-9+/=]+)', '\1$\2:<salt>$<storedkey>:<serverkey>') as rolpassword_masked
FROM pg_authid
WHERE rolname LIKE 'regress_passwd%'
@@ -128,7 +155,13 @@ SELECT rolpassword FROM pg_authid WHERE rolname='regress_passwd_empty';
-- stored/server keys. They will be re-hashed.
CREATE ROLE regress_passwd_sha_len0 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96Rqw=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZI=';
CREATE ROLE regress_passwd_sha_len1 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96RqwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZI=';
+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
CREATE ROLE regress_passwd_sha_len2 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96Rqw=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=';
+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
-- Check that the invalid secrets were re-hashed. A re-hashed secret
-- should not contain the original salt.
SELECT rolname, rolpassword not like '%A6xHKoH/494E941doaPOYg==%' as is_rolpassword_rehashed
--
2.30.2
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
@ 2025-02-22 08:07 ` Guillaume Lelarge <guillaume.lelarge@dalibo.com>
2025-02-22 12:53 ` Re: PATCH: warn about, and deprecate, clear text passwords Guillaume Lelarge <guillaume.lelarge@dalibo.com>
1 sibling, 1 reply; 33+ messages in thread
From: Guillaume Lelarge @ 2025-02-22 08:07 UTC (permalink / raw)
To: pgsql-hackers@lists.postgresql.org
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.
--
Guillaume Lelarge
Consultant
https://dalibo.com
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-22 08:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Guillaume Lelarge <guillaume.lelarge@dalibo.com>
@ 2025-02-22 12:53 ` Guillaume Lelarge <guillaume.lelarge@dalibo.com>
2025-02-24 13:55 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
0 siblings, 1 reply; 33+ messages in thread
From: Guillaume Lelarge @ 2025-02-22 12:53 UTC (permalink / raw)
To: pgsql-hackers@lists.postgresql.org
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
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-22 08:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Guillaume Lelarge <guillaume.lelarge@dalibo.com>
2025-02-22 12:53 ` Re: PATCH: warn about, and deprecate, clear text passwords Guillaume Lelarge <guillaume.lelarge@dalibo.com>
@ 2025-02-24 13:55 ` Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 19:41 ` Re: PATCH: warn about, and deprecate, clear text passwords Guillaume Lelarge <guillaume.lelarge@dalibo.com>
0 siblings, 1 reply; 33+ messages in thread
From: Greg Sabino Mullane @ 2025-02-24 13:55 UTC (permalink / raw)
To: Guillaume Lelarge <guillaume.lelarge@dalibo.com>; +Cc: pgsql-hackers@lists.postgresql.org
Guillaume Lelarge <guillaume.lelarge@dalibo.com> wrote:
I'm obviously +1 on this patch since I sent kinda the same patch two weeks
> ago
Ha ha, my brain forgot about that one (even though I commented on it!) -
apologies for that.
> set password_encryption to 'md5';
> create user u4 password 'md5u1';
> ...
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.)
>
This is correct - it can be both. Not only are we sending a password in
clear text, but we then encrypt it using MD5. Hence, two warnings.
> If I use a real md5 password, it only complains about MD5 encrypted
> password:
Right. If someone sends us something that looks like an already-encrypted
password, we just store it. See get_password_type() in
backend/libpq/crypt.c. In which case, the actual password that a client
would type in would *not* be what was sent over the wire as part of the
ALTER USER / CREATE USER, so we don't complain.
Cheers,
Greg
--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-22 08:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Guillaume Lelarge <guillaume.lelarge@dalibo.com>
2025-02-22 12:53 ` Re: PATCH: warn about, and deprecate, clear text passwords Guillaume Lelarge <guillaume.lelarge@dalibo.com>
2025-02-24 13:55 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
@ 2025-02-24 19:41 ` Guillaume Lelarge <guillaume.lelarge@dalibo.com>
0 siblings, 0 replies; 33+ messages in thread
From: Guillaume Lelarge @ 2025-02-24 19:41 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: pgsql-hackers@lists.postgresql.org
On 24/02/2025 14:55, Greg Sabino Mullane wrote:
> Guillaume Lelarge <guillaume.lelarge@dalibo.com
> <mailto:guillaume.lelarge@dalibo.com>> wrote:
>
> I'm obviously +1 on this patch since I sent kinda the same patch two
> weeks ago
>
>
> Ha ha, my brain forgot about that one (even though I commented on it!) -
> apologies for that.
>
No need to apologize :)
> set password_encryption to 'md5';
> create user u4 password 'md5u1';
> ...
>
> 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.)
>
>
> This is correct - it can be both. Not only are we sending a password in
> clear text, but we then encrypt it using MD5. Hence, two warnings.
>
> If I use a real md5 password, it only complains about MD5 encrypted
> password:
>
>
> Right. If someone sends us something that looks like an already-
> encrypted password, we just store it. See get_password_type() in
> backend/libpq/crypt.c. In which case, the actual password that a client
> would type in would *not* be what was sent over the wire as part of the
> ALTER USER / CREATE USER, so we don't complain.
Sounds good to me.
--
Guillaume Lelarge
Consultant
https://dalibo.com
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
@ 2025-02-24 10:07 ` Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
1 sibling, 1 reply; 33+ messages in thread
From: Aleksander Alekseev @ 2025-02-24 10:07 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: pgsql-hackers
Hi,
> 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.
If the problem is that the password might be logged, wouldn't a proper
solution be not to log such queries?
I don't see how a warning and an extra GUC will improve the overall
security of the system, and I suspect very few users will voluntarily
trade convenience to security by choosing "disallow". So in its
current state the patch doesn't seem to help much.
--
Best regards,
Aleksander Alekseev
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
@ 2025-02-24 14:26 ` Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 33+ messages in thread
From: Greg Sabino Mullane @ 2025-02-24 14:26 UTC (permalink / raw)
To: Aleksander Alekseev <aleksander@timescale.com>; +Cc: pgsql-hackers
On Mon, Feb 24, 2025 at 5:07 AM Aleksander Alekseev <
aleksander@timescale.com> wrote:
> If the problem is that the password might be logged, wouldn't a proper
> solution be not to log such queries?
>
Yes, this has been discussed before. The short answer is that it is
extremely difficult to implement reliably because we would need to add some
artificial intelligence to our parser and/or logger to prevent passwords
from being added via syntax errors. Even preventing certain valid commands
from being logged is fraught with edge cases and difficult tradeoffs. As
mentioned, it's also not just direct logging, it's things like
pg_stat_activity and pg_stat_statements.
The real solution is to train people and applications not to send clear
text passwords. If the command fails to work, that's a pretty good way to
train them.
> I don't see how a warning and an extra GUC will improve the overall
> security of the system, and I suspect very few users will voluntarily
> trade convenience to security by choosing "disallow". So in its current
> state the patch doesn't seem to help much.
>
One of the main goals is to start leading people away from using insecure
methods. Like with MD5, first we warn, then we disable usage (but allow a
way to enable for stubborn users/applications). So I would say the goals
are:
* Provide a warning, so people are aware that sending passwords in the
clear is a bad idea. Right now, there is no warning. Quite the improvement.
* Provide a way to disable using clear text passwords. Also a win for
people like the OP in another thread that wants to prevent password changes
from ending up in the logs. Now they can (and may help with PCI compliance
and related things).
* Provide notice to applications/drivers/frameworks that clear text
passwords are deprecated and they should provide (or recommend) an
alternate method.
* Lay the groundwork for eventually disallowing plain text passwords
completely. A long way off, but this is the start. After a couple years, we
could switch the default from "warn" to "disallow". A few years after that,
disallow completely.
I know it is not a perfect solution, and likely never will be, but we can't
let the perfect be the enemy of the good. This seems a good, small
incremental step. The three-value solution also allows for complete
backwards compatibility, while still allowing admins to throw a warning or
error if desired.
Cheers,
Greg
--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
@ 2025-02-24 20:47 ` Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
0 siblings, 1 reply; 33+ messages in thread
From: Nathan Bossart @ 2025-02-24 20:47 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Mon, Feb 24, 2025 at 09:26:07AM -0500, Greg Sabino Mullane wrote:
> * Lay the groundwork for eventually disallowing plain text passwords
> completely. A long way off, but this is the start. After a couple years, we
> could switch the default from "warn" to "disallow". A few years after that,
> disallow completely.
I wonder how folks feel about the idea of removing the ability to send
passwords to the server in clear text. There may be some scenarios where
clear text is probably fine, and most of passwordcheck's checks rely on
being able to see the clear text password, but we've long encouraged folks
to "pre-encrypt" passwords. I also think it's hard to argue that sending a
clear text password is much more convenient than createuser or \password
(not to mention the PQchangePassword() function in libpq). That being
said, this seems like it has the potential to break a lot of stuff, and we
probably ought to be cautious about that, too.
This is perhaps a nitpick, but one issue with ERROR-ing for clear text
passwords is that the default logging settings seem to send the statement
to the logs, too. So, it might actually increase the likelihood of the
password showing up in the logs. I'm not sure what else could be done, but
I believe the conventional wisdom is that logs can contain sensitive
information, so maybe it's okay... It still seems weird to me to try to
help folks to avoid logging passwords by logging their passwords.
--
nathan
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
@ 2025-02-24 21:06 ` Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 33+ messages in thread
From: Isaac Morland @ 2025-02-24 21:06 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Greg Sabino Mullane <htamfids@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Mon, 24 Feb 2025 at 15:47, Nathan Bossart <nathandbossart@gmail.com>
wrote:
This is perhaps a nitpick, but one issue with ERROR-ing for clear text
> passwords is that the default logging settings seem to send the statement
> to the logs, too. So, it might actually increase the likelihood of the
> password showing up in the logs. I'm not sure what else could be done, but
> I believe the conventional wisdom is that logs can contain sensitive
> information, so maybe it's okay... It still seems weird to me to try to
> help folks to avoid logging passwords by logging their passwords.
>
It is definitely ironic, but it’s non-routinely logging their proposed new
password which, due to the server settings, does not actually get set as
the new password, in order to prevent routinely logging their passwords.
What I mean is, after the error is thrown and the proposed password logged,
they need to re-try with a pre-encrypted password which will not be logged.
If they choose a new password, then the logged one is irrelevant, and even
if they don't, it's just one password rather than all the ones they change.
So on the whole I think this is good. And in any case I believe the
existing behaviour can still be had by configuration so we're not really
imposing anything on anybody.
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
@ 2025-02-24 21:18 ` Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
0 siblings, 1 reply; 33+ messages in thread
From: Nathan Bossart @ 2025-02-24 21:18 UTC (permalink / raw)
To: Isaac Morland <isaac.morland@gmail.com>; +Cc: Greg Sabino Mullane <htamfids@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Mon, Feb 24, 2025 at 04:06:41PM -0500, Isaac Morland wrote:
> And in any case I believe the existing behaviour can still be had by
> configuration so we're not really imposing anything on anybody.
Well, the discussion upthread suggests "disallowing plain text passwords
completely" [0], which means at some point we would have to impose
something, right? Again, maybe this in itself is not a deal-breaker.
After all, we'll probably have a similar problem when we eventually remove
MD5 password support down the road.
[0] https://postgr.es/m/CAKAnmmKGWxEGbvuBAxyDWmuije8agUHTY-82DR1VEkFM2vKNTg%40mail.gmail.com
--
nathan
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
@ 2025-02-24 21:20 ` Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 33+ messages in thread
From: Greg Sabino Mullane @ 2025-02-24 21:20 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Mon, Feb 24, 2025 at 4:18 PM Nathan Bossart <nathandbossart@gmail.com>
wrote:
> Well, the discussion upthread suggests "disallowing plain text passwords
> completely"
Yeah, that's more of a long-term dream than a real plan. It would certainly
be no sooner than Postgres v24 or so...
Cheers,
Greg
--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
@ 2025-02-25 15:34 ` Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
0 siblings, 1 reply; 33+ messages in thread
From: Nathan Bossart @ 2025-02-25 15:34 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Mon, Feb 24, 2025 at 04:20:44PM -0500, Greg Sabino Mullane wrote:
> On Mon, Feb 24, 2025 at 4:18 PM Nathan Bossart <nathandbossart@gmail.com>
> wrote:
>> Well, the discussion upthread suggests "disallowing plain text passwords
>> completely"
>
> Yeah, that's more of a long-term dream than a real plan. It would certainly
> be no sooner than Postgres v24 or so...
I noticed a nearby thread [0] in which there appears to be some budding
support for a GUC that disables sending passwords to the server in
clear-text, at least for CREATE/ALTER ROLE. Perhaps we just add that for
now. (I'm probably well over my quota for new GUCs in v18...)
IMHO a WARNING would really only be appropriate if we are definitely going
to remove support in the future, and that feels like a bit of a stretch to
me due to the level of breakage it could cause. That being said, folks did
seem on board enough with deprecating MD5 passwords for me to feel
comfortable committing it, although that might not quite be an
apples-to-apples comparison. In any case, we've long encouraged folks to
avoid sending passwords to the server in clear-text, so I think it's
reasonable to provide some way to enforce that server-side.
[0] https://postgr.es/m/3136308.1740155121%40sss.pgh.pa.us
--
nathan
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
@ 2025-02-25 16:13 ` Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 33+ messages in thread
From: Greg Sabino Mullane @ 2025-02-25 16:13 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Tue, Feb 25, 2025 at 10:34 AM Nathan Bossart <nathandbossart@gmail.com>
wrote:
> I noticed a nearby thread [0] in which there appears to be some budding
> support for a GUC that disables sending passwords to the server in
> clear-text, at least for CREATE/ALTER ROLE.
Yep, that was the thread that inspired this patch!
Perhaps we just add that for now. (I'm probably well over my quota for new
> GUCs in v18...)
>
Heh.
> IMHO a WARNING would really only be appropriate if we are definitely going
> to remove support in the future, and that feels like a bit of a stretch to
> me due to the level of breakage it could cause. That being said, folks did
> seem on board enough with deprecating MD5 passwords for me to feel
> comfortable committing it, although that might not quite be an
> apples-to-apples comparison. In any case, we've long encouraged folks to
> avoid sending passwords to the server in clear-text, so I think it's
> reasonable to provide some way to enforce that server-side.
>
Yes, I went back and forth on the wording for the warning, but ended up
with a slightly weasely "may be removed" rather than "will be removed". Of
course, no date is explicitly promised, so "will be removed" could be an
accurate. It might just be 75 years from now, when our neural implants make
plain text passwords a quaint relic.
This has a commitfest entry now fwiw:
https://commitfest.postgresql.org/patch/5597/
Thank you for your input on this.
Cheers,
Greg
--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
@ 2025-03-03 16:33 ` Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 17:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
0 siblings, 2 replies; 33+ messages in thread
From: Nathan Bossart @ 2025-03-03 16:33 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Tue, Feb 25, 2025 at 11:13:51AM -0500, Greg Sabino Mullane wrote:
> On Tue, Feb 25, 2025 at 10:34 AM Nathan Bossart <nathandbossart@gmail.com>
> wrote:
>> IMHO a WARNING would really only be appropriate if we are definitely going
>> to remove support in the future, and that feels like a bit of a stretch to
>> me due to the level of breakage it could cause. That being said, folks did
>> seem on board enough with deprecating MD5 passwords for me to feel
>> comfortable committing it, although that might not quite be an
>> apples-to-apples comparison. In any case, we've long encouraged folks to
>> avoid sending passwords to the server in clear-text, so I think it's
>> reasonable to provide some way to enforce that server-side.
>
> Yes, I went back and forth on the wording for the warning, but ended up
> with a slightly weasely "may be removed" rather than "will be removed". Of
> course, no date is explicitly promised, so "will be removed" could be an
> accurate. It might just be 75 years from now, when our neural implants make
> plain text passwords a quaint relic.
I think it would be good to hear some other opinions on whether we should
consider sending clear-text passwords to the server as either 1) fully
supported, 2) deprecated but with no intent to remove anytime soon, or 3)
deprecated with the intent of removal at some point in the next several
years. I personally am -1 on the warning unless we have a consensus on
(3), but I'm +1 on adding a way to enforce "pre-encryption" regardless.
--
nathan
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
@ 2025-03-03 17:06 ` Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 17:11 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
1 sibling, 1 reply; 33+ messages in thread
From: Greg Sabino Mullane @ 2025-03-03 17:06 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Mon, Mar 3, 2025 at 11:33 AM Nathan Bossart <nathandbossart@gmail.com>
wrote:
> I think it would be good to hear some other opinions on whether we should
> consider sending clear-text passwords to the server as either 1) fully
> supported, 2) deprecated but with no intent to remove anytime soon, or 3)
> deprecated with the intent of removal at some point in the next several
> years. I personally am -1 on the warning unless we have a consensus on
> (3), but I'm +1 on adding a way to enforce "pre-encryption" regardless.
>
That's more than fair. And "deprecation" doesn't need to mean that's the
next step in the process. So warn -> deny by default (but allow if you work
at it) -> remove completely. Which is very similar to our md5 path, I
suppose. I'm certainly happy staying at that middle stage for an indefinite
amount of time for both of those, as it means that Postgres is both "secure
by default" but backwards compatible.
--
Cheers,
Greg
--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 17:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
@ 2025-03-03 17:11 ` Isaac Morland <isaac.morland@gmail.com>
0 siblings, 0 replies; 33+ messages in thread
From: Isaac Morland @ 2025-03-03 17:11 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Mon, 3 Mar 2025 at 12:07, Greg Sabino Mullane <htamfids@gmail.com> wrote:
> On Mon, Mar 3, 2025 at 11:33 AM Nathan Bossart <nathandbossart@gmail.com>
> wrote:
>
>> I think it would be good to hear some other opinions on whether we should
>> consider sending clear-text passwords to the server as either 1) fully
>> supported, 2) deprecated but with no intent to remove anytime soon, or 3)
>> deprecated with the intent of removal at some point in the next several
>> years. I personally am -1 on the warning unless we have a consensus on
>> (3), but I'm +1 on adding a way to enforce "pre-encryption" regardless.
>>
>
> That's more than fair. And "deprecation" doesn't need to mean that's the
> next step in the process. So warn -> deny by default (but allow if you work
> at it) -> remove completely. Which is very similar to our md5 path, I
> suppose. I'm certainly happy staying at that middle stage for an indefinite
> amount of time for both of those, as it means that Postgres is both "secure
> by default" but backwards compatible.
>
It's too bad we didn't have this discussion a few years ago. We could have
decided that SCRAM authentication doesn't allow sending cleartext passwords
and then relied on the phase-out of MD5 passwords to phase out sending of
cleartext passwords.
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
@ 2025-03-03 18:10 ` Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 33+ messages in thread
From: Robert Haas @ 2025-03-03 18:10 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Greg Sabino Mullane <htamfids@gmail.com>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Mon, Mar 3, 2025 at 11:33 AM Nathan Bossart <nathandbossart@gmail.com> wrote:
> I think it would be good to hear some other opinions on whether we should
> consider sending clear-text passwords to the server as either 1) fully
> supported, 2) deprecated but with no intent to remove anytime soon, or 3)
> deprecated with the intent of removal at some point in the next several
> years. I personally am -1 on the warning unless we have a consensus on
> (3), but I'm +1 on adding a way to enforce "pre-encryption" regardless.
I wonder if we could drum up some support for not including any
version of the password (even encrypted) in the query string. For
instance, let's say that to change your password you have to use the
new CHANGE PASSWORD command which can only be used at top level (not
inside PL code or whatever) and always takes a single parameter that
must be supplied via the extended query protocol. I suppose there's
still a potential security exposure if people are logging parameters,
but maybe it's easier to avoid logging those parameters when the
command is CHANGE PASSWORD than it is to avoid logging a query string
with sensitive information in it.
If we introduced such a mechanism, perhaps we could eventually
deprecate ALTER USER as a method of changing passwords, or at least
have the option to disallow it. Or maybe we just want to add the
option to disallow it now, as proposed here -- but I'm not totally
convinced that will meaningfully improve security if the command still
exists and might still work on some systems.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
@ 2025-03-03 18:47 ` Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 33+ messages in thread
From: Tom Lane @ 2025-03-03 18:47 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; Greg Sabino Mullane <htamfids@gmail.com>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> I wonder if we could drum up some support for not including any
> version of the password (even encrypted) in the query string. For
> instance, let's say that to change your password you have to use the
> new CHANGE PASSWORD command which can only be used at top level (not
> inside PL code or whatever) and always takes a single parameter that
> must be supplied via the extended query protocol.
How would pg_dumpall cope with transferring passwords then?
I could see insisting that plain-text passwords be supplied only
that way. But removing the ability to have encrypted passwords
in-line seems like a serious operational problem with little benefit.
regards, tom lane
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
@ 2025-03-03 18:54 ` Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
0 siblings, 1 reply; 33+ messages in thread
From: Robert Haas @ 2025-03-03 18:54 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; Greg Sabino Mullane <htamfids@gmail.com>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Mon, Mar 3, 2025 at 1:47 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
> > I wonder if we could drum up some support for not including any
> > version of the password (even encrypted) in the query string. For
> > instance, let's say that to change your password you have to use the
> > new CHANGE PASSWORD command which can only be used at top level (not
> > inside PL code or whatever) and always takes a single parameter that
> > must be supplied via the extended query protocol.
>
> How would pg_dumpall cope with transferring passwords then?
>
> I could see insisting that plain-text passwords be supplied only
> that way. But removing the ability to have encrypted passwords
> in-line seems like a serious operational problem with little benefit.
Oh, good point. I don't know. I just have heard a LOT of complaining
about passwords showing up in the log, and I'm not sure insisting that
they have to all be encrypted is going to make all of the complaining
stop.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
@ 2025-03-14 15:21 ` Nathan Bossart <nathandbossart@gmail.com>
2025-03-14 18:49 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
0 siblings, 1 reply; 33+ messages in thread
From: Nathan Bossart @ 2025-03-14 15:21 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Greg Sabino Mullane <htamfids@gmail.com>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Mon, Mar 03, 2025 at 01:54:59PM -0500, Robert Haas wrote:
> Oh, good point. I don't know. I just have heard a LOT of complaining
> about passwords showing up in the log, and I'm not sure insisting that
> they have to all be encrypted is going to make all of the complaining
> stop.
+1. At this point, IMHO we should consider this v19 material to provide
more time for discussion on the best way to tackle this problem. Blocking
plain-text passwords in CREATE/ALTER ROLE commands may be part of it, but
as Robert notes, we might need to do more.
--
nathan
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
@ 2025-03-14 18:49 ` Greg Sabino Mullane <htamfids@gmail.com>
2025-03-16 15:04 ` Re: PATCH: warn about, and deprecate, clear text passwords Roberto Mello <roberto.mello@gmail.com>
2025-03-17 03:12 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
0 siblings, 2 replies; 33+ messages in thread
From: Greg Sabino Mullane @ 2025-03-14 18:49 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
I'd rather not sit on this another year, if we can help it. We really
should be warning people about this practice. The exact wording of the hint
can be up for debate (or postponed - we technically don't have to say
anything other than 'bad idea').
Having the ability to disable clear text passwords seems an immediate win
for those that want to enable it. Sure, we could be doing more, but I don't
see any of the proposed future changes interfering with this patch.
Cheers,
Greg
--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-14 18:49 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
@ 2025-03-16 15:04 ` Roberto Mello <roberto.mello@gmail.com>
1 sibling, 0 replies; 33+ messages in thread
From: Roberto Mello @ 2025-03-16 15:04 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; Robert Haas <robertmhaas@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Fri, Mar 14, 2025 at 12:50 PM Greg Sabino Mullane <htamfids@gmail.com>
wrote:
> I'd rather not sit on this another year, if we can help it. We really
> should be warning people about this practice. The exact wording of the hint
> can be up for debate (or postponed - we technically don't have to say
> anything other than 'bad idea').
>
> Having the ability to disable clear text passwords seems an immediate win
> for those that want to enable it. Sure, we could be doing more, but I don't
> see any of the proposed future changes interfering with this patch.
>
I agree. This is a clear win that can easily be turned on by
packagers/distributors with little consequence to everyone else.
My only suggestion would be to have the GUC name be closer to other
password-related settings. Looking at the sample file I see
password_encryption
md5_password_warnings
So perhaps something like password_cleartext_action would fit in a little
better and make it easier to spot while going through the file.
Roberto
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-14 18:49 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
@ 2025-03-17 03:12 ` Robert Haas <robertmhaas@gmail.com>
2025-03-17 03:36 ` PATCH: warn about, and deprecate, clear text passwords David G. Johnston <david.g.johnston@gmail.com>
1 sibling, 1 reply; 33+ messages in thread
From: Robert Haas @ 2025-03-17 03:12 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Fri, Mar 14, 2025 at 2:50 PM Greg Sabino Mullane <htamfids@gmail.com> wrote:
> I'd rather not sit on this another year, if we can help it. We really should be warning people about this practice. The exact wording of the hint can be up for debate (or postponed - we technically don't have to say anything other than 'bad idea').
>
> Having the ability to disable clear text passwords seems an immediate win for those that want to enable it. Sure, we could be doing more, but I don't see any of the proposed future changes interfering with this patch.
I don't know, I think Nathan's idea of giving ourselves more time to
decide what to do is a pretty good one. It seems clear from the
discussion so far that there are multiple ideas about what to do here,
and it's not stupid to want to give ourselves a bit of time to think
that through before committing to anything in particular. From my
point of view, the warning text here for what is proposed here almost
might almost be:
WARNING: you just caused a problem for somebody else
The user has no particular reason to care about the fact that the
password they just typed ended up in the log. That is a concern for
the DBA, not the user, and even if they care about the DBA's feelings,
they only get the warning after it's too late to do otherwise.
Blocking ALTER USER commands containing such passwords is better,
because now doing the wrong thing actually doesn't work at all, and so
they have to change their behavior if they want to get anything done.
But we don't seem to be too sure whether we can really get away with
that amount of breakage; and we also don't seem to be sure whether it
really solves the problem; and we're getting very close to feature
freeze.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 33+ messages in thread
* PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-14 18:49 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-17 03:12 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
@ 2025-03-17 03:36 ` David G. Johnston <david.g.johnston@gmail.com>
2025-03-17 13:19 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 33+ messages in thread
From: David G. Johnston @ 2025-03-17 03:36 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Greg Sabino Mullane <htamfids@gmail.com>; Nathan Bossart <nathandbossart@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Sunday, March 16, 2025, Robert Haas <robertmhaas@gmail.com> wrote:
>
>
> WARNING: you just caused a problem for somebody else
>
> The user has no particular reason to care about the fact that the
> password they just typed ended up in the log.
>
It could also be:
warning: your password is known to Big Brother
hint: use psql \password to supply a private password, or see “docs/wiki
page” for more details and a way to pre-compute and send a private password
via SQL.
Sure, we can’t make them drink, but let’s at least show them where we put
the water trough. Some of them will care but be unaware.
We can make it an error later and do nothing, removing the choice but to
figure out the proper way of changing their password.
David J.
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-14 18:49 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-17 03:12 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-17 03:36 ` PATCH: warn about, and deprecate, clear text passwords David G. Johnston <david.g.johnston@gmail.com>
@ 2025-03-17 13:19 ` Robert Haas <robertmhaas@gmail.com>
2025-03-19 13:24 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
0 siblings, 1 reply; 33+ messages in thread
From: Robert Haas @ 2025-03-17 13:19 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Greg Sabino Mullane <htamfids@gmail.com>; Nathan Bossart <nathandbossart@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Sun, Mar 16, 2025 at 11:36 PM David G. Johnston
<david.g.johnston@gmail.com> wrote:
> It could also be:
>
> warning: your password is known to Big Brother
> hint: use psql \password to supply a private password, or see “docs/wiki page” for more details and a way to pre-compute and send a private password via SQL.
OK, that's actually a fair point. It's still true, though, that all
the complaints that I hear about this are of the form "someone MIGHT
do something that puts their password in a log file" and a warning
doesn't stop that.
Granted, other people may hear different complaints than I do.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-14 18:49 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-17 03:12 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-17 03:36 ` PATCH: warn about, and deprecate, clear text passwords David G. Johnston <david.g.johnston@gmail.com>
2025-03-17 13:19 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
@ 2025-03-19 13:24 ` Greg Sabino Mullane <htamfids@gmail.com>
2025-03-19 13:53 ` Re: PATCH: warn about, and deprecate, clear text passwords Bruce Momjian <bruce@momjian.us>
2025-03-19 14:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
0 siblings, 2 replies; 33+ messages in thread
From: Greg Sabino Mullane @ 2025-03-19 13:24 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; Nathan Bossart <nathandbossart@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
>
> The user has no particular reason to care about the fact that the password
> they just typed ended up in the log. That is a concern for
> the DBA, not the user, and even if they care about the DBA's feelings,
> they only get the warning after it's too late to do otherwise.
Can't the same be said about other warnings, esp. md5?
Attached is a rebase of the patch.
I'm a little confused at some of the pushback - this patch is 100%
backwards compatible, addresses a specific requested concern by allowing a
DBA to disallow clear text passwords, and adds a warning to what is clearly
a bad practice that we should be discouraging.
Robert - would you be more inclined to accept this if we kept the three
states, but made the default "allow"? That would still allow people to bump
it stronger manually, but would have no effect on everyone else. That would
give us time to tweak the wording and/or examine other approaches. Although
any other approaches would still leave the need to do something with
passwords via ALTER USER / CREATE USER in the interim.
Cheers,
Greg
--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support
Attachments:
0002-Add-new-server-config-cleartext_passwords_action.patch (application/octet-stream, 17.6K) download
From 555f193926fc09567a4efe3729159569498a5992 Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane <greg@turnstep.com>
Date: Wed, 19 Mar 2025 09:10:18 -0400
Subject: [PATCH] Add new server config cleartext_passwords_action
This controls what happens when someone sends a clear text password
to the server via CREATE USER or ALTER USER. Three states are allowed:
1. "warn" The current default, this issues a warning if a clear
text password is used, but allows the change to proceed. The hint
changes to recommend \password if the current application_name is 'psql'
2. "allow" This does nothing, and thus emulates the historical behavior.
3. "disallow". This prevents the use of plain text completely, by throwing
an error if a password set or change is attempted.
---
.../passwordcheck/expected/passwordcheck.out | 6 ++++
doc/src/sgml/config.sgml | 18 ++++++++++
src/backend/libpq/crypt.c | 34 +++++++++++++++++++
src/backend/utils/misc/guc_tables.c | 17 ++++++++++
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/libpq/crypt.h | 19 +++++++++++
.../ecpg/test/expected/connect-test5.stderr | 16 ++++++---
src/test/regress/expected/create_role.out | 3 ++
src/test/regress/expected/password.out | 33 ++++++++++++++++++
9 files changed, 143 insertions(+), 4 deletions(-)
diff --git a/contrib/passwordcheck/expected/passwordcheck.out b/contrib/passwordcheck/expected/passwordcheck.out
index 83472c76d27..602e91c50ac 100644
--- a/contrib/passwordcheck/expected/passwordcheck.out
+++ b/contrib/passwordcheck/expected/passwordcheck.out
@@ -3,6 +3,9 @@ LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
ALTER USER regress_passwordcheck_user1 PASSWORD 'a_nice_long_password';
+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
-- error: too short
ALTER USER regress_passwordcheck_user1 PASSWORD 'tooshrt';
ERROR: password is too short
@@ -10,6 +13,9 @@ DETAIL: password must be at least "passwordcheck.min_password_length" (8) bytes
-- ok
SET passwordcheck.min_password_length = 6;
ALTER USER regress_passwordcheck_user1 PASSWORD 'v_shrt';
+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
-- error: contains user name
ALTER USER regress_passwordcheck_user1 PASSWORD 'xyzregress_passwordcheck_user1';
ERROR: password must not contain user name
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 873290daa61..87a63e80dab 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1104,6 +1104,24 @@ include_dir 'conf.d'
</listitem>
</varlistentry>
+ <varlistentry id="guc-cleartext-passwords-action" xreflabel="cleartext_passwords_action">
+ <term><varname>cleartext_passwords_action</varname> (<type>enum</type>)
+ <indexterm>
+ <primary><varname>cleartext_passwords_action</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Controls what action to take when a password is sent unencrypted
+ (i.e. in clear text) to the server via the <command>CREATE ROLE</command>
+ or <command>ALTER ROLE</command> command. Valid options are
+ <literal>allow</literal>, <literal>warn</literal>, or
+ <literal>disallow</literal>.
+ The default value is <literal>warn</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="guc-password-encryption" xreflabel="password_encryption">
<term><varname>password_encryption</varname> (<type>enum</type>)
<indexterm>
diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c
index cbb85a27cc1..b093aa9fef7 100644
--- a/src/backend/libpq/crypt.c
+++ b/src/backend/libpq/crypt.c
@@ -21,12 +21,16 @@
#include "libpq/crypt.h"
#include "libpq/scram.h"
#include "utils/builtins.h"
+#include "utils/guc.h"
#include "utils/syscache.h"
#include "utils/timestamp.h"
/* Enables deprecation warnings for MD5 passwords. */
bool md5_password_warnings = true;
+/* Action to take when clear text passwords are used. */
+int cleartext_passwords_action = CLEARTEXT_ACTION_WARN;
+
/*
* Fetch stored password for a user, for authentication.
*
@@ -131,6 +135,36 @@ encrypt_password(PasswordType target_type, const char *role,
}
else
{
+
+ /*
+ * We are sending clear text passwords to the server. What should we
+ * do about that?
+ */
+ if (cleartext_passwords_action == CLEARTEXT_ACTION_WARN)
+ {
+ ereport(WARNING,
+ (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
+ errmsg("using a clear text password"),
+ errdetail("Sending a password using plain text is deprecated and may be removed in a future release of PostgreSQL."),
+ strncmp(application_name, "psql", 5) == 0
+ ? errhint("If using psql, you can set the password with \\password")
+ : errhint("Use a client that can change the password without sending it in clear text")));
+ }
+ else if (cleartext_passwords_action == CLEARTEXT_ACTION_DISALLOW)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PASSWORD),
+ errmsg("using a clear text password"),
+ errdetail("Sending a password using plain text is not allowed."),
+ strncmp(application_name, "psql", 5) == 0
+ ? errhint("If using psql, you can change the password with \\password")
+ : errhint("Use a client that can change the password without sending it in clear text")));
+ }
+ else
+ {
+ /* Silently accept this bad practice. */
+ }
+
switch (target_type)
{
case PASSWORD_TYPE_MD5:
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index cc8f2b1230a..3909473f2c8 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -413,6 +413,13 @@ static const struct config_enum_entry password_encryption_options[] = {
{NULL, 0, false}
};
+static const struct config_enum_entry cleartext_action_options[] = {
+ {"allow", CLEARTEXT_ACTION_ALLOW, false},
+ {"warn", CLEARTEXT_ACTION_WARN, false},
+ {"disallow", CLEARTEXT_ACTION_DISALLOW, false},
+ {NULL, 0, false}
+};
+
static const struct config_enum_entry ssl_protocol_versions_info[] = {
{"", PG_TLS_ANY, false},
{"TLSv1", PG_TLS1_VERSION, false},
@@ -5384,6 +5391,16 @@ struct config_enum ConfigureNamesEnum[] =
NULL, assign_io_method, NULL
},
+ {
+ {"cleartext_passwords_action", PGC_SIGHUP, CONN_AUTH_AUTH,
+ gettext_noop("Action to take when clear text passwords are used."),
+ },
+ &cleartext_passwords_action,
+ CLEARTEXT_ACTION_WARN, cleartext_action_options,
+ NULL, NULL, NULL
+ },
+
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, 0, NULL, NULL, NULL, NULL
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index ad54585cf1d..636f97131c9 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -97,6 +97,7 @@
#password_encryption = scram-sha-256 # scram-sha-256 or md5
#scram_iterations = 4096
#md5_password_warnings = on
+#cleartext_passwords_action = warn # can be allow, warn, or disallow
# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
diff --git a/src/include/libpq/crypt.h b/src/include/libpq/crypt.h
index dee477428e4..d5d0d8af26e 100644
--- a/src/include/libpq/crypt.h
+++ b/src/include/libpq/crypt.h
@@ -28,6 +28,9 @@
/* Enables deprecation warnings for MD5 passwords. */
extern PGDLLIMPORT bool md5_password_warnings;
+/* Specifies action when clear text passwords are used. */
+extern PGDLLIMPORT int cleartext_passwords_action;
+
/*
* Types of password hashes or secrets.
*
@@ -44,6 +47,22 @@ typedef enum PasswordType
PASSWORD_TYPE_SCRAM_SHA_256,
} PasswordType;
+/*
+ * Actions to take when clear text passwords are used.
+ *
+ * Passwords that are sent in clear text via the CREATE/ALTER USER
+ * command can cause a reaction by the server. We can either allow
+ * (the old behavior), warn (throw a warning and hint), or simply
+ * disallow (throws an exception).
+ */
+typedef enum CleartextAction
+{
+ CLEARTEXT_ACTION_ALLOW = 0,
+ CLEARTEXT_ACTION_WARN,
+ CLEARTEXT_ACTION_DISALLOW,
+} CleartextAction;
+
+
extern PasswordType get_password_type(const char *shadow_pass);
extern char *encrypt_password(PasswordType target_type, const char *role,
const char *password);
diff --git a/src/interfaces/ecpg/test/expected/connect-test5.stderr b/src/interfaces/ecpg/test/expected/connect-test5.stderr
index 037db217586..d74cc1f1e81 100644
--- a/src/interfaces/ecpg/test/expected/connect-test5.stderr
+++ b/src/interfaces/ecpg/test/expected/connect-test5.stderr
@@ -4,16 +4,24 @@
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 24: query: alter user regress_ecpg_user2 encrypted password 'insecure'; with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 24: using PQexec
+[NO_PID]: ECPGnoticeReceiver: using a clear text password
[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 0
+[NO_PID]: sqlca: code: 0, state: 01P01
+[NO_PID]: ecpg_execute on line 24: using PQexec
+[NO_PID]: sqlca: code: 0, state: 01P01
[NO_PID]: ecpg_process_output on line 24: OK: ALTER ROLE
-[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: sqlca: code: 0, state: 01P01
[NO_PID]: ecpg_execute on line 25: query: alter user regress_ecpg_user1 encrypted password 'connectpw'; with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 25: using PQexec
+[NO_PID]: ECPGnoticeReceiver: using a clear text password
[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 0
+[NO_PID]: sqlca: code: 0, state: 01P01
+[NO_PID]: ecpg_execute on line 25: using PQexec
+[NO_PID]: sqlca: code: 0, state: 01P01
[NO_PID]: ecpg_process_output on line 25: OK: ALTER ROLE
-[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: sqlca: code: 0, state: 01P01
[NO_PID]: ECPGtrans on line 26: action "commit"; connection "main"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection main closed
diff --git a/src/test/regress/expected/create_role.out b/src/test/regress/expected/create_role.out
index 46d4f9efe99..8347205e4aa 100644
--- a/src/test/regress/expected/create_role.out
+++ b/src/test/regress/expected/create_role.out
@@ -64,6 +64,9 @@ CREATE ROLE regress_login LOGIN;
CREATE ROLE regress_inherit INHERIT;
CREATE ROLE regress_connection_limit CONNECTION LIMIT 5;
CREATE ROLE regress_encrypted_password ENCRYPTED PASSWORD 'foo';
+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
CREATE ROLE regress_password_null PASSWORD NULL;
-- ok, backwards compatible noise words should be ignored
CREATE ROLE regress_noiseword SYSID 12345;
diff --git a/src/test/regress/expected/password.out b/src/test/regress/expected/password.out
index 9bb3ab2818b..ec76afcbcef 100644
--- a/src/test/regress/expected/password.out
+++ b/src/test/regress/expected/password.out
@@ -14,16 +14,25 @@ SET password_encryption = 'scram-sha-256'; -- ok
SET password_encryption = 'md5';
CREATE ROLE regress_passwd1;
ALTER ROLE regress_passwd1 PASSWORD 'role_pwd1';
+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
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 regress_passwd2;
ALTER ROLE regress_passwd2 PASSWORD 'role_pwd2';
+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
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.
SET password_encryption = 'scram-sha-256';
CREATE ROLE regress_passwd3 PASSWORD 'role_pwd3';
+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
CREATE ROLE regress_passwd4 PASSWORD NULL;
-- check list of created entries
--
@@ -63,6 +72,9 @@ ALTER ROLE regress_passwd2_new RENAME TO regress_passwd2;
SET password_encryption = 'md5';
-- encrypt with MD5
ALTER ROLE regress_passwd2 PASSWORD 'foo';
+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
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.
@@ -75,6 +87,9 @@ ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
+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
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
WARNING: setting an MD5-encrypted password
@@ -83,15 +98,27 @@ HINT: Refer to the PostgreSQL documentation for details about migrating to anot
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
+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
-- These may look like valid MD5 secrets, but they are not, so they
-- should be hashed with SCRAM-SHA-256.
-- trailing garbage at the end
CREATE ROLE regress_passwd7 PASSWORD 'md5012345678901234567890123456789zz';
+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
-- invalid length
CREATE ROLE regress_passwd8 PASSWORD 'md501234567890123456789012345678901zz';
+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
-- Changing the SCRAM iteration count
SET scram_iterations = 1024;
CREATE ROLE regress_passwd9 PASSWORD 'alterediterationcount';
+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
SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+/=]+)\$([a-zA-Z0-9+=/]+):([a-zA-Z0-9+/=]+)', '\1$\2:<salt>$<storedkey>:<serverkey>') as rolpassword_masked
FROM pg_authid
WHERE rolname LIKE 'regress_passwd%'
@@ -128,7 +155,13 @@ SELECT rolpassword FROM pg_authid WHERE rolname='regress_passwd_empty';
-- stored/server keys. They will be re-hashed.
CREATE ROLE regress_passwd_sha_len0 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96Rqw=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZI=';
CREATE ROLE regress_passwd_sha_len1 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96RqwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZI=';
+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
CREATE ROLE regress_passwd_sha_len2 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96Rqw=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=';
+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
-- Check that the invalid secrets were re-hashed. A re-hashed secret
-- should not contain the original salt.
SELECT rolname, rolpassword not like '%A6xHKoH/494E941doaPOYg==%' as is_rolpassword_rehashed
--
2.30.2
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-14 18:49 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-17 03:12 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-17 03:36 ` PATCH: warn about, and deprecate, clear text passwords David G. Johnston <david.g.johnston@gmail.com>
2025-03-17 13:19 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-19 13:24 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
@ 2025-03-19 13:53 ` Bruce Momjian <bruce@momjian.us>
1 sibling, 0 replies; 33+ messages in thread
From: Bruce Momjian @ 2025-03-19 13:53 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; David G. Johnston <david.g.johnston@gmail.com>; Nathan Bossart <nathandbossart@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Wed, Mar 19, 2025 at 09:24:19AM -0400, Greg Sabino Mullane wrote:
> I'm a little confused at some of the pushback - this patch is 100% backwards
> compatible, addresses a specific requested concern by allowing a DBA to
> disallow clear text passwords, and adds a warning to what is clearly a bad
> practice that we should be discouraging.
>
> Robert - would you be more inclined to accept this if we kept the three states,
> but made the default "allow"? That would still allow people to bump it stronger
> manually, but would have no effect on everyone else. That would give us time to
> tweak the wording and/or examine other approaches. Although any other
> approaches would still leave the need to do something with passwords via ALTER
> USER / CREATE USER in the interim.
You are getting pushback because this complex user change is still being
debated in mid-March, when the feature freeze is only a few weeks away.
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com
Do not let urgent matters crowd out time for investment in the future.
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-14 18:49 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-17 03:12 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-17 03:36 ` PATCH: warn about, and deprecate, clear text passwords David G. Johnston <david.g.johnston@gmail.com>
2025-03-17 13:19 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-19 13:24 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
@ 2025-03-19 14:06 ` Robert Haas <robertmhaas@gmail.com>
2025-03-19 15:01 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
1 sibling, 1 reply; 33+ messages in thread
From: Robert Haas @ 2025-03-19 14:06 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; Nathan Bossart <nathandbossart@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Wed, Mar 19, 2025 at 9:24 AM Greg Sabino Mullane <htamfids@gmail.com> wrote:
>> The user has no particular reason to care about the fact that the password they just typed ended up in the log. That is a concern for
>> the DBA, not the user, and even if they care about the DBA's feelings, they only get the warning after it's too late to do otherwise.
>
> Can't the same be said about other warnings, esp. md5?
Absolutely. Warnings are sometimes the right thing, but they often
suck. If something is really a bad idea, "ERROR: bad idea" is vastly
superior to "WARNING: what you just already did was a bad idea". If we
don't actually know for sure that it's a bad idea, then it's generally
better not to emit a warning at all, for fear of log-spamming people
who know what they're doing.
> Robert - would you be more inclined to accept this if we kept the three states, but made the default "allow"? That would still allow people to bump it stronger manually, but would have no effect on everyone else. That would give us time to tweak the wording and/or examine other approaches. Although any other approaches would still leave the need to do something with passwords via ALTER USER / CREATE USER in the interim.
I mean, I do think that is probably a better idea, but I personally
have zero intention of committing this patch regardless. I have seen a
lot of problems in this area working at EDB and my educated guess is
that this solves 0% of them. Now, if enough other people show up to
say "but this would solve 100% of my problems," well then fair enough.
But I think it's entirely reasonable for me to look at the combination
of "this is a class of problem that affects me" and "this proposed
solution would not help me" and be skeptical. I think you'd feel the
same if the situation were reversed. If I came along and proposed some
solution to a PG problem and you agreed that the problem was a problem
but my proposed solution seemed useless, I assume you'd also -1 that
patch.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-14 18:49 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-17 03:12 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-17 03:36 ` PATCH: warn about, and deprecate, clear text passwords David G. Johnston <david.g.johnston@gmail.com>
2025-03-17 13:19 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-19 13:24 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-19 14:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
@ 2025-03-19 15:01 ` Nathan Bossart <nathandbossart@gmail.com>
2025-07-12 15:29 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2026-01-09 14:57 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
0 siblings, 2 replies; 33+ messages in thread
From: Nathan Bossart @ 2025-03-19 15:01 UTC (permalink / raw)
To: Robert Haas <robertmhaas@gmail.com>; +Cc: Greg Sabino Mullane <htamfids@gmail.com>; David G. Johnston <david.g.johnston@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Wed, Mar 19, 2025 at 10:06:58AM -0400, Robert Haas wrote:
> On Wed, Mar 19, 2025 at 9:24 AM Greg Sabino Mullane <htamfids@gmail.com> wrote:
>>> The user has no particular reason to care about the fact that the
>>> password they just typed ended up in the log. That is a concern for the
>>> DBA, not the user, and even if they care about the DBA's feelings, they
>>> only get the warning after it's too late to do otherwise.
>>
>> Can't the same be said about other warnings, esp. md5?
>
> Absolutely. Warnings are sometimes the right thing, but they often
> suck. If something is really a bad idea, "ERROR: bad idea" is vastly
> superior to "WARNING: what you just already did was a bad idea". If we
> don't actually know for sure that it's a bad idea, then it's generally
> better not to emit a warning at all, for fear of log-spamming people
> who know what they're doing.
FWIW I primarily intended the MD5 password warning to alert folks that the
ability to use MD5 passwords will go away at some point in the future. If
they want to continue to use MD5 passwords for now, they are free to do so.
They can even turn off the warnings. One of the main reasons I'm not
totally sold on a clear-text password warning is because we don't have
agreement on removing that ability anytime soon, not to mention Bruce's
point about the debate extending into mid-March.
--
nathan
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-14 18:49 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-17 03:12 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-17 03:36 ` PATCH: warn about, and deprecate, clear text passwords David G. Johnston <david.g.johnston@gmail.com>
2025-03-17 13:19 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-19 13:24 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-19 14:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-19 15:01 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
@ 2025-07-12 15:29 ` Greg Sabino Mullane <htamfids@gmail.com>
1 sibling, 0 replies; 33+ messages in thread
From: Greg Sabino Mullane @ 2025-07-12 15:29 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; David G. Johnston <david.g.johnston@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
Rebasing this for v19
Attachments:
0003-Add-new-server-config-cleartext_passwords_action.patch (application/octet-stream, 17.6K) download
From 8673b61f83c7847a806e50c3c5b1f7d631730bdb Mon Sep 17 00:00:00 2001
From: Greg Sabino Mullane <greg@turnstep.com>
Date: Sat, 12 Jul 2025 11:25:58 -0400
Subject: [PATCH] Add new server config cleartext_passwords_action
This controls what happens when someone sends a clear text password
to the server via CREATE USER or ALTER USER. Three states are allowed:
1. "warn" The current default, this issues a warning if a clear
text password is used, but allows the change to proceed. The hint
changes to recommend \password if the current application_name is 'psql'
2. "allow" This does nothing, and thus emulates the historical behavior.
3. "disallow". This prevents the use of plain text completely, by throwing
an error if a password set or change is attempted.
---
.../passwordcheck/expected/passwordcheck.out | 6 ++++
doc/src/sgml/config.sgml | 18 ++++++++++
src/backend/libpq/crypt.c | 34 +++++++++++++++++++
src/backend/utils/misc/guc_tables.c | 17 ++++++++++
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/libpq/crypt.h | 19 +++++++++++
.../ecpg/test/expected/connect-test5.stderr | 16 ++++++---
src/test/regress/expected/create_role.out | 3 ++
src/test/regress/expected/password.out | 33 ++++++++++++++++++
9 files changed, 143 insertions(+), 4 deletions(-)
diff --git a/contrib/passwordcheck/expected/passwordcheck.out b/contrib/passwordcheck/expected/passwordcheck.out
index 83472c76d27..602e91c50ac 100644
--- a/contrib/passwordcheck/expected/passwordcheck.out
+++ b/contrib/passwordcheck/expected/passwordcheck.out
@@ -3,6 +3,9 @@ LOAD 'passwordcheck';
CREATE USER regress_passwordcheck_user1;
-- ok
ALTER USER regress_passwordcheck_user1 PASSWORD 'a_nice_long_password';
+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
-- error: too short
ALTER USER regress_passwordcheck_user1 PASSWORD 'tooshrt';
ERROR: password is too short
@@ -10,6 +13,9 @@ DETAIL: password must be at least "passwordcheck.min_password_length" (8) bytes
-- ok
SET passwordcheck.min_password_length = 6;
ALTER USER regress_passwordcheck_user1 PASSWORD 'v_shrt';
+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
-- error: contains user name
ALTER USER regress_passwordcheck_user1 PASSWORD 'xyzregress_passwordcheck_user1';
ERROR: password must not contain user name
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index c7acc0f182f..d573f79b3d4 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1104,6 +1104,24 @@ include_dir 'conf.d'
</listitem>
</varlistentry>
+ <varlistentry id="guc-cleartext-passwords-action" xreflabel="cleartext_passwords_action">
+ <term><varname>cleartext_passwords_action</varname> (<type>enum</type>)
+ <indexterm>
+ <primary><varname>cleartext_passwords_action</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Controls what action to take when a password is sent unencrypted
+ (i.e. in clear text) to the server via the <command>CREATE ROLE</command>
+ or <command>ALTER ROLE</command> command. Valid options are
+ <literal>allow</literal>, <literal>warn</literal>, or
+ <literal>disallow</literal>.
+ The default value is <literal>warn</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="guc-password-encryption" xreflabel="password_encryption">
<term><varname>password_encryption</varname> (<type>enum</type>)
<indexterm>
diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c
index f6b641e726e..808f6a30655 100644
--- a/src/backend/libpq/crypt.c
+++ b/src/backend/libpq/crypt.c
@@ -21,12 +21,16 @@
#include "libpq/crypt.h"
#include "libpq/scram.h"
#include "utils/builtins.h"
+#include "utils/guc.h"
#include "utils/syscache.h"
#include "utils/timestamp.h"
/* Enables deprecation warnings for MD5 passwords. */
bool md5_password_warnings = true;
+/* Action to take when clear text passwords are used. */
+int cleartext_passwords_action = CLEARTEXT_ACTION_WARN;
+
/*
* Fetch stored password for a user, for authentication.
*
@@ -131,6 +135,36 @@ encrypt_password(PasswordType target_type, const char *role,
}
else
{
+
+ /*
+ * We are sending clear text passwords to the server. What should we
+ * do about that?
+ */
+ if (cleartext_passwords_action == CLEARTEXT_ACTION_WARN)
+ {
+ ereport(WARNING,
+ (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
+ errmsg("using a clear text password"),
+ errdetail("Sending a password using plain text is deprecated and may be removed in a future release of PostgreSQL."),
+ strncmp(application_name, "psql", 5) == 0
+ ? errhint("If using psql, you can set the password with \\password")
+ : errhint("Use a client that can change the password without sending it in clear text")));
+ }
+ else if (cleartext_passwords_action == CLEARTEXT_ACTION_DISALLOW)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PASSWORD),
+ errmsg("using a clear text password"),
+ errdetail("Sending a password using plain text is not allowed."),
+ strncmp(application_name, "psql", 5) == 0
+ ? errhint("If using psql, you can change the password with \\password")
+ : errhint("Use a client that can change the password without sending it in clear text")));
+ }
+ else
+ {
+ /* Silently accept this bad practice. */
+ }
+
switch (target_type)
{
case PASSWORD_TYPE_MD5:
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index d14b1678e7f..627ee9b6fcc 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -417,6 +417,13 @@ static const struct config_enum_entry password_encryption_options[] = {
{NULL, 0, false}
};
+static const struct config_enum_entry cleartext_action_options[] = {
+ {"allow", CLEARTEXT_ACTION_ALLOW, false},
+ {"warn", CLEARTEXT_ACTION_WARN, false},
+ {"disallow", CLEARTEXT_ACTION_DISALLOW, false},
+ {NULL, 0, false}
+};
+
static const struct config_enum_entry ssl_protocol_versions_info[] = {
{"", PG_TLS_ANY, false},
{"TLSv1", PG_TLS1_VERSION, false},
@@ -5418,6 +5425,16 @@ struct config_enum ConfigureNamesEnum[] =
NULL, assign_io_method, NULL
},
+ {
+ {"cleartext_passwords_action", PGC_SIGHUP, CONN_AUTH_AUTH,
+ gettext_noop("Action to take when clear text passwords are used."),
+ },
+ &cleartext_passwords_action,
+ CLEARTEXT_ACTION_WARN, cleartext_action_options,
+ NULL, NULL, NULL
+ },
+
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, 0, NULL, NULL, NULL, NULL
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index a9d8293474a..978ac20c73d 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -97,6 +97,7 @@
#password_encryption = scram-sha-256 # scram-sha-256 or md5
#scram_iterations = 4096
#md5_password_warnings = on
+#cleartext_passwords_action = warn # can be allow, warn, or disallow
#oauth_validator_libraries = '' # comma-separated list of trusted validator modules
# GSSAPI using Kerberos
diff --git a/src/include/libpq/crypt.h b/src/include/libpq/crypt.h
index a1b4b363143..921de2d8e6f 100644
--- a/src/include/libpq/crypt.h
+++ b/src/include/libpq/crypt.h
@@ -28,6 +28,9 @@
/* Enables deprecation warnings for MD5 passwords. */
extern PGDLLIMPORT bool md5_password_warnings;
+/* Specifies action when clear text passwords are used. */
+extern PGDLLIMPORT int cleartext_passwords_action;
+
/*
* Types of password hashes or secrets.
*
@@ -44,6 +47,22 @@ typedef enum PasswordType
PASSWORD_TYPE_SCRAM_SHA_256,
} PasswordType;
+/*
+ * Actions to take when clear text passwords are used.
+ *
+ * Passwords that are sent in clear text via the CREATE/ALTER USER
+ * command can cause a reaction by the server. We can either allow
+ * (the old behavior), warn (throw a warning and hint), or simply
+ * disallow (throws an exception).
+ */
+typedef enum CleartextAction
+{
+ CLEARTEXT_ACTION_ALLOW = 0,
+ CLEARTEXT_ACTION_WARN,
+ CLEARTEXT_ACTION_DISALLOW,
+} CleartextAction;
+
+
extern PasswordType get_password_type(const char *shadow_pass);
extern char *encrypt_password(PasswordType target_type, const char *role,
const char *password);
diff --git a/src/interfaces/ecpg/test/expected/connect-test5.stderr b/src/interfaces/ecpg/test/expected/connect-test5.stderr
index 037db217586..d74cc1f1e81 100644
--- a/src/interfaces/ecpg/test/expected/connect-test5.stderr
+++ b/src/interfaces/ecpg/test/expected/connect-test5.stderr
@@ -4,16 +4,24 @@
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute on line 24: query: alter user regress_ecpg_user2 encrypted password 'insecure'; with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 24: using PQexec
+[NO_PID]: ECPGnoticeReceiver: using a clear text password
[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 0
+[NO_PID]: sqlca: code: 0, state: 01P01
+[NO_PID]: ecpg_execute on line 24: using PQexec
+[NO_PID]: sqlca: code: 0, state: 01P01
[NO_PID]: ecpg_process_output on line 24: OK: ALTER ROLE
-[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: sqlca: code: 0, state: 01P01
[NO_PID]: ecpg_execute on line 25: query: alter user regress_ecpg_user1 encrypted password 'connectpw'; with 0 parameter(s) on connection main
[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 25: using PQexec
+[NO_PID]: ECPGnoticeReceiver: using a clear text password
[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 0
+[NO_PID]: sqlca: code: 0, state: 01P01
+[NO_PID]: ecpg_execute on line 25: using PQexec
+[NO_PID]: sqlca: code: 0, state: 01P01
[NO_PID]: ecpg_process_output on line 25: OK: ALTER ROLE
-[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: sqlca: code: 0, state: 01P01
[NO_PID]: ECPGtrans on line 26: action "commit"; connection "main"
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: connection main closed
diff --git a/src/test/regress/expected/create_role.out b/src/test/regress/expected/create_role.out
index 46d4f9efe99..8347205e4aa 100644
--- a/src/test/regress/expected/create_role.out
+++ b/src/test/regress/expected/create_role.out
@@ -64,6 +64,9 @@ CREATE ROLE regress_login LOGIN;
CREATE ROLE regress_inherit INHERIT;
CREATE ROLE regress_connection_limit CONNECTION LIMIT 5;
CREATE ROLE regress_encrypted_password ENCRYPTED PASSWORD 'foo';
+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
CREATE ROLE regress_password_null PASSWORD NULL;
-- ok, backwards compatible noise words should be ignored
CREATE ROLE regress_noiseword SYSID 12345;
diff --git a/src/test/regress/expected/password.out b/src/test/regress/expected/password.out
index 9bb3ab2818b..ec76afcbcef 100644
--- a/src/test/regress/expected/password.out
+++ b/src/test/regress/expected/password.out
@@ -14,16 +14,25 @@ SET password_encryption = 'scram-sha-256'; -- ok
SET password_encryption = 'md5';
CREATE ROLE regress_passwd1;
ALTER ROLE regress_passwd1 PASSWORD 'role_pwd1';
+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
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 regress_passwd2;
ALTER ROLE regress_passwd2 PASSWORD 'role_pwd2';
+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
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.
SET password_encryption = 'scram-sha-256';
CREATE ROLE regress_passwd3 PASSWORD 'role_pwd3';
+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
CREATE ROLE regress_passwd4 PASSWORD NULL;
-- check list of created entries
--
@@ -63,6 +72,9 @@ ALTER ROLE regress_passwd2_new RENAME TO regress_passwd2;
SET password_encryption = 'md5';
-- encrypt with MD5
ALTER ROLE regress_passwd2 PASSWORD 'foo';
+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
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.
@@ -75,6 +87,9 @@ ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t
SET password_encryption = 'scram-sha-256';
-- create SCRAM secret
ALTER ROLE regress_passwd4 PASSWORD 'foo';
+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
-- already encrypted with MD5, use as it is
CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023';
WARNING: setting an MD5-encrypted password
@@ -83,15 +98,27 @@ HINT: Refer to the PostgreSQL documentation for details about migrating to anot
-- This looks like a valid SCRAM-SHA-256 secret, but it is not
-- so it should be hashed with SCRAM-SHA-256.
CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234';
+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
-- These may look like valid MD5 secrets, but they are not, so they
-- should be hashed with SCRAM-SHA-256.
-- trailing garbage at the end
CREATE ROLE regress_passwd7 PASSWORD 'md5012345678901234567890123456789zz';
+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
-- invalid length
CREATE ROLE regress_passwd8 PASSWORD 'md501234567890123456789012345678901zz';
+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
-- Changing the SCRAM iteration count
SET scram_iterations = 1024;
CREATE ROLE regress_passwd9 PASSWORD 'alterediterationcount';
+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
SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+/=]+)\$([a-zA-Z0-9+=/]+):([a-zA-Z0-9+/=]+)', '\1$\2:<salt>$<storedkey>:<serverkey>') as rolpassword_masked
FROM pg_authid
WHERE rolname LIKE 'regress_passwd%'
@@ -128,7 +155,13 @@ SELECT rolpassword FROM pg_authid WHERE rolname='regress_passwd_empty';
-- stored/server keys. They will be re-hashed.
CREATE ROLE regress_passwd_sha_len0 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96Rqw=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZI=';
CREATE ROLE regress_passwd_sha_len1 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96RqwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZI=';
+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
CREATE ROLE regress_passwd_sha_len2 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96Rqw=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=';
+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
-- Check that the invalid secrets were re-hashed. A re-hashed secret
-- should not contain the original salt.
SELECT rolname, rolpassword not like '%A6xHKoH/494E941doaPOYg==%' as is_rolpassword_rehashed
--
2.30.2
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-14 18:49 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-17 03:12 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-17 03:36 ` PATCH: warn about, and deprecate, clear text passwords David G. Johnston <david.g.johnston@gmail.com>
2025-03-17 13:19 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-19 13:24 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-19 14:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-19 15:01 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
@ 2026-01-09 14:57 ` Greg Sabino Mullane <htamfids@gmail.com>
2026-01-09 16:28 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Treat <rob@xzilla.net>
2026-08-24 07:00 ` Re: PATCH: warn about, and deprecate, clear text passwords Jakub Wartak <jakub.wartak@enterprisedb.com>
1 sibling, 2 replies; 33+ messages in thread
From: Greg Sabino Mullane @ 2026-01-09 14:57 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Robert Haas <robertmhaas@gmail.com>; David G. Johnston <david.g.johnston@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Wed, Mar 19, 2025 at 11:01 AM Nathan Bossart <nathandbossart@gmail.com>
wrote:
> One of the main reasons I'm not totally sold on a clear-text password
> warning is because we don't have
> agreement on removing that ability anytime soon, not to mention
> Bruce's point about the debate extending into mid-March.
>
Okay, we are now safely past last March :). Any further thoughts on this?
My preference is still warn by default, but I could also be on board with
ignore by default.
Nathan, I'm not sure that having a concrete resolve to someday remove
cleartext passwords should be a blocker to warning now that they are a bad
idea, but open to discussion there.
Cheers,
Greg
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-14 18:49 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-17 03:12 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-17 03:36 ` PATCH: warn about, and deprecate, clear text passwords David G. Johnston <david.g.johnston@gmail.com>
2025-03-17 13:19 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-19 13:24 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-19 14:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-19 15:01 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2026-01-09 14:57 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
@ 2026-01-09 16:28 ` Robert Treat <rob@xzilla.net>
1 sibling, 0 replies; 33+ messages in thread
From: Robert Treat @ 2026-01-09 16:28 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; Robert Haas <robertmhaas@gmail.com>; David G. Johnston <david.g.johnston@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Fri, Jan 9, 2026 at 9:58 AM Greg Sabino Mullane <htamfids@gmail.com> wrote:
> On Wed, Mar 19, 2025 at 11:01 AM Nathan Bossart <nathandbossart@gmail.com> wrote:
>>
>> One of the main reasons I'm not totally sold on a clear-text password warning is because we don't have
>> agreement on removing that ability anytime soon, not to mention Bruce's point about the debate extending into mid-March.
>
>
>
> Okay, we are now safely past last March :). Any further thoughts on this? My preference is still warn by default, but I could also be on board with ignore by default.
>
> Nathan, I'm not sure that having a concrete resolve to someday remove cleartext passwords should be a blocker to warning now that they are a bad idea, but open to discussion there.
>
But Is it a bad idea?In the case of md5, it was a bad idea, because we
were going to remove support for md5, so we knew that people who
clearly care about security were going to need to make a change to
*something*, and giving them a heads up was certainly a good idea
about that.
In the cleartext password case, if we aren't going to remove cleartext
passwords (and TBH, I really can't fathom that we would remove them
entirely), then the warning is just us having opinions about other
people's setup that we can't possibly be more informed about.
So I'm generally -1 on the idea of needing a warning and more so on
the idea it should be the default. And while I do think an option that
allows administrators to disable cleartext passwords seems potentially
useful, for all the gnashing of teeth about it, I don't see a lot of
adoption of things like https://github.com/HexaCluster/credcheck.
Robert Treat
https://xzilla.net
^ permalink raw reply [nested|flat] 33+ messages in thread
* Re: PATCH: warn about, and deprecate, clear text passwords
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 10:07 ` Re: PATCH: warn about, and deprecate, clear text passwords Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 18:10 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Re: PATCH: warn about, and deprecate, clear text passwords Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2025-03-14 18:49 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-17 03:12 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-17 03:36 ` PATCH: warn about, and deprecate, clear text passwords David G. Johnston <david.g.johnston@gmail.com>
2025-03-17 13:19 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-19 13:24 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-03-19 14:06 ` Re: PATCH: warn about, and deprecate, clear text passwords Robert Haas <robertmhaas@gmail.com>
2025-03-19 15:01 ` Re: PATCH: warn about, and deprecate, clear text passwords Nathan Bossart <nathandbossart@gmail.com>
2026-01-09 14:57 ` Re: PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
@ 2026-08-24 07:00 ` Jakub Wartak <jakub.wartak@enterprisedb.com>
1 sibling, 0 replies; 33+ messages in thread
From: Jakub Wartak @ 2026-08-24 07:00 UTC (permalink / raw)
To: Greg Sabino Mullane <htamfids@gmail.com>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; Robert Haas <robertmhaas@gmail.com>; David G. Johnston <david.g.johnston@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; Isaac Morland <isaac.morland@gmail.com>; Aleksander Alekseev <aleksander@timescale.com>; pgsql-hackers
On Fri, Jan 9, 2026 at 3:58 PM Greg Sabino Mullane <htamfids@gmail.com> wrote:
>
>
> On Wed, Mar 19, 2025 at 11:01 AM Nathan Bossart <nathandbossart@gmail.com> wrote:
>>
>> One of the main reasons I'm not totally sold on a clear-text password warning is because we don't have
>> agreement on removing that ability anytime soon, not to mention Bruce's point about the debate extending into mid-March.
>
>
>
> Okay, we are now safely past last March :). Any further thoughts on this? My preference is still warn by default, but I could also be on board with ignore by default.
>
> Nathan, I'm not sure that having a concrete resolve to someday remove cleartext passwords should be a blocker to warning now that they are a bad idea, but open to discussion there.
I owed a review to Greg, so I've taken a look at this old thread, and oh my
I didn't realize what I was up to, but I'll try to revive the attempt.
I think Robert in [1] had the best longer-term idea about passing password in
extended protocol only and using a new command dedicated for this. As for the
Tom's question from [2] I had immediate thought: why not use psql's \bind
there in pg_dumpall -g to pass password via extended protocol?
There are some PoC patches (full-disclaimer: by Claude Opus), but they are for
re-igniting the important discussion, and NOT for commit (just seeking how it
would work/behave, not for proper impl. and for finding weak spots in overall
concept, I hope I'm not going to be grilled too harshly for doing that here
;), as the topic seems to be a bit critical)
0001 - this is by Greg, cleartext_passwords_action GUC; it's just re-applied
by LLM due to bit-rot, so this is not an AI patch. Just for someone
to have ready to thing on -master. If that ever gets in, he is the
author
0002 - introduce 'PASSWORD $1, $2' top level planning command (so it works
with extended protocol)
0003 - desperate attempt to tame the passwords from server log; doomed(?)
0004 - same as above, but for extended protocol too; doomed(?)
0005 - teach pg_dumpall -g to issue PASSWORD with \bind
Intro, my rationale:
====================
1. I've run a 'wildai' semi-production-like experiments where the LLM was
used to attack semi-safe PG~master connecting as "app_dba" kind of account
(owner of all data, pg_monitor for troubleshooting/monitoring) and plenty
of extensions. I did not want the LLM to concentrate on finding buffer
overflows, but I intentionally planted some *typical* mistakes that people
regularly do from what I saw (this is largely outside the scope of this
thread), but first thing was ... in under like 5mins and a couple of USD it
deduced on its own that I've created some other users from pg_stat_statements
with CREATE USER/ALTER USER that had pg_read_all_data, then it connected there
using dblink extension over 127.0.0.1, fetched pg_authid superuser passwords,
used john the ripper, used dblink again to reach now that superuser and
execute touch /var/lib/pgsql/data/DONE.txt )) (that was its objective).
The key thing for me here is: how __FAST__ this was. Now the thing is that
even if I know all of this I have NO way to force any of my co-workers (DBAs)
to prevent that vulnerable thing from happening. One could say that SCRAM
password could be also there, so it would only delay the thing (it would take
more time for jtr)..
2. Earlier Greg mentioned PCI DSS compliance, so I've checked and PCI DSS says
via requirement 8.3.2 (v4.x) or 8.2.1 (v3.x):
Using strong cryptography, render all authentication credentials (such as
passwords/phrases) unreadable during transmission and __storage on all
system components__
Later they even say (10.7):
Retain audit trail history for at least one year, with a minimum of three
months immediately available for analysis (for example, online, archived, or
restorable from backup).
This literally means that people having log_statements=ddl (useful for
SRE, not as proper audit trail) are cooked. pg_stat_statements also
potentially stores them (.save=on)... and this is backed up which even further
undermines the pg_authid/pg_shadow encryption.
Meanwhile Greg provided a patch that started this thread with:
> 1. "warn" The current default, this issues a warning if a clear
> text password is used
>
> 2. "allow" This does nothing, and thus emulates the historical behavior.
>
> 3. "disallow". This prevents the use of plain text completely, by throwing
> an error if a password set or change is attempted.
I'm +1 to this idea in general, but with the default of "allow" for now. DBAs
could temporarily switch to "warn" to detect uses of it and then later after
some time switch to "disallow" to meet harder security/compliance objectives.
But all of that is - as discussed - an even bigger security risk, because we
would have *more* passwords.
I would probably vote +1 to adding some deprecation/security note that
starting with PG-20, cleartext passwords are deprecated, but there are no
plans to remove it, then gradually maybe evaluate position; but the point is
security installations could enable opt-in.
> PGC_HUP
I would also make it somehow possible to be per-role GUC (overridable with
ALTER USER .. SET)
Naming => how about allow_cleartext_passwords=allow/warn/disallow (or deny?)?
And with the context of those attached patches, how about even
allow_alter_user_passwords? (to disable the whole thing). We have those
'allow_%' and they seem to be doing great.
Extended protocol (\bind) inital attemps
========================================
So, in [1] Robert proposed something and I've come up initially with this
kludge as starting point:
CREATE OR REPLACE FUNCTION public.set_password(uname text, pwd text)
RETURNS void
LANGUAGE plpgsql
SECURITY DEFINER
SET search_path TO 'pg_catalog', 'pg_temp'
SET
log_min_duration_statement TO '-1'
SET log_parameter_max_length TO
'0'
SET log_parameter_max_length_on_error TO '0'
SET log_min_messages
TO 'error'
SET log_error_verbosity TO 'terse'
SET log_statement TO 'none'
AS $function$
DECLARE
v_msg text;
v_query text := current_query(); -- detect non-bind
BEGIN
-- check if not using extended protocol
IF v_query != 'select set_password($1, $2) ' THEN
RAISE EXCEPTION 'do not use simple query protocol to run this';
END IF;
-- scram_sha256_verifier() not provided for clarity
EXECUTE format('ALTER USER %I PASSWORD %L',
uname, public.scram_sha256_verifier(pwd));
-- just in case silence the exception stack
EXCEPTION WHEN OTHERS THEN
GET STACKED DIAGNOSTICS v_msg = MESSAGE_TEXT;
RAISE EXCEPTION '%', v_msg;
END $function$;
Ofc, it misses plenty of stuff this way and was only written in a way
to prevent leaks by superuser, it literally requires running as:
BEGIN;
SET LOCAL log_parameter_max_length = 0;
SET LOCAL log_parameter_max_length_on_error = 0;
SET LOCAL log_statement = 'none';
-- yay!
SELECT public.set_password($1, $2) \bind 'user' 'pw' \g
COMMIT;
but of course that won't work for non-superusers due to lack of privs on some
of those GUCs :( Nobody is going to convince me that our userbase should use
this frankenstein command to change passwords to avoid leaking the password
Ofc, it won't fully solve problems, e.g:
ERROR: do not use simple query protocol to run this
STATEMENT: select set_password('user', 'secretpw');
PASSWORD cmd
============
So of course I had to try to see what Robert's idea could look like (0002, btw
he is not to be blamed for this attached slop, and he's not aware of what
I'm trying to do here at all )
To use/test it, just turn on all password logging you can think of, and try to
use \password from psql and ALTER USER .. PASSWORD 'cleartext' and see what
happens. Or maybe use this as base to come up with something better.
0002..0005 are probably full of slop, security bugs and so on, perhaps
concentrate on the UX or outcomes ? To me it behaves OK-ish or at least the
least worst option among all the bad ones (including current state).
It won't cure
all the leaks for sure, but apparently nothing will (even with 0003/0004,
this thing comes to the mind):
DO $$ BEGIN EXECUTE format('ALTER USER import PASSWORD ''new'''); END; $$;
As such 0004 and 0005 are marked to be doomed already probably, because as
Tom provided a good argument in [3][4] this opens some precedent, but there
seems to be no other way(?) Well, we could at least build some new contrib/
extension that would do that, but add plain warnings there that this is
not fully 100% secure way to do this (because it is impossible).
Some open questions:
- still some old psql client could connect and issue plaintext/even hashed
password, so without 0003/0004 we stand no chances. Maybe we could still
try to do damage control, but add some documentation that logs shall be
protected anyway, because they still may contain sensitive password and those
are not security issues (?)
- attached patches have of course no backwards compatibility (e.g. newer
libpq's PQchangePassword() reaching an older server would fail because it
would send them an unknown 'PASSWORD' command)
- maybe command fit is after all wrong idea? How about a new dedicated protocol
message type dedicated to just changing passwords (???)
- or maybe reworking ALTER TABLE from being a utility statement to a parsable
statement[4], but that sounded way too challenging for myself even in theory
(risk of introducing bugs, etc)
-J.
[1] - https://www.postgresql.org/message-id/CA%2BTgmoYDtt0TR-9B4sMFRGYzompcu-Ph9k7nM3gu7hTPrWWYgQ%40mail.g...
[2] - https://www.postgresql.org/message-id/4061037.1741027647%40sss.pgh.pa.us
[3] - https://www.postgresql.org/message-id/3139897.1740157064%40sss.pgh.pa.us
[4] - https://www.postgresql.org/message-id/1601051.1740499733%40sss.pgh.pa.us
Attachments:
vIDEAv1-0001-Add-cleartext_passwords_action-to-react-to-c.patch.nocfbot (application/octet-stream, 18.6K) download
vIDEAv1-0003-Keep-clear-text-role-passwords-out-of-the-se.patch.nocfbot (application/octet-stream, 14.0K) download
vIDEAv1-0002-Add-PASSWORD-command-to-set-a-role-s-passwor.patch.nocfbot (application/octet-stream, 37.0K) download
vIDEAv1-0005-pg_dumpall-dump-role-passwords-with-the-PASS.patch.nocfbot (application/octet-stream, 10.9K) download
vIDEAv1-0004-Redact-clear-text-role-passwords-in-the-exte.patch.nocfbot (application/octet-stream, 10.0K) download
^ permalink raw reply [nested|flat] 33+ messages in thread
end of thread, other threads:[~2026-08-24 07:00 UTC | newest]
Thread overview: 33+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-02-21 22:33 PATCH: warn about, and deprecate, clear text passwords Greg Sabino Mullane <htamfids@gmail.com>
2025-02-22 08:07 ` Guillaume Lelarge <guillaume.lelarge@dalibo.com>
2025-02-22 12:53 ` Guillaume Lelarge <guillaume.lelarge@dalibo.com>
2025-02-24 13:55 ` Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 19:41 ` Guillaume Lelarge <guillaume.lelarge@dalibo.com>
2025-02-24 10:07 ` Aleksander Alekseev <aleksander@timescale.com>
2025-02-24 14:26 ` Greg Sabino Mullane <htamfids@gmail.com>
2025-02-24 20:47 ` Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:06 ` Isaac Morland <isaac.morland@gmail.com>
2025-02-24 21:18 ` Nathan Bossart <nathandbossart@gmail.com>
2025-02-24 21:20 ` Greg Sabino Mullane <htamfids@gmail.com>
2025-02-25 15:34 ` Nathan Bossart <nathandbossart@gmail.com>
2025-02-25 16:13 ` Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 16:33 ` Nathan Bossart <nathandbossart@gmail.com>
2025-03-03 17:06 ` Greg Sabino Mullane <htamfids@gmail.com>
2025-03-03 17:11 ` Isaac Morland <isaac.morland@gmail.com>
2025-03-03 18:10 ` Robert Haas <robertmhaas@gmail.com>
2025-03-03 18:47 ` Tom Lane <tgl@sss.pgh.pa.us>
2025-03-03 18:54 ` Robert Haas <robertmhaas@gmail.com>
2025-03-14 15:21 ` Nathan Bossart <nathandbossart@gmail.com>
2025-03-14 18:49 ` Greg Sabino Mullane <htamfids@gmail.com>
2025-03-16 15:04 ` Roberto Mello <roberto.mello@gmail.com>
2025-03-17 03:12 ` Robert Haas <robertmhaas@gmail.com>
2025-03-17 03:36 ` David G. Johnston <david.g.johnston@gmail.com>
2025-03-17 13:19 ` Robert Haas <robertmhaas@gmail.com>
2025-03-19 13:24 ` Greg Sabino Mullane <htamfids@gmail.com>
2025-03-19 13:53 ` Bruce Momjian <bruce@momjian.us>
2025-03-19 14:06 ` Robert Haas <robertmhaas@gmail.com>
2025-03-19 15:01 ` Nathan Bossart <nathandbossart@gmail.com>
2025-07-12 15:29 ` Greg Sabino Mullane <htamfids@gmail.com>
2026-01-09 14:57 ` Greg Sabino Mullane <htamfids@gmail.com>
2026-01-09 16:28 ` Robert Treat <rob@xzilla.net>
2026-08-24 07:00 ` Jakub Wartak <jakub.wartak@enterprisedb.com>
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