Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix python crypt module to work with FIPS #3955

Merged
merged 1 commit into from
Oct 10, 2022

Conversation

dmcilvaney
Copy link
Contributor

@dmcilvaney dmcilvaney commented Oct 7, 2022

Merge Checklist

All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)

  • The toolchain has been rebuilt successfully (or no changes were made to it)
  • The toolchain/worker package manifests are up-to-date
  • Any updated packages successfully build (or no packages were changed)
  • Packages depending on static components modified in this PR (Golang, *-static subpackages, etc.) have had their Release tag incremented.
  • Package tests (%check section) have been verified with RUN_CHECK=y for existing SPEC files, or added to new SPEC files
  • All package sources are available
  • cgmanifest files are up-to-date and sorted (./cgmanifest.json, ./toolkit/tools/cgmanifest.json, ./toolkit/scripts/toolchain/cgmanifest.json, .github/workflows/cgmanifest.json)
  • LICENSE-MAP files are up-to-date (./SPECS/LICENSES-AND-NOTICES/data/licenses.json, ./SPECS/LICENSES-AND-NOTICES/LICENSES-MAP.md, ./SPECS/LICENSES-AND-NOTICES/LICENSE-EXCEPTIONS.PHOTON)
  • All source files have up-to-date hashes in the *.signatures.json files
  • sudo make go-tidy-all and sudo make go-test-coverage pass
  • Documentation has been updated to match any changes to the build system
  • Ready to merge

Summary

When booting a FIPS system using the Azure cloud-init module it would fail to run. The failure was caused by calling import crypt here: https://github.com/canonical/cloud-init/blob/cd2cca35a1bf36b584422f431c3ddf55b820434c/cloudinit/sources/DataSourceAzure.py#L8

When a system is running in FIPS mode, glibc's crypt library will detect this and limit the hashing algorithms it makes available. Python's crypt module wraps this glibc library, and when loaded with import crypt it queries the underlying library for the available algorithms. When in FIPS mode the library returns an error code for md5 since it is not a valid FIPS algorithm.

A check was added in Python3.9 (python/cpython#16599) to validate the return codes from the glibc library, but it did not consider the different error codes a disabled algorithm would return vs. a missing one.

A recent patch (python/cpython#94742) was added to also handle the error codes generated for the disabled case but was not backported beyond 3.10.

Change Log
Does this affect the toolchain?

YES

Test Methodology
  • Local build in progress
  • Test on live system by directly modifying the python sources

@dmcilvaney dmcilvaney requested a review from a team as a code owner October 7, 2022 23:51
@ghost ghost added the main PR Destined for main label Oct 7, 2022
@dmcilvaney dmcilvaney merged commit 313bd70 into microsoft:main Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
main PR Destined for main
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants