Skip to content

postgres_user fails in FIPS #56673

Closed
Closed

Description

@jdshewey

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

  1. changed the title [-]postgres_database fails in FIPS[/-] [+]postgres_user fails in FIPS[/+] on Apr 16, 2020
  2. OrangeDog commented on Apr 17, 2020

    @OrangeDog
    Contributor

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

  3. added
    needs-more-info
    on Apr 17, 2020
  4. Akm0d commented on Apr 17, 2020

    @Akm0d
    Contributor

    @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

  5. OrangeDog commented on Apr 20, 2020

    @OrangeDog
    Contributor

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

  6. alexey-zhukovin commented on Apr 23, 2020

    @alexey-zhukovin
    Contributor

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

  7. OrangeDog commented on Apr 23, 2020

    @OrangeDog
    Contributor

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

  8. added
    bug
    on Apr 23, 2020
  9. alexey-zhukovin commented on Apr 23, 2020

    @alexey-zhukovin
    Contributor

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

  10. added this to the Blocked milestone on Apr 27, 2020
  11. sagetherage commented on Dec 14, 2020

    @sagetherage
    Contributor

    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.

  12. dwoz commented on Jul 2, 2026

    @dwoz
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-more-info

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions