Skip to content

[BUG] - Use of MD5 algorithm in FIPs system #2383

Closed

Description

@jose-pr

Are you using paramiko as a client or server?

Client

What feature(s) aren't working right?

SSH, SFTP, Keys/auth, known_hosts

What version(s) of paramiko are you using?

3.4

What version(s) of Python are you using?

3.11

What operating system and version are you using?

Rocky 9

If you're connecting as a client, which SSH server are you connecting to?

No response

If you're using paramiko as part of another tool, which tool/version?

No response

Expected/desired behavior

Being able to open a ssh connection.

Actual behavior

When using a systems with FIPS enabled md5 hash will fail.
In my case i couldn't even open a connection because of PKey when using key auth or when adding a new host. Due to its use in the
debug log

        client._log(
            DEBUG,
            "Adding {} host key for {}: {}".format(
                key.get_name(), hostname, hexlify(key.get_fingerprint())
            ),
        )

return md5(self.asbytes()).digest()

How to reproduce

No response

Anything else?

Not use md5, not sure if sha1 would also be problematic with FIP. At least not depend on hashlib with depends on openssl which will fail.
Maybe use sha256 instead?

Activity

  1. mopi3456 commented on Feb 10, 2025

    @mopi3456

    I have patched my local version as follows, seems to be working

    paramiko]$ diff pkey.py pkey.orig
    28,33c28
    < # from hashlib import sha256
    < #
    < import hashlib
    < import sys
    < from functools import partial
    < #
    ---
    > from hashlib import md5, sha256
    67,71d61
    < if sys.version_info >= (3, 8):
    <     md5 = partial(hashlib.md5, usedforsecurity=False)
    < else:
    <     md5 = hashlib.md5
    <
    967a958
    >
    
  2. added a commit that references this issue on Feb 10, 2025
  3. steveb commented on Feb 10, 2025

    @steveb

    Thanks @mopi3456 I turned this comment into a PR. This is the standard approach for flagging MD5 usage as not security critical, for example pytest: https://github.com/pytest-dev/pytest-randomly/pull/415/files#diff-77e4b024fe5132833f7d62b9ffc8028a856311e1a3afbb81f5715efc2bea28b9R1-R8

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions