Skip to content

Adds Argon2 support for password hashing #5441

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

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

Conversation

aidenlindsay
Copy link

Description

This change adds support for Argon2 as another alternative password hashing algorithm. Which builds on the added support for configuration of parameters, by building support for the following parameters:

Argon2:

  • Memory (defaults to 64MiB/65536)
  • Iterations (defaults to 3)
  • Length (defaults to 32)
  • Parallelism (defaults to 1)
  • Type (defaults to Argon2ID)
  • Version (defaults to 19)

This includes adding the Argon2PasswordHasher class as well as amending all current classes that use the hashing algorithms to support the new algorithm (PasswordHasherFactory.java, Hasher.java, test scripts, etc.)

Previously there was only support for BCrypt and PBKDF2 with BCrypt being the default, this allows the option to use another alternative algorithm in password hashing

Issues Resolved

#4592

Related Issues

#4590
#4524

Testing

Added both integration tests and unit tests to cover the new code as well as some manual 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.

Signed-off-by: Aiden Lindsay <[email protected]>
Signed-off-by: Aiden Lindsay <[email protected]>
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 @aidenlindsay ! The PR mostly looks good to me. Please address the JSM related comments and fix the integration tests.

});

Assert.assertFalse(message1.toString().contains("$argon2id$"));
Assert.assertTrue(message1.toString().contains("__HASH__"));
Copy link
Member

Choose a reason for hiding this comment

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

is __HASH__ a standard redaction string? If it's possible can we check exact instead of contains, that way we will not need assertion on line 401

Copy link
Author

Choose a reason for hiding this comment

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

For the 401 assert I can be more specific with the hash data instead of just saying .contains, but I don't really know what you mean by removing it? HASH is not a standard but it does seem to be the convention used in the security plugin for other algorithms to indicate the hash has been redacted. I think that for its use case, checking that this appears at all is sufficient to ensure hashes are being redacted as intended, but I'm open to other suggestions

Copy link
Member

Choose a reason for hiding this comment

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

I see. I meant to say whether we should compare with equalTo instead of contains.

Copy link
Author

Choose a reason for hiding this comment

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

I think in practice audit messages are usually JSON objects or logs, and so they will contain more than just the string HASH, and therefore it would be unrealistic to check it is exactly equal, and more helpful to check that the term appears to show redaction

@DarshitChanpura DarshitChanpura changed the title Add support for Argon2 for password hashing (NEW + IMPROVED) Adds Argon2 support for password hashing Jun 25, 2025
…, manually tested and works the same

Signed-off-by: Aiden Lindsay <[email protected]>
…ame change can work for the other algs

Signed-off-by: Aiden Lindsay <[email protected]>
…password hashing algorithms

Signed-off-by: Aiden Lindsay <[email protected]>
…instead of hard coding the values

Signed-off-by: Aiden Lindsay <[email protected]>
@aidenlindsay
Copy link
Author

will fix the test failures after lunch

Copy link
Member

@DarshitChanpura DarshitChanpura left a comment

Choose a reason for hiding this comment

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

The changes look good to me. I'll wait for CI to be green before my final review.

…s, this change seems to create a new error which may be improved

Signed-off-by: Aiden Lindsay <[email protected]>
@aidenlindsay
Copy link
Author

All bulk integration tests now pass locally except a single unrequired one that seems to be related to the clusters and not the code, could somebody run these integration tests again, think everything should be good for merge now. Will begin working on an update to the documentation :)

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