Skip to content

Default to SSHA-256 as API key stored credential hasher #120997

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

Merged
merged 31 commits into from
Jan 29, 2025

Conversation

n1v0lg
Copy link
Contributor

@n1v0lg n1v0lg commented Jan 28, 2025

API keys are high-entropy secure random strings. This means that the additional work factor of functions like PBKDF or bcrypt are not necessary, and a faster hash function like salted SHA-256 provides adequate security against offline attacks (hash collision, brute force, etc.).

This PR adds SSHA-256 to the list of supported stored hash algorithms for API key secrets, and makes it the default algorithm. Additionally, this PR changes the format of API key secrets, moving from an encoded UUID to a random string which increase the entropy of API keys from 122 bits to 128 bits, without changing overall secret length.

Relates: ES-9504

@n1v0lg n1v0lg added >enhancement :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) v9.0.0 v8.18.0 labels Jan 28, 2025
@n1v0lg n1v0lg self-assigned this Jan 28, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @n1v0lg, I've created a changelog YAML for you.

@n1v0lg n1v0lg changed the title Allow SSHA-256 for API key credential hash Allow SSHA-256 as API key credential hash Jan 28, 2025
@n1v0lg n1v0lg changed the title Allow SSHA-256 as API key credential hash Allow SSHA-256 as API key stored credential hash Jan 28, 2025
@n1v0lg n1v0lg marked this pull request as ready for review January 28, 2025 12:34
@elasticsearchmachine elasticsearchmachine added the Team:Security Meta label for security team label Jan 28, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

@n1v0lg n1v0lg changed the title Allow SSHA-256 as API key stored credential hash Default to SSHA-256 as API key stored credential hash Jan 28, 2025
@n1v0lg n1v0lg changed the title Default to SSHA-256 as API key stored credential hash Default to SSHA-256 as API key stored credential hasher Jan 28, 2025
@slobodanadamovic slobodanadamovic self-requested a review January 28, 2025 16:06
Copy link
Contributor

@slobodanadamovic slobodanadamovic left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Looks good, I left just one small comment for your consideration. No need for re-review.

@n1v0lg n1v0lg added auto-backport Automatically create backport pull requests when merged auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) labels Jan 29, 2025
@elasticsearchmachine elasticsearchmachine merged commit 51b4fff into elastic:main Jan 29, 2025
21 checks passed
@n1v0lg n1v0lg deleted the api-key-stored-hash branch January 29, 2025 18:14
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.x Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 120997

@n1v0lg
Copy link
Contributor Author

n1v0lg commented Jan 29, 2025

💚 All backports created successfully

Status Branch Result
8.x

Questions ?

Please refer to the Backport tool documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >enhancement :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) Team:Security Meta label for security team v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants