Skip to content

Commit

Permalink
fix: Enforce stronger encryption for new password hashing
Browse files Browse the repository at this point in the history
Previously, we attempted to hash the new password using the same encryption parameters as the initial password. In cases where the initial password was hashed with low kdf iterations, this led to server rejections. Thus commit fore a higher kdf iterations for new passwords to ensure compatibility with server requirements
  • Loading branch information
cballevre committed Nov 7, 2024
1 parent 5446765 commit 02050d1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/actions/passphrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const UPDATE_HINT = 'UPDATE_HINT'
export const UPDATE_HINT_SUCCESS = 'UPDATE_HINT_SUCCESS'
export const UPDATE_HINT_FAILURE = 'UPDATE_HINT_FAILURE'

const KDF_ITERATIONS = 650000

const invalidPassphraseErrorAction = {
type: UPDATE_PASSPHRASE_FAILURE,
errors: {
Expand Down Expand Up @@ -76,7 +78,8 @@ export const updatePassphrase = (

const newHashAndKeys = await vaultClient.computeNewHashAndKeys(
currentPassphrase,
newPassphrase
newPassphrase,
KDF_ITERATIONS
)
await cozyFetch(client, 'PUT', '/settings/passphrase', {
current_passphrase: newHashAndKeys.currentPasswordHash,
Expand Down Expand Up @@ -154,7 +157,8 @@ export const updatePassphrase2FASecond = (
await vaultClient.login(currentPassphrase)
const newHashAndKeys = await vaultClient.computeNewHashAndKeys(
currentPassphrase,
newPassphrase
newPassphrase,
KDF_ITERATIONS
)
await cozyFetch(client, 'PUT', '/settings/passphrase', {
new_passphrase: newHashAndKeys.newPasswordHash,
Expand Down

0 comments on commit 02050d1

Please sign in to comment.