pgsql: Apply timingsafe_bcmp() in authentication paths

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Apply timingsafe_bcmp() in authentication paths
Date: 2026-05-11 12:19:38
Message-ID: E1wMPbm-0002XK-1F@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Apply timingsafe_bcmp() in authentication paths

This commit applies timingsafe_bcmp() to authentication paths that
handle attributes or data previously compared with memcpy() or strcmp(),
which are sensitive to timing attacks.

The following data is concerned by this change, some being in the
backend and some in the frontend:
- For a SCRAM or MD5 password, the computed key or the MD5 hash compared
with a password during a plain authentication.
- For a SCRAM exchange, the stored key, the client's final nonce and the
server nonce.
- RADIUS (up to v18), the encrypted password.
- For MD5 authentication, the MD5(MD5()) hash.

Reported-by: Joe Conway <mail(at)joeconway(dot)com>
Security: CVE-2026-6478
Author: Michael Paquier <michael(at)paquier(dot)xyz>
Reviewed-by: John Naylor <johncnaylorls(at)gmail(dot)com>
Backpatch-through: 14

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c4e7435b30984dacd0396ce0128bd54c8026fef5
Author: Michael Paquier <michael(at)paquier(dot)xyz>

Modified Files
--------------
src/backend/libpq/auth-scram.c | 8 ++++----
src/backend/libpq/auth.c | 2 +-
src/backend/libpq/crypt.c | 6 ++++--
src/interfaces/libpq/fe-auth-scram.c | 6 +++---
4 files changed, 12 insertions(+), 10 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2026-05-11 12:19:39 pgsql: Check CREATE privilege on multirange type schema in CREATE TYPE.
Previous Message Noah Misch 2026-05-11 12:19:37 pgsql: Harden our regex engine against integer overflow in size calcula