You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Migrating existing installations from a 2048-bit to a 4096-bit RSA JWT key
#8018
Vaultwarden signs its JWTs with rsa_key.pem, which is generated as RSA-2048. RSA-2048 is still secure today, but NIST plans to deprecate it after 2030 (SP 800-131A / IR 8547). I'm about to open a small PR that makes new installations generate a 4096-bit key. Before writing any code, I'd like to discuss whether and how existing installations could be migrated.
Why simply replacing the key isn't enough
Admins can already replace rsa_key.pem by hand, but an automatic migration would need to handle these:
All sessions would end. Refresh tokens are signed with this key and are valid for up to 90 days on mobile (MOBILE_REFRESH_VALIDITY), and 30 days otherwise. "Remember this device" 2FA tokens last up to 90 days (two_factor_remember_days). Invitation, emergency access, email verification and delete links would also stop working.
The prelogin KDF secret would change.PRELOGIN_KDF_KEY is derived from the bytes of rsa_key.pem, and it is used to give non-existent accounts stable fake KDF settings. If the key changes, the fake settings for unknown emails change while real accounts keep theirs. An attacker comparing prelogin responses before and after the change could tell which email addresses have accounts.
Possible approach
On startup, if the existing key is smaller than 4096 bits, generate a new 4096-bit key and keep the old one as a verification-only key (for example rsa_key.pem.old).
Sign all new tokens with the new key, and set a kid header so decode_jwt can pick the right key. Tokens without a kid would fall back to the old key.
Keep PRELOGIN_KDF_KEY stable across the rotation, for example by deriving it from the old key until it is removed, or by persisting the derived secret separately.
Delete the old key once the longest token lifetime (90 days, plus some margin) has passed since the rotation, recorded via the old file's timestamp or a small marker file.
An alternative would be to not migrate automatically at all, and instead document a manual rotation that accepts that everyone gets logged out.
Would you be interested in a PR for the automatic migration, or would you prefer the documented manual route (or neither)? I'm happy to adjust the approach to whatever fits the project best.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Vaultwarden signs its JWTs with
rsa_key.pem, which is generated as RSA-2048. RSA-2048 is still secure today, but NIST plans to deprecate it after 2030 (SP 800-131A / IR 8547). I'm about to open a small PR that makes new installations generate a 4096-bit key. Before writing any code, I'd like to discuss whether and how existing installations could be migrated.Why simply replacing the key isn't enough
Admins can already replace
rsa_key.pemby hand, but an automatic migration would need to handle these:MOBILE_REFRESH_VALIDITY), and 30 days otherwise. "Remember this device" 2FA tokens last up to 90 days (two_factor_remember_days). Invitation, emergency access, email verification and delete links would also stop working.PRELOGIN_KDF_KEYis derived from the bytes ofrsa_key.pem, and it is used to give non-existent accounts stable fake KDF settings. If the key changes, the fake settings for unknown emails change while real accounts keep theirs. An attacker comparing prelogin responses before and after the change could tell which email addresses have accounts.Possible approach
rsa_key.pem.old).kidheader sodecode_jwtcan pick the right key. Tokens without akidwould fall back to the old key.PRELOGIN_KDF_KEYstable across the rotation, for example by deriving it from the old key until it is removed, or by persisting the derived secret separately.An alternative would be to not migrate automatically at all, and instead document a manual rotation that accepts that everyone gets logged out.
Would you be interested in a PR for the automatic migration, or would you prefer the documented manual route (or neither)? I'm happy to adjust the approach to whatever fits the project best.
Assisted by ClaudeCode:claude-opus-5-5
All reactions