Repository navigation
Conversation
vakwetu
force-pushed
the
fix_md5_for_fips
branch
2 times, most recently
from
November 19, 2021 19:35
da8f49f to
06aac83
Compare
|
The Docs check failure was reported as an issue: #1940 |
Right now, because of a couple of invocations of md5() to generate fingerprints for log messages, paramiko does not work on systems where FIPS mode is enabled. This is because hashlib.md5() fails when FIPS mode is enabled on the kernel. An attribute has been added to hashlib in python 3.9 to allow the use of md5() in non-security contexts. This is because FIPS allows the use of md5() when secret data is not involved - which is exactly the case here. This attribute "usedforsecurity" has been backported to python versions prior to python 3.9 on some distributions. We therefore add a check to confirm whether the attribute is supported, and if so, annotate accordingly to allow the operation to succeed. See https://bugs.python.org/issue9216 for more details.
vakwetu
force-pushed
the
fix_md5_for_fips
branch
from
December 3, 2021 15:36
b717c32 to
76a0369
Compare
openstack-mirroring
pushed a commit
to openstack/openstack
that referenced
this pull request
Jan 25, 2022
* Update tempest from branch 'master'
to 86db21ea6afb6c26a21fc143a7d061e947c31a93
- Patch paramiko
Its not clear how long it will take for paramiko to merge
paramiko/paramiko#1928 to allow paramiko to
work in a FIPS enabled environment.
In the meantime, lets patch paramiko so we can merge our FIPS enabled
gates. When the patch or its equivalent is merged, we can remove this
code.
Change-Id: Ib59647e6aa3dc313ee603ee9d322416179ef615c
openstack-mirroring
pushed a commit
to openstack/tempest
that referenced
this pull request
Jan 25, 2022
Its not clear how long it will take for paramiko to merge paramiko/paramiko#1928 to allow paramiko to work in a FIPS enabled environment. In the meantime, lets patch paramiko so we can merge our FIPS enabled gates. When the patch or its equivalent is merged, we can remove this code. Change-Id: Ib59647e6aa3dc313ee603ee9d322416179ef615c
gouthampacha
reviewed
Mar 8, 2022
gouthampacha
left a comment
There was a problem hiding this comment.
+1 Can this be merged please, so we don't have to resort to monkey patching? :) https://review.opendev.org/c/openstack/manila/+/819375/7/manila/utils.py#74
Contributor
|
Cross-referencing #2189 (comment), making the suggestion that updating the hash algorithm in these spots might be preferable to suppressing the errors about the obsolete MD5. |
rnetser
pushed a commit
to RedHatQE/openshift-virtualization-tests
that referenced
this pull request
Oct 5, 2026
…6430) ##### What this PR does / why we need it: On FIPS-enabled clusters, the `ocp-virt-validation-checkup-rhel9` image uses RHEL 9.8 as base with the system Python interpreter. The system Python links `hashlib` against RHEL's system OpenSSL, which enforces FIPS mode when the cluster has FIPS enabled (`/proc/sys/crypto/fips_enabled = 1`). In FIPS mode, `hashlib.md5()` without `usedforsecurity=False` raises `UnsupportedDigestmodError`, causing all SSH connectivity checks into VMs to fail: ``` Function: rrmngmnt.host.run_command Kwargs: {'command': ['exit'], 'tcp_timeout': 60} Last exception: UnsupportedDigestmodError: [digital envelope routines] unsupported. ``` **Root cause:** `paramiko.pkey.md5` (imported from `hashlib`) is called by: - `PKey.get_fingerprint()` — used for display/logging of host key fingerprints in all host key policies (`AutoAddPolicy`, `RejectPolicy`, `WarningPolicy`) and during SSH client auth - `PKey._read_private_key_pem()` — used for password-protected PEM key decryption CI (Jenkins) uses the `openshift-virtualization-tests:latest` image (Fedora 41 + `uv` standalone Python) which bundles its own OpenSSL that does not inherit the host FIPS policy — hence no failure there. **Upstream status:** Known paramiko bug ([issue #396](paramiko/paramiko#396), open since 2014). Multiple PRs submitted ([#1928](paramiko/paramiko#1928), [#2189](paramiko/paramiko#2189), [#2496](paramiko/paramiko#2496), [#2624](paramiko/paramiko#2624)) — none merged. No fix in `paramiko 5.0.0`. **Fix:** Patch `paramiko.pkey.md5` at import time via `vars()` to use `usedforsecurity=False`. This tells OpenSSL FIPS that the MD5 usage is not for security purposes (fingerprint display/logging only). **Validated on a FIPS-enabled cluster:** `test_clone_from_block_to_fs_using_dv_template` fails without the patch and passes with it on the `ocp-virt-validation-checkup-rhel9` image. ##### Which issue(s) this PR fixes: CNV-98463 ##### Special notes for reviewer: `vars(paramiko.pkey).update(...)` is used instead of direct attribute assignment to avoid mypy `attr-defined`/`method-assign` errors on third-party module patching, without requiring `# type: ignore` (prohibited by AGENTS.md) or a broad `ignore_errors` mypy override. ##### jira-ticket: CNV-98463 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Improved compatibility for automated test runs in FIPS-enabled environments. Application behavior and user-facing functionality are unchanged; this update affects test setup only and does not alter security protections. No new end-user features or other behavior changes are included. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Ramón Lobillo <[email protected]> Co-authored-by: Claude Sonnet 4.6 (1M context) <[email protected]>
ameya-keskar
pushed a commit
to ameya-keskar/openshift-virtualization-tests
that referenced
this pull request
Oct 6, 2026
…edHatQE#6430) ##### What this PR does / why we need it: On FIPS-enabled clusters, the `ocp-virt-validation-checkup-rhel9` image uses RHEL 9.8 as base with the system Python interpreter. The system Python links `hashlib` against RHEL's system OpenSSL, which enforces FIPS mode when the cluster has FIPS enabled (`/proc/sys/crypto/fips_enabled = 1`). In FIPS mode, `hashlib.md5()` without `usedforsecurity=False` raises `UnsupportedDigestmodError`, causing all SSH connectivity checks into VMs to fail: ``` Function: rrmngmnt.host.run_command Kwargs: {'command': ['exit'], 'tcp_timeout': 60} Last exception: UnsupportedDigestmodError: [digital envelope routines] unsupported. ``` **Root cause:** `paramiko.pkey.md5` (imported from `hashlib`) is called by: - `PKey.get_fingerprint()` — used for display/logging of host key fingerprints in all host key policies (`AutoAddPolicy`, `RejectPolicy`, `WarningPolicy`) and during SSH client auth - `PKey._read_private_key_pem()` — used for password-protected PEM key decryption CI (Jenkins) uses the `openshift-virtualization-tests:latest` image (Fedora 41 + `uv` standalone Python) which bundles its own OpenSSL that does not inherit the host FIPS policy — hence no failure there. **Upstream status:** Known paramiko bug ([issue RedHatQE#396](paramiko/paramiko#396), open since 2014). Multiple PRs submitted ([RedHatQE#1928](paramiko/paramiko#1928), [RedHatQE#2189](paramiko/paramiko#2189), [RedHatQE#2496](paramiko/paramiko#2496), [RedHatQE#2624](paramiko/paramiko#2624)) — none merged. No fix in `paramiko 5.0.0`. **Fix:** Patch `paramiko.pkey.md5` at import time via `vars()` to use `usedforsecurity=False`. This tells OpenSSL FIPS that the MD5 usage is not for security purposes (fingerprint display/logging only). **Validated on a FIPS-enabled cluster:** `test_clone_from_block_to_fs_using_dv_template` fails without the patch and passes with it on the `ocp-virt-validation-checkup-rhel9` image. ##### Which issue(s) this PR fixes: CNV-98463 ##### Special notes for reviewer: `vars(paramiko.pkey).update(...)` is used instead of direct attribute assignment to avoid mypy `attr-defined`/`method-assign` errors on third-party module patching, without requiring `# type: ignore` (prohibited by AGENTS.md) or a broad `ignore_errors` mypy override. ##### jira-ticket: CNV-98463 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Improved compatibility for automated test runs in FIPS-enabled environments. Application behavior and user-facing functionality are unchanged; this update affects test setup only and does not alter security protections. No new end-user features or other behavior changes are included. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Ramón Lobillo <[email protected]> Co-authored-by: Claude Sonnet 4.6 (1M context) <[email protected]>
Ahmad-Hafe
pushed a commit
to Ahmad-Hafe/openshift-virtualization-tests
that referenced
this pull request
Oct 8, 2026
…edHatQE#6430) ##### What this PR does / why we need it: On FIPS-enabled clusters, the `ocp-virt-validation-checkup-rhel9` image uses RHEL 9.8 as base with the system Python interpreter. The system Python links `hashlib` against RHEL's system OpenSSL, which enforces FIPS mode when the cluster has FIPS enabled (`/proc/sys/crypto/fips_enabled = 1`). In FIPS mode, `hashlib.md5()` without `usedforsecurity=False` raises `UnsupportedDigestmodError`, causing all SSH connectivity checks into VMs to fail: ``` Function: rrmngmnt.host.run_command Kwargs: {'command': ['exit'], 'tcp_timeout': 60} Last exception: UnsupportedDigestmodError: [digital envelope routines] unsupported. ``` **Root cause:** `paramiko.pkey.md5` (imported from `hashlib`) is called by: - `PKey.get_fingerprint()` — used for display/logging of host key fingerprints in all host key policies (`AutoAddPolicy`, `RejectPolicy`, `WarningPolicy`) and during SSH client auth - `PKey._read_private_key_pem()` — used for password-protected PEM key decryption CI (Jenkins) uses the `openshift-virtualization-tests:latest` image (Fedora 41 + `uv` standalone Python) which bundles its own OpenSSL that does not inherit the host FIPS policy — hence no failure there. **Upstream status:** Known paramiko bug ([issue RedHatQE#396](paramiko/paramiko#396), open since 2014). Multiple PRs submitted ([RedHatQE#1928](paramiko/paramiko#1928), [RedHatQE#2189](paramiko/paramiko#2189), [RedHatQE#2496](paramiko/paramiko#2496), [RedHatQE#2624](paramiko/paramiko#2624)) — none merged. No fix in `paramiko 5.0.0`. **Fix:** Patch `paramiko.pkey.md5` at import time via `vars()` to use `usedforsecurity=False`. This tells OpenSSL FIPS that the MD5 usage is not for security purposes (fingerprint display/logging only). **Validated on a FIPS-enabled cluster:** `test_clone_from_block_to_fs_using_dv_template` fails without the patch and passes with it on the `ocp-virt-validation-checkup-rhel9` image. ##### Which issue(s) this PR fixes: CNV-98463 ##### Special notes for reviewer: `vars(paramiko.pkey).update(...)` is used instead of direct attribute assignment to avoid mypy `attr-defined`/`method-assign` errors on third-party module patching, without requiring `# type: ignore` (prohibited by AGENTS.md) or a broad `ignore_errors` mypy override. ##### jira-ticket: CNV-98463 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Improved compatibility for automated test runs in FIPS-enabled environments. Application behavior and user-facing functionality are unchanged; this update affects test setup only and does not alter security protections. No new end-user features or other behavior changes are included. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Ramón Lobillo <[email protected]> Co-authored-by: Claude Sonnet 4.6 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Right now, because of a couple of invocations of md5() to generate
fingerprints for log messages, paramiko does not work on systems where
FIPS mode is enabled. This is because hashlib.md5() fails when FIPS
mode is enabled on the kernel.
An attribute has been added to hashlib in python 3.9 to allow
the use of md5() in non-security contexts. This is because FIPS allows
the use of md5() when secret data is not involved - which is exactly the
case here.
This attribute "usedforsecurity" has been backported to python versions
prior to python 3.9 on some distributions. We therefore add a check
to confirm whether the attribute is supported, and if so, annotate
accordingly to allow the operation to succeed.
See https://bugs.python.org/issue9216 for more details.