]> granicus.if.org Git - postgresql/commit
Fix detection of passwords hashed with MD5 or SCRAM-SHA-256
authorMichael Paquier <michael@paquier.xyz>
Tue, 23 Apr 2019 06:43:38 +0000 (15:43 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 23 Apr 2019 06:43:38 +0000 (15:43 +0900)
commit15fe91e70ec69ecffad9f250f8e96f3823147195
tree5e52320bc7edbf8450113a176343657727af9866
parent42b962176e7ab196a24e96877845331c255a978f
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
src/backend/libpq/auth-scram.c
src/backend/libpq/crypt.c
src/include/common/md5.h
src/include/libpq/scram.h
src/test/regress/expected/password.out
src/test/regress/sql/password.sql