Repository navigation
Description
Description
In the postgres module, the _maybe_encrypt_password function makes use of hashlib.md5. This however is prohibited and failes in while in (FIPS 140-2)[https://csrc.nist.gov/publications/detail/fips/140/2/final] mode.
Steps to Reproduce the behavior
Enable FIPS 140-2 mode. This can be done in CentOS/RHEL using these instructions. Then attempt to create a database user using the postgres_user state or module
Expected behavior
This will not fail in FIPS-140-2 mode
Error output
ID: postgres_user-example
Function: postgres_user.present
Name: example
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/salt/state.py", line 1933, in call
**cdata['kwargs'])
File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1951, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/states/postgres_user.py", line 147, in present
encrypted=encrypted)
File "/usr/lib/python3.6/site-packages/salt/modules/postgres.py", line 997, in _maybe_encrypt_password
hashlib.md5(salt.utils.stringutils.to_bytes('{0}{1}'.format(password, role))).hexdigest())
ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS
Started: 20:32:01.922439
Duration: 0.651 ms
Changes:
Versions Report
[root@server example]# salt-call --version
salt-call 2019.2.3 (Fluorine)
Additional Notes
This can be worked around by provided pre-hashed, however newer versions of Postgres can now support scram-sha-256 hashes, so it may make the most sense to upgrade this function to support this kind of hash for FIPS 140-2 mode users.
Activity
[-]postgres_database fails in FIPS[/-][+]postgres_user fails in FIPS[/+]OrangeDog commentedon Apr 17, 2020
Use of MD5 password hashes isn't FIPS compliant regardless of how you set them.
SCRAM-SHA-256 (#51217) is the only solution.
Akm0d commentedon Apr 17, 2020
@jdshewey Thanks for opening an issue! Can you give me the output of
salt --versions-report? It could help to see the version of the cryptolibrary being usedOrangeDog commentedon Apr 20, 2020
@Akm0d no version of any crypto library will support MD5 in FIPS 140-2 mode.
alexey-zhukovin commentedon Apr 23, 2020
@jdshewey, @OrangeDog am I right that #51217 is fixing this issue?
OrangeDog commentedon Apr 23, 2020
@alexey-zhukovin what do you mean? It's a feature request to support the only FIPS-compliant password hash option that postgres has.
alexey-zhukovin commentedon Apr 23, 2020
@jdshewey
Could you provide steps to reproduce this issue?
And
statefile and command that you used to get this result.sagetherage commentedon Dec 14, 2020
currently, we are not FIPS compliant, but @OrangeDog's PR #59034 will help here and we are looking to get that merged in the Aluminium Release cycle. I will leave this in the backlog for now.
dwoz commentedon Jul 2, 2026
Fix merged and shipped in a supported release. Closing per bulk triage. Reopen if this reproduces on a currently supported release (3006.x, 3007.x, 3008.x, master).