Skip to content

Correct Argon2 settings when creating new database #11853

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 1 commit into
base: develop
Choose a base branch
from

Conversation

droidmonkey
Copy link
Member

  • Argon2 default parallelism settings were set to the number of threads on the computer. That is excessive on high cpu count computers.

See #11852 (comment)

Testing strategy

Tested manually and unit tests

Type of change

  • ✅ Bug fix (non-breaking change that fixes an issue)

@droidmonkey droidmonkey added the pr: bugfix Pull request that fixes a bug label Mar 8, 2025
@droidmonkey droidmonkey added this to the v2.8.0 milestone Mar 8, 2025
@droidmonkey droidmonkey requested a review from phoerious March 8, 2025 14:26
Copy link

codecov bot commented Mar 8, 2025

Codecov Report

Attention: Patch coverage is 76.47059% with 4 lines in your changes missing coverage. Please review.

Project coverage is 63.89%. Comparing base (37ddbb3) to head (6b36b33).

Files with missing lines Patch % Lines
src/crypto/kdf/Argon2Kdf.cpp 57.14% 3 Missing ⚠️
...ui/dbsettings/DatabaseSettingsWidgetEncryption.cpp 83.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #11853      +/-   ##
===========================================
- Coverage    63.92%   63.89%   -0.03%     
===========================================
  Files          369      370       +1     
  Lines        38920    38921       +1     
===========================================
- Hits         24878    24868      -10     
- Misses       14042    14053      +11     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@phoerious phoerious left a comment

Choose a reason for hiding this comment

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

2 sounds a bit low to me. What about using idealThreadCount(), but cap it to, say, 8.

@droidmonkey
Copy link
Member Author

droidmonkey commented Mar 8, 2025

The way parallelism works in argon2 is that it divides the total memory (e.g., 64 MiB) by the parallelism number (called a lane) and then performs the argon2 algorithm on each lane at the same time. So if you make parallelism 8 but keep memory at 64 MiB, you actually don't improve security at all. But if you want to set memory to 512 MiB, you can set parallelism to 8, and the total time will stay the same as 64 MiB and parallelism of 1. This ultimately reduces the capability of a GPU attack, but only if you also increase memory.

This is a good writeup: https://community.bitwarden.com/t/argon2id-parallelism-explanation/54189/6

At the end of the day, I think a max default of 4 is fine, but we should also be upping the default memory by the parallelism perhaps?

@phoerious
Copy link
Member

Capping it a four is fine with me as well. Just up the memory cost accordingly as well.

* Argon2 default parallelism settings were set to the number of threads on the computer. That is excessive on high cpu count computers.
@droidmonkey droidmonkey force-pushed the fix/argon2-settings branch from 3832ba0 to 6b36b33 Compare March 30, 2025 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: bugfix Pull request that fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants