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

Use BC libraries to parse PEM files, increase key length, allow gener… #17393

Merged

Conversation

beanuwave
Copy link
Contributor

NOTE: Basically a split up from the original PR

Description

This PR should provide a smoother transition to FIPS 140 standard by eliminating deprecated code, increase security standards and use more standardized approach to parse key files.

  • Refactors PemUtils to parse private keys in formats EC, PKCS8, PKCS1, and DSA, with or without encryption, and with or without parameters.
  • Elevate exclusion for cryptographic binaries from sub-modules to project level.
  • Increase key size for google cloud storage.
  • Increased security standards in KeyTabs and algorithms for Kerberos.
  • Remove unused BC libraries from ingest-attachment plugin.
  • Use KeyStoreUtils to create a keystore at runtime with default certificates to be used in tests.

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 62d1786: 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 force-pushed the reevaluate_security_settings branch from 62d1786 to 99b1e83 Compare February 19, 2025 14:24
Copy link
Contributor

❌ Gradle check result for 99b1e83: 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 force-pushed the reevaluate_security_settings branch from 99b1e83 to ac4fa36 Compare February 19, 2025 14:53
Copy link
Contributor

❌ Gradle check result for ac4fa36: 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 force-pushed the reevaluate_security_settings branch from ac4fa36 to 7a837ea Compare February 19, 2025 15:26
Copy link
Contributor

❌ Gradle check result for 7a837ea: 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 force-pushed the reevaluate_security_settings branch from 7a837ea to bd18542 Compare February 19, 2025 16:17
Copy link
Contributor

✅ Gradle check result for bd18542: SUCCESS

Copy link

codecov bot commented Feb 19, 2025

Codecov Report

Attention: Patch coverage is 84.48276% with 9 lines in your changes missing coverage. Please review.

Project coverage is 72.36%. Comparing base (e397903) to head (d4a2bba).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...opensearch/gradle/testclusters/OpenSearchNode.java 0.00% 5 Missing ⚠️
.../main/java/org/opensearch/common/ssl/PemUtils.java 93.02% 2 Missing and 1 partial ⚠️
.../opensearch/common/ssl/SslConfigurationLoader.java 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #17393      +/-   ##
============================================
- Coverage     72.47%   72.36%   -0.11%     
+ Complexity    65693    65636      -57     
============================================
  Files          5304     5304              
  Lines        304981   304744     -237     
  Branches      44238    44190      -48     
============================================
- Hits         221033   220531     -502     
- Misses        65808    66192     +384     
+ Partials      18140    18021     -119     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@cwperks cwperks left a comment

Choose a reason for hiding this comment

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

Thank you for splitting up the PR @beanuwave. I think this is much easier to review at half the number of files of the first PR. @reta when you have some time could you also take a look?

@reta
Copy link
Collaborator

reta commented Feb 22, 2025

Thank you for splitting up the PR @beanuwave. I think this is much easier to review at half the number of files for the first PR. @reta when you have some time could you also take a look?

Indeed, thank you @beanuwave , I is much easier to reason about the change and it looks good to me. Overall, I would like to highlight only once concern here, we are bringing Bouncycastle to core (but to generalize - the whole ecosystem including clients, plugins, extensions, ....) as hard, non optional dependency (as for this change, through libs/opensearch-ssl-config). Is it a good or bad thing? I don't know to be honest, but most (if not all) projects I am aware of do not enforce that (netty is one of those). @andrross @cwperks I think it is up to us to decide is it a way to go.

PS: We've already discussed the same concern on the original pull request #14912

@andrross
Copy link
Member

we are bringing Bouncycastle to core (but to generalize - the whole ecosystem including clients, plugins, extensions, ....) as hard, non optional dependency (as for this change, through libs/opensearch-ssl-config). Is it a good or bad thing? I don't know to be honest, but most (if not all) projects I am aware of do not enforce that (netty is one of those).

@reta @cwperks I also don't know the right answer here, but my intuition is that it is probably okay to introduce this dependency. Going through your list of things in the ecosystem: Clients - I think this mainly means the Java high level REST client. I think we need to continue the work to move to opensearch-java where it has no dependency on the server. Plugins - they are already tightly coupled to the server (the run in the same JVM). Bringing this new transitive dependency doesn't seem too problematic to me. Extensions - the long-term goal of extensions should decouple it from the server implementation (including dependencies), but we're a long way from that being real so I don't see this as a show stopper either.

My overall thought is that OpenSearch is not a general purpose library like Netty or Lucene, so we don't need to be quite so conservative with dependencies. If there are concrete examples of how a bouncycastle dependency will cause problems I'd be happy to change my mind though.

Copy link
Collaborator

@reta reta left a comment

Choose a reason for hiding this comment

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

Thank you @beanuwave , @cwperks @andrross please take a look when you have time, thanks folks!

@beanuwave beanuwave force-pushed the reevaluate_security_settings branch from bd18542 to 163ac40 Compare February 26, 2025 09:57
Copy link
Contributor

❌ Gradle check result for 163ac40: 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 force-pushed the reevaluate_security_settings branch from 163ac40 to 9d181bd Compare February 26, 2025 11:36
Copy link
Contributor

❕ Gradle check result for 9d181bd: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

@beanuwave
Copy link
Contributor Author

@reta That's great news! I hope we can merge it once everyone has given their final review. I've just pushed the 1-liner for the policy file, as requested by @cwperks, plus the usual rebase against upstream.

…al use of known cryptographic binary extensions, remove unused BC dependencies

Signed-off-by: Igonin <[email protected]>
@beanuwave beanuwave force-pushed the reevaluate_security_settings branch from 9d181bd to eb8f19d Compare February 26, 2025 13:15
Copy link
Member

@cwperks cwperks left a comment

Choose a reason for hiding this comment

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

This change LGTM! Thank you for the persistence @beanuwave!

Copy link
Contributor

❌ Gradle check result for eb8f19d: 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 force-pushed the reevaluate_security_settings branch from eb8f19d to d4a2bba Compare February 26, 2025 15:34
Copy link
Contributor

✅ Gradle check result for d4a2bba: SUCCESS

@cwperks cwperks merged commit 0ffed5e into opensearch-project:main Feb 26, 2025
30 checks passed
@cwperks
Copy link
Member

cwperks commented Feb 26, 2025

@beanuwave This is merged now. #14912 can be rebased.

vinaykpud pushed a commit to vinaykpud/OpenSearch that referenced this pull request Feb 26, 2025
opensearch-project#17393)

* Use BC libraries to parse PEM files, increase key length, allow general use of known cryptographic binary extensions, remove unused BC dependencies

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

* remove duplicated test permission

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

---------

Signed-off-by: Igonin <[email protected]>
Co-authored-by: Igonin <[email protected]>
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.

4 participants