Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vsOW9-003ZQs-1F for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Feb 2026 17:05:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vsOW8-00Aw21-0F for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Feb 2026 17:05:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vsOW7-00Aw1t-2c for pgsql-hackers@lists.postgresql.org; Tue, 17 Feb 2026 17:05:43 +0000 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vsOW5-000000015Q1-10rl for pgsql-hackers@postgresql.org; Tue, 17 Feb 2026 17:05:43 +0000 Received: by mail-oi1-x241.google.com with SMTP id 5614622812f47-45f004e7d71so9636b6e.1 for ; Tue, 17 Feb 2026 09:05:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771347941; x=1771952741; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=NC9UDduAApFpy1EztF7geOcC0DAYmNytR8GX/+PwAlw=; b=WODp2dXHK332JO6GNZUg4wY3xfMOTI+KjSGG2HGVKyNyS+06m/DsfPbKwaL11Owg5B 5KTS8lqlVVBAqtFeNtE+rudRMBYGDKf873bip7YR4SWPsyHBg84P6VBvevHO2zK4AlrW GNLfyWk62n0SGKZQstZdYYko3vxnhnjy2/XZ7ODJRVf2WdELuTAsW5yPfew21m3DQgXv pW6pmaWIorIuhE0q+fUu5CTT76AoMn0IYodFoBc9vYpiqzUwnTMWuEQ+DXEUzgQlkdwM o3Qs3fEYtXMkQnkibhKzjDTniJsGWKGoLmg/vUdhxoqYcU4efYZqMNsMt3WSCc9zAEoq yKWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771347941; x=1771952741; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NC9UDduAApFpy1EztF7geOcC0DAYmNytR8GX/+PwAlw=; b=UnGSw06BNuO25lErNjOJd2Es+Idak0zHLsMs+tUizxzcwXv7zSim91BURnyilAHP3s lgIlHz/+Hrq/id8/oHu8sYjMYc8uOYD2sSJ1RJpDmGpPGXnnBLbP07Gwmudtz5vXMMBW 5Za1zJJ+Npauf9TTAZA+F8MPepYpAtjmr2rbpXrldNCQSaZqj9hBeLWXNmW9q9PH8qFw HNOavZEPdbxx7LCxNr2q4gdDvQ0ZKkHC8GUe3DrWMO0KFVQ0w9bTKIxSM5WPpCa5do1R ypf5Qn6bcLwal9tI2MXugyKmLnYj0JjofKv0dvsEJ4NixHCjwNMS8lSTGO2iApQwnh2c BmDw== X-Gm-Message-State: AOJu0YxOkmzo5o6sIv4yQuHGRmP7CGkDMoSiYMZn3OVaU8rUKo+l+DeL wDGPNCXy8lwpr/ws/NW7nNryZT7xXywX9RGRyPkjqHuLI+f6unkPRlzdf1uKOL+Y X-Gm-Gg: AZuq6aKPAuhdelJInqYjk18sb8eJk3dRjwCHgZg2noY+NsIZtMFV7Ik6EvBIf2qlwKr hNnBy4r1eEvCNfyQx2k2XaBxj+13IbS2RMnuva5Gh73bQ7QMBWPI7LWpyCNqUHjQhWjpXcPF9gJ lXLSqI/kL5hkHzXGo9Si7aEy36TnjhuGDQ14YunIHZV4v/WeDf7rKCsr7O0JZJKcVbV0xLMCE6f sQf2uG1dQRaJ8pjH1jMV5cpB+pKv6LnqqOIP2A7S5tF71hjY0NbqUnP4uwLwTkDGLZ8edkL8aqh +sziKMgj/OJ64IBnIdFaz6IINaoEhbtFDbjhbYwhoJnJc1Lm7QZmIWOIcM+I5c2KWnTMODgblI0 FxBGRg47Cg/tDYcimyxxTchDIl4K1DeV/aJNAPbAWcMjDx1k7Hi0oCOIdcu2uBgrXTC4f72tb+d 12yq20h3q1peevm5pSaoJsQwKJSrF/tZPApOSEgIwj2Z9Ul7cElYgAZ/tleVWCDpgNUBZMiLLFL iTmI4HtuaQidFoN X-Received: by 2002:a05:6808:c28c:b0:450:b87b:1ec4 with SMTP id 5614622812f47-463b01b46a8mr6335793b6e.15.1771347941434; Tue, 17 Feb 2026 09:05:41 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4636b064cd5sm13091536b6e.10.2026.02.17.09.05.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Feb 2026 09:05:40 -0800 (PST) Date: Tue, 17 Feb 2026 11:05:38 -0600 From: Nathan Bossart To: Andreas Karlsson Cc: pgsql-hackers@postgresql.org, Tom Lane Subject: Re: add warning upon successful md5 password auth Message-ID: References: <0731e3d8-3d13-4539-addc-a2c13a8b1b14@proxel.se> <3c4c95a2-c27b-4d9c-8eda-c96a17ba1d37@proxel.se> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="7EXlSGbrPZLhwNui" Content-Disposition: inline In-Reply-To: <3c4c95a2-c27b-4d9c-8eda-c96a17ba1d37@proxel.se> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --7EXlSGbrPZLhwNui Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Feb 17, 2026 at 07:08:17AM +0100, Andreas Karlsson wrote: > After thinking more on the subject I have come around. I think warning spam > (that can be disabled) is fine and why not introduce it directly in 19? WFM > As for the patch itself I think it looks good, but I am not a fan of the > test code. Why not simply write like the below? > > test_conn($node, 'user=md5_role', 'md5', 0, > log_like => > [qr/connection authenticated: identity="md5_role" method=md5/], > expected_stderr => > [qr/authenticated with an MD5-encrypted password/]) No good reason. I've updated the patch. -- nathan --7EXlSGbrPZLhwNui Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0001-Warn-upon-successful-MD5-password-authentication.patch From f55b97a4791c137f8c7271a45f7f6f19424b3d32 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Tue, 17 Feb 2026 10:20:47 -0600 Subject: [PATCH v2 1/1] Warn upon successful MD5 password authentication. This uses the "connection warning" infrastructure introduced by commit 1d92e0c2cc to emit a WARNING when an MD5 password is used to authenticate. MD5 password support was marked as deprecated in v18 and will be removed in a future release of Postgres. These warnings are on by default but can be turned off via the existing md5_password_warnings parameter. Reviewed-by: Andreas Karlsson Reviewed-by: Xiangyu Liang Discussion: https://postgr.es/m/aYzeAYEbodkkg5e-%40nathan --- doc/src/sgml/config.sgml | 3 ++- src/backend/libpq/crypt.c | 17 +++++++++++++++++ src/test/authentication/t/001_password.pl | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index faf0bdb62aa..6e5a5364778 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1188,7 +1188,8 @@ include_dir 'conf.d' Controls whether a WARNING about MD5 password - deprecation is produced when a CREATE ROLE or + deprecation is produced upon successful MD5 password authentication or + when a CREATE ROLE or ALTER ROLE statement sets an MD5-encrypted password. The default value is on. diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c index dbdd0e40f41..37ccec355c7 100644 --- a/src/backend/libpq/crypt.c +++ b/src/backend/libpq/crypt.c @@ -294,7 +294,24 @@ md5_crypt_verify(const char *role, const char *shadow_pass, } if (strcmp(client_pass, crypt_pwd) == 0) + { retval = STATUS_OK; + + if (md5_password_warnings) + { + MemoryContext oldcontext; + char *warning; + char *detail; + + oldcontext = MemoryContextSwitchTo(TopMemoryContext); + + warning = pstrdup(_("authenticated with an MD5-encrypted password")); + detail = pstrdup(_("MD5 password support is deprecated and will be removed in a future release of PostgreSQL.")); + StoreConnectionWarning(warning, detail); + + MemoryContextSwitchTo(oldcontext); + } + } else { *logdetail = psprintf(_("Password does not match for user \"%s\"."), diff --git a/src/test/authentication/t/001_password.pl b/src/test/authentication/t/001_password.pl index 0ec9aa9f4e8..a4b11673c26 100644 --- a/src/test/authentication/t/001_password.pl +++ b/src/test/authentication/t/001_password.pl @@ -499,6 +499,8 @@ SKIP: { skip "MD5 not supported" unless $md5_works; test_conn($node, 'user=md5_role', 'md5', 0, + expected_stderr => + qr/authenticated with an MD5-encrypted password/, log_like => [qr/connection authenticated: identity="md5_role" method=md5/]); } -- 2.50.1 (Apple Git-155) --7EXlSGbrPZLhwNui--