mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-08-24 23:22:58 -05:00
[GH-ISSUE #6982] Feature: Configurable default KDF type for new user registrations #35535
Reference in New Issue
Block a user
Originally created by @dnplkndll on GitHub (Mar 21, 2026).
Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/6982
Summary
Allow server administrators to configure the default KDF type (PBKDF2 or Argon2id) for new user registrations via environment variables, rather than having PBKDF2 hardcoded as the only default.
Motivation
The default KDF for new user registrations is hardcoded in
src/db/models/user.rs:Argon2id is widely considered superior to PBKDF2 for password hashing because it is memory-hard, making it significantly more resistant to GPU-based brute-force attacks. Vaultwarden already fully supports Argon2id — users can switch to it in their account settings — but the server default remains PBKDF2.
For self-hosted instances (especially family or small-team deployments), most users will never change their KDF settings. Allowing the server admin to set Argon2id as the default ensures all new accounts start with the stronger KDF without requiring each user to manually change it.
Proposed Solution
Add four environment variables:
CLIENT_KDF_TYPEi320CLIENT_KDF_ITERATIONSi32600000CLIENT_KDF_MEMORYi3264CLIENT_KDF_PARALLELISMi324Backwards compatible: Default values produce identical behavior to the current hardcoded constants. Existing users are not affected.
Example usage
Files changed (~81 lines across 4 files)
src/config.rs— Config entries with validationsrc/db/models/user.rs— Replace hardcoded constants with config-backed functionssrc/api/core/accounts.rs— Use config for prelogin defaults (unknown email case).env.template— Document new variablesImplementation
I have a working, tested implementation and am happy to submit a PR if this is of interest.