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 Blake2b hash #5089

Merged

Conversation

terryquigleysas
Copy link
Contributor

Description

  • Bug fix
  • Blake2b is deterministic. Passing the parameters incorrectly results in the wrong hash being produced.
  • What is the old behavior before changes and new behavior after changes?
    This may be considered a "Breaking Change" for 3.0.0 as the hashes will now be different - correct, but different from before.

Issues Resolved

Resolves #4274

Testing

Updated existing tests.
Ran Bulk Integration Test action against the branch.
Local testing.

Check List

  • New functionality includes testing
  • New functionality has been documented
  • New Roles/Permissions have a corresponding security dashboards plugin PR
  • API changes companion pull request created
  • Commits are signed per the DCO using --signoff

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.

cwperks
cwperks previously approved these changes Feb 5, 2025
Signed-off-by: Terry Quigley <[email protected]>
@nibix
Copy link
Collaborator

nibix commented Feb 6, 2025

Note: In a mixed cluster state, this will yield inconsistent results: Some nodes will hash value A to hash X, while other nodes will hash value A to hash Y. This will especially affect aggregations. Are we okay with this (genuine question)? In any case, this should be documented.

@terryquigleysas
Copy link
Contributor Author

Note: In a mixed cluster state, this will yield inconsistent results: Some nodes will hash value A to hash X, while other nodes will hash value A to hash Y. This will especially affect aggregations. Are we okay with this (genuine question)? In any case, this should be documented.

@nibix Thank you for your comment. That is not something that I would have been aware of.

I still strongly lean towards putting this change in.

  • It is a clear bug with incorrect behavior that should be fixed
  • Now that version 3.x is imminent would be a good time to make the change
  • I totally agree that any potential behavior differences should be documented

@nibix
Copy link
Collaborator

nibix commented Feb 10, 2025

@terryquigleysas One way to work around that issue would be to gate the new behavior by a config option that can be changed at runtime (In config.yml for example). That way, the behavior can be changed from old to new nearly instantaneously, thus reducing the chance of inconsistent aggregations massively.

@terryquigleysas
Copy link
Contributor Author

@terryquigleysas One way to work around that issue would be to gate the new behavior by a config option that can be changed at runtime (In config.yml for example). That way, the behavior can be changed from old to new nearly instantaneously, thus reducing the chance of inconsistent aggregations massively.

@nibix What would you suggest naming the property?
Would the default for 3.x be the old behavior or the fixed behavior?

@nibix
Copy link
Collaborator

nibix commented Feb 10, 2025

Just to avoid any misunderstanding: I am in no position to give authoritative rulings on such changes. I can only give my opinion and my recommendations. Any unclear issues need to be clarified in a community driven process.

To reiterate the issue:

  • Any upgrade of an existing OpenSearch cluster with high availability requirements to a new version is done using the "rolling upgrade" technique. In this technique, one or a few nodes are removed from the cluster, upgraded and then added to the cluster again. This is repeated until all the nodes are on the new version.
  • Thus, you will have a phase where the cluster will be consisting of nodes of two different versions. This is called a "mixed cluster" state. For larger clusters, such a rolling upgrade can take a significant time, possibly a day or more.
  • Index contents are usually spread around over several different nodes in shards. The code we are looking at in this PR operates on the shard level. Thus, if shard 1 of an index is on OpenSearch version A, and shard 2 of the same index is on OpenSearch version B, two different versions of OpenSearch will process the data and especially the field masking functionality. One random node will then have the responsibility to combine the sub-responses of the individual nodes.
  • Thus, if the field masking logic is changed, there can be cases where search and aggregation results contain the combination of the old logic with the new logic.

A dynamically changeable config flag would solve this the following way:

  • Initially, the config flag retains the old behavior.
  • The cluster is upgraded to the new version.
  • After the upgrade is complete, an admin can change the config flag to the new behavior.

If the config flag would be initially set to the new behavior, the issue would be actually not avoidable.

Having said this, this approach has indeed the downside that it needs manual intervention of an admin after the completion of the rolling upgrade. There would be also not an easy way to automate that.

Another alternative solution might be to use the cluster state to check whether the cluster is in a mixed state or not. The cluster state API provides methods for that. However, TBH, I am not sure how easy these APIs are accessible from the very low level code we are talking about.

@cwperks
Copy link
Member

cwperks commented Feb 10, 2025

FYI There is a class called ClusterInfoHolder that listens to changes in cluster state and can be interrogated to find the min node version in a cluster.

@cwperks
Copy link
Member

cwperks commented Feb 18, 2025

@terryquigleysas @nibix

How should we proceed here? As far I see, there are 2 choices:

  • Document that aggregations could be inaccurate in a mixed cluster
  • Implement logic to check if the min node in a cluster is below 3_0_0 and intentionally do aggregations w/ the old logic and then switch over to new logic once min node version in the cluster is >= 3_0_0

@nibix
Copy link
Collaborator

nibix commented Feb 19, 2025

@cwperks

How should we proceed here? As far I see, there are 2 choices:

* Document that aggregations could be inaccurate in a mixed cluster

This has the downside that it makes certain uses cases impossible in mixed cluster states. If there are, for example, alerting solutions on such data, these might produce false positives in this phase.

What are the exact high availability and compatibility promises OpenSearch makes? I guess we need to know these in order to decide whether this is viable.

* Implement logic to check if the min node in a cluster is below 3_0_0 and intentionally do aggregations w/ the old logic and then switch over to new logic once min node version in the cluster is >= 3_0_0

One downside is here also that the change happens to an kind of uncontrolled point in time. If there are use cases which depend on specific hashes, this also might present a challenge to react to the changed hashes in the right point in time.

I think there are a couple of further options:

  • Introduce a configuration option to control the behavior, but do not initially change the behavior. Communicate to the users that there will be an upcoming change and that they should change that option proactively in order to avoid uncontrolled incidents in there applications caused by the change. At a later version, then change the behavior to the correct blake hash.

  • Just keep it the way it is and give users a further option to have a "correct" blake2b hash. If I understand blake2b correctly (Please correct me if I am wrong!), the salt and personalization parameters are just concated together to an IV. Thus, the current use of the parameters does not reduce the strength of the hashing - it just produces results which are inconsistent to correct applications to the parameters. The option would be to document that by default a non-standard hashing is used. Additionally, users should be given the choice to explicitly specify the blake2b hash in the role configuration.

@terryquigleysas
Copy link
Contributor Author

terryquigleysas commented Feb 19, 2025

@nibix @cwperks Thank you for the comments and suggestions. I have been on vacation for a few days and just catching up on this.

I have looked at checking for the min cluster version. Unfortunately I don't think it is feasible for several reasons. As mentioned above, making these settings available to the relevant code doesn't look trivial. There would likely be an unwanted performance hit for the checks, and even then it would still result in erratic results in various scenarios.

I think we could however use an existing option to support setting the default masking algorithm to revert to the legacy behavior- see https://opensearch.org/docs/latest/security/access-control/field-masking/#advanced-use-an-alternative-hash-algorithm. For example:

plugins.security.masked_fields.algorithm.default: BLAKE2B_LEGACY_DEFAULT

This means that:

  • The new code hashes correctly by default, getting rid of the bug
  • If a user is concerned about inconsistent results in the case of a mixed cluster BLAKE2B_LEGACY_DEFAULT can be set on the 3.x nodes
  • If a user wishes to retain the old hashes, for whatever reason, BLAKE2B_LEGACY_DEFAULT can also be set
  • This ensures that the hashes provided are consistent and deterministic
  • This would need to be documented

What do you think?

Signed-off-by: Terry Quigley <[email protected]>
Signed-off-by: Terry Quigley <[email protected]>
@terryquigleysas terryquigleysas force-pushed the fix_blake2b_hash branch 2 times, most recently from 0be2540 to ae98611 Compare February 20, 2025 17:56
@nibix
Copy link
Collaborator

nibix commented Feb 20, 2025

If a user is concerned about inconsistent results in the case of a mixed cluster BLAKE2B_LEGACY_DEFAULT can be set on the 3.x nodes

This is a genuine question, because I really do not know: With the standard K8S deployment methods, is it possible to achieve that only nodes with a certain version do get a deviating opensearch.yml config?

If this is possible, I think it's a good way to go.

@terryquigleysas
Copy link
Contributor Author

If a user is concerned about inconsistent results in the case of a mixed cluster BLAKE2B_LEGACY_DEFAULT can be set on the 3.x nodes

This is a genuine question, because I really do not know: With the standard K8S deployment methods, is it possible to achieve that only nodes with a certain version do get a deviating opensearch.yml config?

If this is possible, I think it's a good way to go.

We can certainly do it in our K8S deployments. We did similar upgrading from 1.x to 2.x.
I can't speak for how everyone manages their K8S deployments but it's definitely technically possible.

I've updated the PR to include the new functionality.

@nibix
Copy link
Collaborator

nibix commented Feb 26, 2025

For me, it looks good now.

I have triggered again the failing CI jobs.

However, I guess, we still need documentation regarding that breaking change. However, I cannot give pointers where that would be. @cwperks can you help out?

@nibix
Copy link
Collaborator

nibix commented Feb 26, 2025

There seem to be still a couple of test failures. Can you please have a look?

2025-02-26T13:04:40.5373152Z > Task :integrationTest
2025-02-26T13:04:40.5375347Z 
2025-02-26T13:04:40.5376221Z FieldMaskingTest > org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple_legacyDefaultAlgorithm FAILED
2025-02-26T13:04:40.5377915Z     org.junit.ComparisonFailure: expected:<[c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2]> but was:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]>
2025-02-26T13:04:40.5379122Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5379610Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5380479Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple_legacyDefaultAlgorithm(FieldMaskingTest.java:157)
2025-02-26T13:04:40.5381188Z 
2025-02-26T13:04:40.5381844Z FieldMaskingTest > org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple FAILED
2025-02-26T13:04:40.5383235Z     org.junit.ComparisonFailure: expected:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]> but was:<[c042e214a8b49561577445be44c188a8e6274006b36cd0c6fba5312253cf9293]>
2025-02-26T13:04:40.5384364Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5384827Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5385565Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple(FieldMaskingTest.java:145)
2025-02-26T13:04:40.5386295Z 
2025-02-26T13:04:40.5386782Z FieldMaskingTest > org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.simple FAILED
2025-02-26T13:04:40.5388181Z     org.junit.ComparisonFailure: expected:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]> but was:<[c042e214a8b49561577445be44c188a8e6274006b36cd0c6fba5312253cf9293]>
2025-02-26T13:04:40.5389304Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5389749Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5390531Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.simple(FieldMaskingTest.java:276)
2025-02-26T13:04:40.5391158Z 
2025-02-26T13:04:40.5391786Z FieldMaskingTest > org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.keyword FAILED
2025-02-26T13:04:40.5393192Z     org.junit.ComparisonFailure: expected:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]> but was:<[c042e214a8b49561577445be44c188a8e6274006b36cd0c6fba5312253cf9293]>
2025-02-26T13:04:40.5394283Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5394746Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5395545Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.keyword(FieldMaskingTest.java:290)
2025-02-26T13:04:40.5396300Z 
2025-02-26T13:04:40.5396306Z 
2025-02-26T13:04:40.5396707Z Suite: Test class org.opensearch.security.privileges.dlsfls.FieldMaskingTest
2025-02-26T13:04:40.5397959Z   2> org.junit.ComparisonFailure: expected:<[c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2]> but was:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]>
2025-02-26T13:04:40.5399121Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5399562Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5400416Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple_legacyDefaultAlgorithm(FieldMaskingTest.java:157)
2025-02-26T13:04:40.5402198Z   2> org.junit.ComparisonFailure: expected:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]> but was:<[c042e214a8b49561577445be44c188a8e6274006b36cd0c6fba5312253cf9293]>
2025-02-26T13:04:40.5403011Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5403334Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5403848Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple(FieldMaskingTest.java:145)
2025-02-26T13:04:40.5405605Z   2> org.junit.ComparisonFailure: expected:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]> but was:<[c042e214a8b49561577445be44c188a8e6274006b36cd0c6fba5312253cf9293]>
2025-02-26T13:04:40.5407023Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5407559Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5408454Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.simple(FieldMaskingTest.java:276)
2025-02-26T13:04:40.5410080Z   2> org.junit.ComparisonFailure: expected:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]> but was:<[c042e214a8b49561577445be44c188a8e6274006b36cd0c6fba5312253cf9293]>
2025-02-26T13:04:40.5411312Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5411994Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5412860Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.keyword(FieldMaskingTest.java:290)
2025-02-26T13:04:40.5413577Z 
2025-02-26T13:04:40.5413696Z Tests with failures:
2025-02-26T13:04:40.5414395Z  - org.opensearch.security.InternalAuditLogTest.testAuditLogShouldBeGreenInSingleNodeCluster
2025-02-26T13:04:40.5415536Z  - org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple_legacyDefaultAlgorithm
2025-02-26T13:04:40.5416520Z  - org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple
2025-02-26T13:04:40.5417566Z  - org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.simple
2025-02-26T13:04:40.5418358Z  - org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.keyword

@cwperks
Copy link
Member

cwperks commented Feb 26, 2025

However, I guess, we still need documentation regarding that breaking change. However, I cannot give pointers where that would be. @cwperks can you help out?

@terryquigleysas has previously made changes to the documentation website. I think the right location would be https://github.com/opensearch-project/documentation-website/blob/main/_security/access-control/field-masking.md?plain=1

@nibix
Copy link
Collaborator

nibix commented Feb 26, 2025

I guess, for the chosen solution we also need to have a documentation that is being read by users that are applying the update. Users upgrading won't pro-actively navigate into the field masking docs. Is there a thing like release notes?

@cwperks
Copy link
Member

cwperks commented Feb 26, 2025

I guess, for the chosen solution we also need to have a documentation that is being read by users that are applying the update. Users upgrading won't pro-actively navigate into the field masking docs. Is there a thing like release notes?

For 3.0 there will be a migration guide and list of breaking changes similar to: https://opensearch.org/docs/latest/breaking-changes/

@terryquigleysas
Copy link
Contributor Author

There seem to be still a couple of test failures. Can you please have a look?

2025-02-26T13:04:40.5373152Z > Task :integrationTest
2025-02-26T13:04:40.5375347Z 
2025-02-26T13:04:40.5376221Z FieldMaskingTest > org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple_legacyDefaultAlgorithm FAILED
2025-02-26T13:04:40.5377915Z     org.junit.ComparisonFailure: expected:<[c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2]> but was:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]>
2025-02-26T13:04:40.5379122Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5379610Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5380479Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple_legacyDefaultAlgorithm(FieldMaskingTest.java:157)
2025-02-26T13:04:40.5381188Z 
2025-02-26T13:04:40.5381844Z FieldMaskingTest > org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple FAILED
2025-02-26T13:04:40.5383235Z     org.junit.ComparisonFailure: expected:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]> but was:<[c042e214a8b49561577445be44c188a8e6274006b36cd0c6fba5312253cf9293]>
2025-02-26T13:04:40.5384364Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5384827Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5385565Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple(FieldMaskingTest.java:145)
2025-02-26T13:04:40.5386295Z 
2025-02-26T13:04:40.5386782Z FieldMaskingTest > org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.simple FAILED
2025-02-26T13:04:40.5388181Z     org.junit.ComparisonFailure: expected:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]> but was:<[c042e214a8b49561577445be44c188a8e6274006b36cd0c6fba5312253cf9293]>
2025-02-26T13:04:40.5389304Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5389749Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5390531Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.simple(FieldMaskingTest.java:276)
2025-02-26T13:04:40.5391158Z 
2025-02-26T13:04:40.5391786Z FieldMaskingTest > org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.keyword FAILED
2025-02-26T13:04:40.5393192Z     org.junit.ComparisonFailure: expected:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]> but was:<[c042e214a8b49561577445be44c188a8e6274006b36cd0c6fba5312253cf9293]>
2025-02-26T13:04:40.5394283Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5394746Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5395545Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.keyword(FieldMaskingTest.java:290)
2025-02-26T13:04:40.5396300Z 
2025-02-26T13:04:40.5396306Z 
2025-02-26T13:04:40.5396707Z Suite: Test class org.opensearch.security.privileges.dlsfls.FieldMaskingTest
2025-02-26T13:04:40.5397959Z   2> org.junit.ComparisonFailure: expected:<[c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2]> but was:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]>
2025-02-26T13:04:40.5399121Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5399562Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5400416Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple_legacyDefaultAlgorithm(FieldMaskingTest.java:157)
2025-02-26T13:04:40.5402198Z   2> org.junit.ComparisonFailure: expected:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]> but was:<[c042e214a8b49561577445be44c188a8e6274006b36cd0c6fba5312253cf9293]>
2025-02-26T13:04:40.5403011Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5403334Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5403848Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple(FieldMaskingTest.java:145)
2025-02-26T13:04:40.5405605Z   2> org.junit.ComparisonFailure: expected:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]> but was:<[c042e214a8b49561577445be44c188a8e6274006b36cd0c6fba5312253cf9293]>
2025-02-26T13:04:40.5407023Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5407559Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5408454Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.simple(FieldMaskingTest.java:276)
2025-02-26T13:04:40.5410080Z   2> org.junit.ComparisonFailure: expected:<[96c8d1da7eb153db858d4f0585120319e17ed1162db9e94bee19fb10b6d19727]> but was:<[c042e214a8b49561577445be44c188a8e6274006b36cd0c6fba5312253cf9293]>
2025-02-26T13:04:40.5411312Z         at org.junit.Assert.assertEquals(Assert.java:117)
2025-02-26T13:04:40.5411994Z         at org.junit.Assert.assertEquals(Assert.java:146)
2025-02-26T13:04:40.5412860Z         at org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.keyword(FieldMaskingTest.java:290)
2025-02-26T13:04:40.5413577Z 
2025-02-26T13:04:40.5413696Z Tests with failures:
2025-02-26T13:04:40.5414395Z  - org.opensearch.security.InternalAuditLogTest.testAuditLogShouldBeGreenInSingleNodeCluster
2025-02-26T13:04:40.5415536Z  - org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple_legacyDefaultAlgorithm
2025-02-26T13:04:40.5416520Z  - org.opensearch.security.privileges.dlsfls.FieldMaskingTest$Field.simple
2025-02-26T13:04:40.5417566Z  - org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.simple
2025-02-26T13:04:40.5418358Z  - org.opensearch.security.privileges.dlsfls.FieldMaskingTest$FieldMaskingRule.keyword

Strangely these hadn't been failing earlier. On the case now.

Copy link

codecov bot commented Feb 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.65%. Comparing base (305df57) to head (87f425a).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5089      +/-   ##
==========================================
+ Coverage   71.64%   71.65%   +0.01%     
==========================================
  Files         335      335              
  Lines       22748    22755       +7     
  Branches     3599     3601       +2     
==========================================
+ Hits        16297    16305       +8     
- Misses       4651     4652       +1     
+ Partials     1800     1798       -2     
Files with missing lines Coverage Δ
.../opensearch/security/OpenSearchSecurityPlugin.java 83.83% <100.00%> (ø)
...earch/security/privileges/dlsfls/FieldMasking.java 87.05% <100.00%> (+0.55%) ⬆️

... and 4 files with indirect coverage changes

@terryquigleysas
Copy link
Contributor Author

@nibix @cwperks That should be it ready now. I can follow up on the documentation tasks once this goes in.

@shikharj05
Copy link
Contributor

+1 on using a config - it's okay to change the default and document the behavior here- https://opensearch.org/docs/latest/security/access-control/field-masking/

Breaking change here-

#5031 &
https://opensearch.org/docs/latest/breaking-changes/

I am not sure if we can add a log line in-case of incorrect aggregations in mixed cluster state. @terryquigleysas

@terryquigleysas
Copy link
Contributor Author

+1 on using a config - it's okay to change the default and document the behavior here- https://opensearch.org/docs/latest/security/access-control/field-masking/

Breaking change here-

#5031 & https://opensearch.org/docs/latest/breaking-changes/

I am not sure if we can add a log line in-case of incorrect aggregations in mixed cluster state. @terryquigleysas

@shikharj05 Thank you for confirming the locations where the documentation needs to change. I will pick up those once this PR goes in.

The addition of the BLAKE2B_LEGACY_DEFAULT option means that the mixed-cluster aggregation scenario can be avoided.

@shikharj05
Copy link
Contributor

shikharj05 commented Feb 28, 2025

Since the default implementation will change, users might still land into mixed-cluster issue (if they don't update the config). Hence, I was checking if it's possible to add a log line.

@terryquigleysas
Copy link
Contributor Author

I have looked at checking for the min cluster version. Unfortunately I don't think it is feasible for several reasons. As mentioned above, making these settings available to the relevant code doesn't look trivial. There would likely be an unwanted performance hit for the checks, and even then it would still result in erratic results in various scenarios.

@shikharj05 It's a fair point regarding the edge case and one I addressed above. I think the best approach is to fix the bug as it is here and document the change in the two locations you mention.

I could add a log line saying the existing hash has been implemented incorrectly but that would have to be done separately to be backported to the 1.x and 2,x versions.

@willyborankin willyborankin merged commit d43f96c into opensearch-project:main Mar 3, 2025
42 checks passed
@terryquigleysas terryquigleysas deleted the fix_blake2b_hash branch March 3, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Blake2b hashing for Masked Fields does not apply salt correctly
5 participants