salt icon indicating copy to clipboard operation
salt copied to clipboard

postgres_user fails in FIPS

Open jdshewey opened this issue 6 years ago • 8 comments

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.

jdshewey avatar Apr 16 '20 21:04 jdshewey

Use of MD5 password hashes isn't FIPS compliant regardless of how you set them. SCRAM-SHA-256 (#51217) is the only solution.

OrangeDog avatar Apr 17 '20 08:04 OrangeDog

@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 used

Akm0d avatar Apr 17 '20 19:04 Akm0d

@Akm0d no version of any crypto library will support MD5 in FIPS 140-2 mode.

OrangeDog avatar Apr 20 '20 09:04 OrangeDog

@jdshewey, @OrangeDog am I right that #51217 is fixing this issue?

alexey-zhukovin avatar Apr 23 '20 15:04 alexey-zhukovin

@alexey-zhukovin what do you mean? It's a feature request to support the only FIPS-compliant password hash option that postgres has.

OrangeDog avatar Apr 23 '20 16:04 OrangeDog

@jdshewey Could you provide steps to reproduce this issue? And state file and command that you used to get this result.

alexey-zhukovin avatar Apr 23 '20 16:04 alexey-zhukovin

currently, we are not FIPS compliant, but @OrangeDog's PR https://github.com/saltstack/salt/pull/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.

sagetherage avatar Dec 14 '20 21:12 sagetherage

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).

dwoz avatar Jul 02 '26 08:07 dwoz