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 FIPS mode detection #1754

Merged
merged 1 commit into from
Aug 9, 2022
Merged

Fix FIPS mode detection #1754

merged 1 commit into from
Aug 9, 2022

Conversation

stanhu
Copy link
Contributor

@stanhu stanhu commented Jun 29, 2022

Description

Previously FIPS detection relied on the OpenSSL::OPENSSL_FIPS
constant being defined. However, on RedHat operating systems, this
constant is always defined in
/usr/include/openssl/opensslconf-x86_64.h. As a result, on such
operating systems FIPS mode would erroneously be labeled as enabled.
This constant is a necessary but not sufficient condition to determine
whether FIPS is actually enabled.

OpenSSL has a runtime fips_mode check
(https://wiki.openssl.org/index.php/FIPS_mode()) that should be used
instead. Ruby will use this if the OPENSSL_FIPS compile-time
constant is available:
https://github.com/ruby/ruby/blob/685efac05983dee44ce2d96c24f2fcb96a0aebe2/ext/openssl/ossl.c#L413-L428

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

@stanhu stanhu requested review from a team as code owners June 29, 2022 15:45
@stanhu stanhu force-pushed the sh-fix-fips-mode-check branch from 9d26dc5 to cd3bbaf Compare June 29, 2022 15:46
@@ -30,6 +30,6 @@
fips Mash.new

require "openssl" unless defined?(OpenSSL)
fips["kernel"] = { "enabled" => OpenSSL::OPENSSL_FIPS }
fips["kernel"] = { "enabled" => OpenSSL.fips_mode }
Copy link
Contributor Author

@stanhu stanhu Jun 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see this was reverted in ab6180b. OpenSSL v3.0 may not have fips_mode: https://wiki.openssl.org/index.php/OpenSSL_3.0

Previously FIPS detection relied on the `OpenSSL::OPENSSL_FIPS`
constant being defined. However, on RedHat operating systems, this
constant is always defined in
`/usr/include/openssl/opensslconf-x86_64.h`. As a result, on such
operating systems FIPS mode would erroneously be labeled as enabled.
This constant is a necessary but not sufficient condition to determine
whether FIPS is actually enabled.

OpenSSL has a runtime `fips_mode` check
(https://wiki.openssl.org/index.php/FIPS_mode()) that should be used
instead. Ruby will use this if the `OPENSSL_FIPS` compile-time
constant is available:
https://github.com/ruby/ruby/blob/685efac05983dee44ce2d96c24f2fcb96a0aebe2/ext/openssl/ossl.c#L413-L428

Signed-off-by: Stan Hu <[email protected]>
@stanhu stanhu force-pushed the sh-fix-fips-mode-check branch from cd3bbaf to 754de96 Compare July 5, 2022 20:20
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 5, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Collaborator

@jaymzh jaymzh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. We ship with our own OpenSSL, so this should be fine.

@stanhu
Copy link
Contributor Author

stanhu commented Jul 27, 2022

Thanks @jaymzh. What's left to merge this?

@jaymzh jaymzh merged commit 5bc0ddb into chef:main Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants