• Michael Paquier's avatar
    Fix detection of passwords hashed with MD5 or SCRAM-SHA-256 · ccae190b
    Michael Paquier authored
    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
    ccae190b
crypt.c 7.68 KB