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

Support for FIPS compliance mode #14912

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

beanuwave
Copy link
Contributor

@beanuwave beanuwave commented Jul 23, 2024

Description

This PR makes FIPS mode available through the OPENSEARCH_CRYPTO_STANDARD=FIPS-140-3 environmental parameter instead of the tests.fips.enabled setting. It provides FIPS 140-3 support by replacing all BC dependencies with BCFIPS dependencies and making FIPS approved-only mode configurable at launch. Running this mode restricts the BCFIPS provider to rely solely on FIPS-certified ciphers.

  • The fips.gradle build script is removed in order to support a single-build solution.
  • All BC dependencies are replaced by BCFIPS.
  • Fixed creation of password protected internal keystore for valuable settings at node start. The add-string command was made with additional --stdin option, which interferes with password input.
  • The Password Matcher inside Identity-Shiro that relies on BC to check if hashed passwords match with OpenBSDBCrypt is replaced by the password4j implementation.
  • Adds full support for the BCFKS format (*.bcfks) for key and trust stores, also making it the default.
  • KeyStore instantiation was added to forbidden-apis in favour of KeyStoreFactory.
  • Google's truststore is converted to the BCFKS format.
  • Makes the best guess of which store type is provided based on the filename extension.
  • Store types are strictly limited to JKS, PKCS12, PKCS11, and BCFKS.
  • Refactors PemUtils to parse private keys in formats EC, PKCS8, PKCS1, and DSA, with or without encryption, and with or without parameters.
  • dependency ':libs:opensearch-common' was added to rest-client build, to support strict keystore types. It's also the reason for JVM bump JAVA8 to JAVA11.
  • allow ingest-attachment plugin to run in FIPS mode, since BC dependencies find no use.
  • The java.security file is added to the build to distinguish between FIPS and non-FIPS environments.
  • The fips_java.security file is altered due to evolving security standards.
  • The security.policy file is altered to grant necessary security permissions.
  • Increased security standards in KeyTabs and algorithms for Kerberos.
  • SecureRandom gets instantiated in to different way, depending on if it runs with FIPS or not.
  • Uninstalls SunJCE provider from security providers list at runtime when FIPS mode is enabled.

Runtime limitations (known so far) that come with enabling FIPS mode:

Admins can continue to manage their systems without being impacted by this change. However, for those keen on FIPS compliance, the most common obstacle will likely be the requirement to set a stronger password for the internal keystore and also convert key and truststores to *.bcfks format.

  • Does not allow empty passwords for keystores or private keys (they need to be at least 112 bits in strength).
  • The ssl.verification_mode=NONE setting is not permitted.
  • JKS and PKCS12 key and trust store types are not supported at all.
  • The internal keystore cannot be auto-migrated from versions 1 or 2.
  • Azure Classic Discovery plugin -> deprecated.
  • SQL-CLI client.
  • HDFS plugin won't connect since it's using RC4 cipher for token authentication.

Reasons for refactoring PemUtils, which is used by the Reindex API in cases of migrating data from a remote cluster that is TLS protected:

  • Lack of support for evolving standards like PKCS#8.
  • Password-Based Key Derivation Functions such as PBKDF-OPENSSL are not supported in FIPS mode in favor of the PBKDF2 standard.
  • Java type safety.
  • It is generally a good idea to let ASN1 annotation parsing be done by external security libraries.

Related Issues

opensearch-project/security#3420

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Contributor

❌ Gradle check result for 6016d5d: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@beanuwave beanuwave changed the title Draft to allow run in FIPS compliace mode Draft to allow run in FIPS compliance mode Jul 24, 2024
Copy link
Contributor

❌ Gradle check result for 8e8ed47: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for 6016d5d: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@dblock
Copy link
Member

dblock commented Jul 24, 2024

Could use some help maybe from @cwperks or @peternied reviewing this, please.

@beanuwave
Copy link
Contributor Author

@reta I would also appreciate multiple smaller commits so that they are easier to review. The reason I found it difficult with the modular approach is that the project already had BC dependencies in multiple modules. Unfortunately, the process of replacing old BC with FIPS counterparts cannot be split because they cannot coexist on the classpath at the same time.

@cwperks The build fails on SimpleSecureNetty4TransportTests due to a race condition. Despite minimizing randomness and tweaking various cluster/node transport settings, I still cannot pinpoint the cause of the closed connection and handshake issues. Any help would be greatly appreciated.

@kkhatua kkhatua added the v3.0.0 Issues and PRs related to version 3.0.0 label Feb 7, 2025
@reta
Copy link
Collaborator

reta commented Feb 7, 2025

@reta I would also appreciate multiple smaller commits so that they are easier to review. The reason I found it difficult with the modular approach is that the project already had BC dependencies in multiple modules. Unfortunately, the process of replacing old BC with FIPS counterparts cannot be split because they cannot coexist on the classpath at the same time.

Thank you @beanuwave, I think we could clearly start with build tools and removing deprecated / not used settings (as I suggested) - it does not have any dependencies on FIPS but will shave off 20-30 files immediately. The other pieces will follow, at least I don't see the blockers there, but certainly some work.

@cwperks
Copy link
Member

cwperks commented Feb 12, 2025

@cwperks The build fails on SimpleSecureNetty4TransportTests due to a race condition. Despite minimizing randomness and tweaking various cluster/node transport settings, I still cannot pinpoint the cause of the closed connection and handshake issues. Any help would be greatly appreciated.

I once encountered a similar thread leak failure on #16778, but not sure how to resolve the failure seen in SimpleSecureNetty4TransportTests.testFailToSend. It passes when I run the test locally or on my dev desktop, but fails consistently in the jenkins runner.

Signed-off-by: Iwan Igonin <[email protected]>

# Conflicts:
#	server/build.gradle

# Conflicts:
#	server/build.gradle

# Conflicts:
#	server/build.gradle
Signed-off-by: Iwan Igonin <[email protected]>

# Conflicts:
#	buildSrc/version.properties
Signed-off-by: Iwan Igonin <[email protected]>
…Pattern

Signed-off-by: Iwan Igonin <[email protected]>

# Conflicts:
#	CHANGELOG-3.0.md
Summery:
- replace unsecure kerberos crypto algorithms
- add 'java.security.KeyStore' to forbidden-apis
- instantiate and use SecureRandom from BCFIPS library
- exclude SunJCE from security providers list at runtime, when running in FIPS JVM
- exclude Azure tests when running in FIPS JVM

Signed-off-by: Iwan Igonin <[email protected]>
Copy link
Contributor

❌ Gradle check result for 96524cf: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for 1e6ae86: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3.0.0 Issues and PRs related to version 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.