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

feat(crypto): use passwap for machine and app secrets #7657

Merged
merged 23 commits into from
Apr 5, 2024

Conversation

muhlemmer
Copy link
Contributor

@muhlemmer muhlemmer commented Mar 27, 2024

This change introduces the use of passwap for secrets or machine users (client credentials), OIDC and API applications.
Similar to user passwords, hash configuration can now be updated in zitadel's yaml config and secrets get re-hashed when the first next verification succeeds.

Config changes

The SecretGenerators.PasswordSaltCost options are removed. These were previously set to 14 as a default. If users had custom values for this setting, it will now be ignored.

There is a new config option SystemDefaults.SecretHasher which carries passwap related config in the same way we do for human user passwords. If users wish to retain their custom bcrypt cost, SystemDefaults.SecretHasher.Hasher.Cost must be set accordingly. The new default cost is 4, which is the minimum required by the bcrypt package.

4 is actually a more than sufficient value. With the defaults of digits, lower and upper case letters, there are 64^62 possible values.
Benchmarking bcrypt on my laptop at cost 4, does around 1275 ops/second. It would take 7.5e108 seconds to go through all possibilities.
Adding the fact that these are not user passwords and the ability to brute-force the hashed secrets from the database has no value for an attacker, should they get leaked.

As this feature rehashes on config change, expect all machine user and application secrets to get a hash.updated event if no action is taken. This is fine. As the default cost is significantly lowered, there shouldn't be much overhead.

Refactorings

Crypto interface

The CryptoCode interfaces have changed into EncryptedCode interfaces. There is no longer a combined interface for encrypted and hashed codes. "old style" for generating and verifying codes has been preserved for encrypted codes, such as email, sms codes and many more. The Hashed Code generator is completely separated from this interface now.,

Generators

The generators for hashed codes are now moved completely into the command package. Previously the generator was obtained from the query package and passed into command.

Closes #6540

Definition of Ready

  • I am happy with the code
  • Short description of the feature/issue is added in the pr description
  • PR is linked to the corresponding user story
  • Acceptance criteria are met
  • All open todos and follow ups are defined in a new ticket and justified
  • Deviations from the acceptance criteria and design are agreed with the PO and documented.
  • No debug or dead code
  • My code has no repetitions
  • Critical parts are tested automatically
  • Where possible E2E tests are implemented
  • Documentation/examples are up-to-date
  • All non-functional requirements are met
  • Functionality of the acceptance criteria is checked manually on the dev system.

Copy link

vercel bot commented Mar 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 5, 2024 9:35am

internal/repository/project/api_config.go Outdated Show resolved Hide resolved
cmd/setup/25.sql Outdated Show resolved Hide resolved
@muhlemmer muhlemmer merged commit 2089992 into main Apr 5, 2024
25 checks passed
@muhlemmer muhlemmer deleted the perf-machine-secret branch April 5, 2024 09:35
Copy link

🎉 This PR is included in version 2.50.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

Machine Secret algorithm is only bcrypt
2 participants