pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix detection of passwords hashed with MD5 or SCRAM-SHA-256
Date: Tue, 23 Apr 2019 06:47:20 +0000
Message-ID: <E1hIpD6-0002uT-TG@gemulon.postgresql.org> (raw)

Fix detection of passwords hashed with MD5 or SCRAM-SHA-256

This commit fixes a couple of issues related to the way password
verifiers hashed with MD5 or SCRAM-SHA-256 are detected, leading to
being able to store in catalogs passwords which do not follow the
supported hash formats:
- A MD5-hashed entry was checked based on if its header uses "md5" and
if the string length matches what is expected.  Unfortunately the code
never checked if the hash only used hexadecimal characters, as reported
by Tom Lane.
- A SCRAM-hashed entry was checked based on only its header, which
should be "SCRAM-SHA-256$", but it never checked for any fields
afterwards, as reported by Jonathan Katz.

Backpatch down to v10, which is where SCRAM has been introduced, and
where password verifiers in plain format have been removed.

Author: Jonathan Katz
Reviewed-by: Tom Lane, Michael Paquier
Discussion: https://postgr.es/m/016deb6b-1f0a-8e9f-1833-a8675b170aa9@postgresql.org
Backpatch-through: 10

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ccae190b916f27fbe4079ee4664d34cd1be47b79

Modified Files
--------------
src/backend/libpq/auth-scram.c         |  4 +---
src/backend/libpq/crypt.c              | 13 +++++++++++--
src/include/common/md5.h               |  1 +
src/include/libpq/scram.h              |  2 ++
src/test/regress/expected/password.out | 17 ++++++++++++++++-
src/test/regress/sql/password.sql      | 13 +++++++++++++
6 files changed, 44 insertions(+), 6 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1hIpD6-0002uT-TG@gemulon.postgresql.org>
Permalink:  ../E1hIpD6-0002uT-TG@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hIpD6-0002uT-TG@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: Fix detection of passwords hashed with MD5 or SCRAM-SHA-256
  In-Reply-To: <E1hIpD6-0002uT-TG@gemulon.postgresql.org>
  References: <E1hIpD6-0002uT-TG@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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