Repository navigation
Add sha256 and sha512 support for key fingerprint calculation - #1103
ioparaskev wants to merge 4 commits into
Conversation
|
ssh-add from OpenSSH-7.4p1 shows auth key fingerprints like so: Just to say, this PR is consistent with that, and thus seems like a generally good idea. But this will likely be deferred to a major release because it's a "breaking" output-format change for the |
|
@ploxiln I agree |
|
Changes made, now it's py2/3 compatible.
|
|
any updates for this? |
|
Would love to see this PR accepted. |
|
I'm not sure why after all these years this is still unmerged but if the reason is backwards compatibility, I think we can figure a way to roll this change (maybe still keeping the md5 as default behaviour?). It's really unfortunate that in 2020 paramiko is still stuck with md5 |
|
I am facing similar issue. can someone help when these changes can be merged? |
|
I would also like to see this merged. We use paramiko at work, and since moving to FIPS this has become a big issue. It looks like discussion about this has been on-going since 2014. |
|
@ioparaskev, looks like there are merge conflicts. I'm not sure if that's what's standing in the way, but do you have time to fix those? I'd take a whack at it but I don't have a great way to test at the moment. |
|
@avidspartan1 I'm not sure since I never got any feedback on why this can't be merged. P.S:
|
- Adds methods `get_sha256_fingerprint`, `get_sha512_fingerprint`, `get_md5_fingerprint` to support different algorithms for calculating key fingerprint. sha1 fingerprint calculation is not added due to recent practical collision findings while md5 is still provided for backwards compatibility. - Adds method `get_available_fingerprint_methods` that returns a dictionary of availabe hash algorithms and their corresponding callbacks. - Method `get_fingerprint` now supports an optional `algorithm` parameter to specify the preferred algorithm that will be used for the fingerprint calculation. If the algorithm is not supported or not given, it falls back to md5. - This commit acts as a backwards compatibility step with a future projection of changing the default behaviour to return a sha256 base64-trimmed digest instead of md5 digest. This allows better collision resistance. For more info about fast collision attacks on MD5 check the paper "Fast Collision Attack on MD5" by Tao Xie1, Fanbao Liu, Dengguo Feng. sha256 is also the default behavior of OpenSSH since version 6.8
Co-authored-by: Mateusz Stompór <[email protected]>
Co-authored-by: Mateusz Stompór <[email protected]>
Co-authored-by: MrMino <[email protected]>
|
Really need this PR merged for so that FIPS is supported. It's 2020, we shouldn't only be be using MD5 |
|
This may be a bit of scope creep for this bug. But it would be very nice if the default AutoAddPolicy and AutoReject were also updated to use these new fingerprints by default, and fall back to md5 only if sha is not available In addition to updating pkey with additional algorithms, may I also suggest sometime in the future the paramiko https://github.com/paramiko/paramiko/blob/master/paramiko/client.py#L805 |
|
Bump? Also – what about using a fingerprint as a host key. That doesn't seem possible today. A StackOverflow answer suggests using a custom |
|
Is there a view of when this PR will be merged? |
|
When? |
|
Hello! Any news on this PR please? |
|
@alex Would you be willing to merge this PR if the author resolved the merge conflicts? |
In fips mode, we fail with:
File "/usr/lib/python3.6/site-packages/otopi/context.py", line 132, in _executeMethod
method['method']()
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-setup/ovirt-engine-dwh/core/remote_engine.py", line 83, in _remote_engine_customization
oenginecons.ConfigEnv.ENGINE_FQDN
File "/usr/share/ovirt-engine/setup/ovirt_engine_setup/remote_engine.py", line 146, in configure
self._style.configure(fqdn=fqdn)
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-common/base/remote_engine/remote_engine_root_ssh.py", line 177, in configure
self._ssh_connect()
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-common/base/remote_engine/remote_engine_root_ssh.py", line 153, in _ssh_connect
osetupcons.ConfigEnv.REMOTE_ENGINE_HOST_CLIENT_KEY
File "/usr/lib/python3.6/site-packages/paramiko/client.py", line 416, in connect
self, server_hostkey_name, server_key
File "/usr/lib/python3.6/site-packages/paramiko/client.py", line 837, in missing_host_key
key.get_name(), hostname, hexlify(key.get_fingerprint())
File "/usr/lib/python3.6/site-packages/paramiko/pkey.py", line 180, in get_fingerprint
return md5(self.asbytes()).digest()
This is because we use paramiko.WarningPolicy, which uses
get_fingerprint to show the missing key, which uses hashlib.md5 [1],
which is disabled in fips mode.
Create our own policy instead, that does not show the key.
Please note that this isn't a complete fix for [1] - e.g. if you have
any keys in normal locations, such as ~/.ssh/id_rsa, paramiko will fail
later, when mentioning that it's going to try loading them.
[1] paramiko/paramiko#1103
Change-Id: I99a934ceefc707cdff127229d1bebf196aac4140
Signed-off-by: Yedidyah Bar David <[email protected]>
In fips mode, we fail with:
File "/usr/lib/python3.6/site-packages/otopi/context.py", line 132, in _executeMethod
method['method']()
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-setup/ovirt-engine-dwh/core/remote_engine.py", line 83, in _remote_engine_customization
oenginecons.ConfigEnv.ENGINE_FQDN
File "/usr/share/ovirt-engine/setup/ovirt_engine_setup/remote_engine.py", line 146, in configure
self._style.configure(fqdn=fqdn)
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-common/base/remote_engine/remote_engine_root_ssh.py", line 177, in configure
self._ssh_connect()
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-common/base/remote_engine/remote_engine_root_ssh.py", line 153, in _ssh_connect
osetupcons.ConfigEnv.REMOTE_ENGINE_HOST_CLIENT_KEY
File "/usr/lib/python3.6/site-packages/paramiko/client.py", line 416, in connect
self, server_hostkey_name, server_key
File "/usr/lib/python3.6/site-packages/paramiko/client.py", line 837, in missing_host_key
key.get_name(), hostname, hexlify(key.get_fingerprint())
File "/usr/lib/python3.6/site-packages/paramiko/pkey.py", line 180, in get_fingerprint
return md5(self.asbytes()).digest()
This is because we use paramiko.WarningPolicy, which uses
get_fingerprint to show the missing key, which uses hashlib.md5 [1],
which is disabled in fips mode.
Create our own policy instead, that does not show the key.
Please note that this isn't a complete fix for [1] - e.g. if you have
any keys in normal locations, such as ~/.ssh/id_rsa, paramiko will fail
later, when mentioning that it's going to try loading them.
[1] paramiko/paramiko#1103
Change-Id: I99a934ceefc707cdff127229d1bebf196aac4140
Signed-off-by: Yedidyah Bar David <[email protected]>
In fips mode, we fail with:
File "/usr/lib/python3.6/site-packages/otopi/context.py", line 132, in _executeMethod
method['method']()
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-setup/ovirt-engine-dwh/core/remote_engine.py", line 83, in _remote_engine_customization
oenginecons.ConfigEnv.ENGINE_FQDN
File "/usr/share/ovirt-engine/setup/ovirt_engine_setup/remote_engine.py", line 146, in configure
self._style.configure(fqdn=fqdn)
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-common/base/remote_engine/remote_engine_root_ssh.py", line 177, in configure
self._ssh_connect()
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-common/base/remote_engine/remote_engine_root_ssh.py", line 153, in _ssh_connect
osetupcons.ConfigEnv.REMOTE_ENGINE_HOST_CLIENT_KEY
File "/usr/lib/python3.6/site-packages/paramiko/client.py", line 416, in connect
self, server_hostkey_name, server_key
File "/usr/lib/python3.6/site-packages/paramiko/client.py", line 837, in missing_host_key
key.get_name(), hostname, hexlify(key.get_fingerprint())
File "/usr/lib/python3.6/site-packages/paramiko/pkey.py", line 180, in get_fingerprint
return md5(self.asbytes()).digest()
This is because we use paramiko.WarningPolicy, which uses
get_fingerprint to show the missing key, which uses hashlib.md5 [1],
which is disabled in fips mode.
Create our own policy instead, that does not show the key.
Please note that this isn't a complete fix for [1] - e.g. if you have
any keys in normal locations, such as ~/.ssh/id_rsa, paramiko will fail
later, when mentioning that it's going to try loading them.
[1] paramiko/paramiko#1103
Change-Id: I99a934ceefc707cdff127229d1bebf196aac4140
Signed-off-by: Yedidyah Bar David <[email protected]>
In fips mode, we fail with:
File "/usr/lib/python3.6/site-packages/otopi/context.py", line 132, in _executeMethod
method['method']()
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-setup/ovirt-engine-dwh/core/remote_engine.py", line 83, in _remote_engine_customization
oenginecons.ConfigEnv.ENGINE_FQDN
File "/usr/share/ovirt-engine/setup/ovirt_engine_setup/remote_engine.py", line 146, in configure
self._style.configure(fqdn=fqdn)
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-common/base/remote_engine/remote_engine_root_ssh.py", line 177, in configure
self._ssh_connect()
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-common/base/remote_engine/remote_engine_root_ssh.py", line 153, in _ssh_connect
osetupcons.ConfigEnv.REMOTE_ENGINE_HOST_CLIENT_KEY
File "/usr/lib/python3.6/site-packages/paramiko/client.py", line 416, in connect
self, server_hostkey_name, server_key
File "/usr/lib/python3.6/site-packages/paramiko/client.py", line 837, in missing_host_key
key.get_name(), hostname, hexlify(key.get_fingerprint())
File "/usr/lib/python3.6/site-packages/paramiko/pkey.py", line 180, in get_fingerprint
return md5(self.asbytes()).digest()
This is because we use paramiko.WarningPolicy, which uses
get_fingerprint to show the missing key, which uses hashlib.md5 [1],
which is disabled in fips mode.
Create our own policy instead, that does not show the key.
Please note that this isn't a complete fix for [1] - e.g. if you have
any keys in normal locations, such as ~/.ssh/id_rsa, paramiko will fail
later, when mentioning that it's going to try loading them.
[1] paramiko/paramiko#1103
Change-Id: I99a934ceefc707cdff127229d1bebf196aac4140
Signed-off-by: Yedidyah Bar David <[email protected]>
In fips mode, we fail with:
File "/usr/lib/python3.6/site-packages/otopi/context.py", line 132, in _executeMethod
method['method']()
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-setup/ovirt-engine-dwh/core/remote_engine.py", line 83, in _remote_engine_customization
oenginecons.ConfigEnv.ENGINE_FQDN
File "/usr/share/ovirt-engine/setup/ovirt_engine_setup/remote_engine.py", line 146, in configure
self._style.configure(fqdn=fqdn)
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-common/base/remote_engine/remote_engine_root_ssh.py", line 177, in configure
self._ssh_connect()
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-common/base/remote_engine/remote_engine_root_ssh.py", line 153, in _ssh_connect
osetupcons.ConfigEnv.REMOTE_ENGINE_HOST_CLIENT_KEY
File "/usr/lib/python3.6/site-packages/paramiko/client.py", line 416, in connect
self, server_hostkey_name, server_key
File "/usr/lib/python3.6/site-packages/paramiko/client.py", line 837, in missing_host_key
key.get_name(), hostname, hexlify(key.get_fingerprint())
File "/usr/lib/python3.6/site-packages/paramiko/pkey.py", line 180, in get_fingerprint
return md5(self.asbytes()).digest()
This is because we use paramiko.WarningPolicy, which uses
get_fingerprint to show the missing key, which uses hashlib.md5 [1],
which is disabled in fips mode.
Create our own policy instead, that does not show the key.
Please note that this isn't a complete fix for [1] - e.g. if you have
any keys in normal locations, such as ~/.ssh/id_rsa, paramiko will fail
later, when mentioning that it's going to try loading them.
[1] paramiko/paramiko#1103
Change-Id: I99a934ceefc707cdff127229d1bebf196aac4140
Signed-off-by: Yedidyah Bar David <[email protected]>
In fips mode, we fail with:
File "/usr/lib/python3.6/site-packages/otopi/context.py", line 132, in _executeMethod
method['method']()
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-setup/ovirt-engine-dwh/core/remote_engine.py", line 83, in _remote_engine_customization
oenginecons.ConfigEnv.ENGINE_FQDN
File "/usr/share/ovirt-engine/setup/ovirt_engine_setup/remote_engine.py", line 146, in configure
self._style.configure(fqdn=fqdn)
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-common/base/remote_engine/remote_engine_root_ssh.py", line 177, in configure
self._ssh_connect()
File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-common/base/remote_engine/remote_engine_root_ssh.py", line 153, in _ssh_connect
osetupcons.ConfigEnv.REMOTE_ENGINE_HOST_CLIENT_KEY
File "/usr/lib/python3.6/site-packages/paramiko/client.py", line 416, in connect
self, server_hostkey_name, server_key
File "/usr/lib/python3.6/site-packages/paramiko/client.py", line 837, in missing_host_key
key.get_name(), hostname, hexlify(key.get_fingerprint())
File "/usr/lib/python3.6/site-packages/paramiko/pkey.py", line 180, in get_fingerprint
return md5(self.asbytes()).digest()
This is because we use paramiko.WarningPolicy, which uses
get_fingerprint to show the missing key, which uses hashlib.md5 [1],
which is disabled in fips mode.
Create our own policy instead, that does not show the key.
Please note that this isn't a complete fix for [1] - e.g. if you have
any keys in normal locations, such as ~/.ssh/id_rsa, paramiko will fail
later, when mentioning that it's going to try loading them.
[1] paramiko/paramiko#1103
Change-Id: I99a934ceefc707cdff127229d1bebf196aac4140
Signed-off-by: Yedidyah Bar David <[email protected]>
|
I'm not deeply familiar with the code here, but per xxx it looks like paramiko 3.2 introduced a I figure the changes in this PR will need to be adapted to this new code... it seems likely that either (i) the existing code will need to be converted to a method, so that the desired fingerprint type can be passed as an argument, or (ii) multiple properties will need to be created, one for each desired fingerprint type. I'm not sure how bitprophet will want to resolve this. I've flagged it for his policy decision. |
Hello - it's been over a year without a decision - @bskinn is there any way this could progress? |
|
I haven't seen any roadmap plans on integrating this functionality so I'm not extremely enthusiastic on refactoring and syncing the PR so that it can sit waiting for another 4+ years tbh |
I rather wanted to get an insight from the repository maintainers - but thanks for replying! |
In order for n-g-s to be able to run on a node in FIPS enforcing mode, it *must* not use md5. However, paramiko's code has a get_fingerprint call where it is fingerprinting data for the exchange to identify a difference, which can use any algorithm realistically. Anyhow, this is necessary because it appears that paramiko's maintainer is not really interested in fixing the md5 usage. As a result, we're forced to monkeypatch paramiko, which is loaded by netmiko, which is what NGS uses. This should be fixed in paramiko, but also it seems several changes been proposed without forward movement. https: //github.com/paramiko/paramiko/pull/688 https: //github.com/paramiko/paramiko/pull/1103 https: //github.com/paramiko/paramiko/pull/2189 https: //github.com/paramiko/paramiko/pull/2496 https: //github.com/paramiko/paramiko/issues/2383 https: //github.com/paramiko/paramiko/issues/396 Related-Bug: 2098819 Change-Id: Ia3fb9d2baa14be1726197d1115e92adc9ce5ce0a
* Update networking-generic-switch from branch 'master'
to b351b9136d569b02c8b94df3e52fdd10038df3c4
- Merge "don't use paramiko's get_fingerprint (md5)"
- don't use paramiko's get_fingerprint (md5)
In order for n-g-s to be able to run on a node in FIPS enforcing mode,
it *must* not use md5. However, paramiko's code has a get_fingerprint
call where it is fingerprinting data for the exchange to identify
a difference, which can use any algorithm realistically.
Anyhow, this is necessary because it appears that paramiko's maintainer
is not really interested in fixing the md5 usage. As a result, we're
forced to monkeypatch paramiko, which is loaded by netmiko, which is
what NGS uses.
This should be fixed in paramiko, but also it seems several changes
been proposed without forward movement.
https: //github.com/paramiko/paramiko/pull/688
https: //github.com/paramiko/paramiko/pull/1103
https: //github.com/paramiko/paramiko/pull/2189
https: //github.com/paramiko/paramiko/pull/2496
https: //github.com/paramiko/paramiko/issues/2383
https: //github.com/paramiko/paramiko/issues/396
Related-Bug: 2098819
Change-Id: Ia3fb9d2baa14be1726197d1115e92adc9ce5ce0a
get_sha256_fingerprint,get_sha512_fingerprint,get_md5_fingerprintto support different algorithms for calculatingkey fingerprint. sha1 fingerprint calculation is not added due to recent
practical collision findings while md5 is still provided for backwards
compatibility.
get_available_fingerprint_methodsthat returns adictionary of availabe hash algorithms and their corresponding
callbacks.
get_fingerprintnow supports an optionalalgorithmparameter to specify the preferred algorithm that will be used for the
fingerprint calculation. If the algorithm is not supported or not given,
it falls back to md5.
projection of changing the default behaviour to return a sha256
base64-trimmed digest instead of md5 digest. This allows better collision
resistance. For more info about fast collision attacks on MD5 check
the paper "Fast Collision Attack on MD5" by Tao Xie1, Fanbao Liu,
Dengguo Feng. sha256 is also the default behavior of OpenSSH since version
6.8