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 1vqGGN-007ZMK-0z for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Feb 2026 19:52:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vqGGM-005Qx9-1Y for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Feb 2026 19:52:39 +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 1vqGGM-005Qwx-0B for pgsql-hackers@lists.postgresql.org; Wed, 11 Feb 2026 19:52:38 +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 1vqGGK-00000000Amy-12U2 for pgsql-hackers@postgresql.org; Wed, 11 Feb 2026 19:52:37 +0000 Received: by mail-oi1-x241.google.com with SMTP id 5614622812f47-45c733ccc32so1478804b6e.0 for ; Wed, 11 Feb 2026 11:52:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770839556; x=1771444356; darn=postgresql.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=b+lor3xeDijC95GInMhtoLDLb9x2lF6evZ9GwyGa8RQ=; b=EhyfNywsnXqC9bTyWKA53R28pcD9RCqLpcgCW1XJCV/zMMO6s0G7sgcMLE3U+Iu8HD yjyjOUjIGzv/EFiJYvSORB7n70tUbbJNOT+vQSysTzdajNhGxAmvg2sx/o3ynWV7QCZW 4VEE0MhS843j8PVBrzDBBvyfBAsPJlCDjtwYj77x4uuI0OBRICN7tJ/ruEsuT/EnNWqO gTBiA7OGbLQqAS55eASh6JaMoFdncFSOQGPxeYFwV9qLc+scxIyj9vCIhrKZ7GAllbE6 hKgOhc+flpKsiNXc20Qw7s8Ztdz86AAE9dExCWFseZ4zY/y8QK/2l3y9rWurZo4sXHol BCpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770839556; x=1771444356; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=b+lor3xeDijC95GInMhtoLDLb9x2lF6evZ9GwyGa8RQ=; b=T+rPQv1+LVDZoAv1/lnL0FCDmdHHyHxR+jdr+m35KjqV07wxeoa0B+FCO8cgzdj3oz qTKCFm//hVAkAfqQf1x/RI16CyRlrs4cOC6pFq2vUP+dbYdGYdZb6vQpQv4aRd+YTFHx eYGU2EvFfHtETRyLLrQdfVgAZwCOck9pNxRNkikUG8MXez7LgOK++Qtw1DxFcahnEtz2 65zyUyOfkcjLsDudLrZ1328TWWhl66SRD575TEHv1iLfjPubKpD3jmYzoja+UCmtr4+4 ITauuO3IsG2Q5Z3w7pd9xL9lQjGu8ZNWa8BWvPrcr3AUTEQcW6OY7MNyTvokmvlm5lOT cv2w== X-Gm-Message-State: AOJu0YwR+Ish19sESLuJxUtriSFvE07ujIODZwM855yE1wjVQi+d5mky gWzQpsbBw/biFyWlH5kkBWY8sCy9RGh7DW0MbIv2w/vE9ORrdHRAwD3zGRNaH6gI X-Gm-Gg: AZuq6aL4DqJtD/sRwMZU3cbcQ6esXzXI6i0xJTH65W6y0UDaMlsdQdc5jr2xvlAsWpi 7a/EHBZk618/JX4VUKP1YLBDa+hW9mVqMNSN2dY0reK8Gh39kwpK6tE3pKyKJBpbug/DE7vAGiW I5x6WqXnthfw9fzOTsbH8ZQXGHVWvG2xnlUhtbK6dIu0ftBCYE5yHuc966Sx/hnaDuyGrvVAf1/ sNCXilOWZu0Z56uivJUX2msMBNKBM7wGMMZNXHCCCpcjKK3CyxVM/u4/SZSh/yp+y63rXQZjHKy +Dy/bHBf4Wlp1+8YP9AkAEhq9yweSsIZ0vaCTzBDsatL9ZS0GAbmi0ztWsyMuytqsPxHscP1ydV uDha78FrhpNcBezu17m93cEB5811orgsf5q2F7B7FW4Lr90pCEe3uurlxmClvw4FWHE2R3iZjEt u2oQbH2Y+uQ2zC33smL3JyldZ8hQrsH7/CES8qbbTyOTQGhpJXgK63Bj6x+qPXwJy8FGhZ2LXOq VA+rE5pA67nXpAq X-Received: by 2002:a05:6808:448c:b0:45f:42d6:3014 with SMTP id 5614622812f47-4637b6a9c99mr334623b6e.26.1770839556386; Wed, 11 Feb 2026 11:52:36 -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-4636b098dd9sm1476181b6e.15.2026.02.11.11.52.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Feb 2026 11:52:35 -0800 (PST) Date: Wed, 11 Feb 2026 13:52:33 -0600 From: Nathan Bossart To: pgsql-hackers@postgresql.org Subject: add warning upon successful md5 password auth Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="EMvnJNmKCGMA0Isi" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --EMvnJNmKCGMA0Isi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline From a related discussion last year [0]: On Tue, Jun 03, 2025 at 12:09:50PM -0500, Nathan Bossart wrote: > On Tue, Jun 03, 2025 at 09:43:59AM -0500, Nathan Bossart wrote: >> On Tue, Jun 03, 2025 at 10:34:06AM -0400, Tom Lane wrote: >>> If we really want to be in peoples' face about this, the thing >>> to do is to print a warning every time they log in with an MD5 >>> password. Also, to Michael's point, that really would be exactly >>> the same place where the eventual "sorry, not supported anymore" >>> message will be. >> >> I held off on this because I was worried it might be far too noisy. That >> does seem like it has the best chance of getting folks' attention, though. >> If it's too noisy, users can always turn off the warnings. > > Here is a draft-grade patch that adds a WARNING upon successful > authentication with an MD5 password. It's a little hacky because AFAICT we > need to wait until well after authentication (for GUCs to be set up, etc.) > before we actually emit the WARNING. When the time comes to remove MD5 > password support completely, we'll need to do something like modify > CheckMD5Auth() to always return STATUS_ERROR with an appropriate logdetail > message. Since I just added a "connection warnings" infrastructure in commit 1d92e0c2cc, I thought it might be a good time to revisit this idea. Attached is an updated patch. I'm not sure this is v19 material. It could make sense to wait until v20 or something. But I figured it was worth at least having the discussion. [0] https://postgr.es/m/aD8sXgfJeIGLc7-t%40nathan -- nathan --EMvnJNmKCGMA0Isi Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0001-Add-warning-upon-successful-MD5-password-authenti.patch From 5a80bd6f98c7f83dc9e1fef56c71be2f5570ba29 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Wed, 11 Feb 2026 11:56:15 -0600 Subject: [PATCH v1 1/1] Add warning upon successful MD5 password authentication. --- doc/src/sgml/config.sgml | 7 ++++--- src/backend/libpq/crypt.c | 17 +++++++++++++++++ src/test/authentication/t/001_password.pl | 7 ++++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 6bc2690ce07..a1f3ca65ed2 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1188,9 +1188,10 @@ include_dir 'conf.d' Controls whether a WARNING about MD5 password - deprecation is produced when a CREATE ROLE or - ALTER ROLE statement sets an MD5-encrypted password. - The default value is on. + 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..45f9f3504f7 100644 --- a/src/test/authentication/t/001_password.pl +++ b/src/test/authentication/t/001_password.pl @@ -498,9 +498,10 @@ test_conn($node, 'user=scram_role', 'md5', 0, SKIP: { skip "MD5 not supported" unless $md5_works; - test_conn($node, 'user=md5_role', 'md5', 0, - log_like => - [qr/connection authenticated: identity="md5_role" method=md5/]); + my @test_params = (); + push @test_params, log_like => [qr/connection authenticated: identity="md5_role" method=md5/]; + push @test_params, expected_stderr => qr/authenticated with an MD5-encrypted password/; + test_conn($node, 'user=md5_role', 'md5', 0, @test_params); } # require_auth succeeds with SCRAM required. -- 2.50.1 (Apple Git-155) --EMvnJNmKCGMA0Isi--