Skip to content

[PM-30370] Add salt to vault sync response#7248

Draft
ike-kottlowski wants to merge 4 commits intomainfrom
auth/pm-21926/add-salt-to-vault-dtos
Draft

[PM-30370] Add salt to vault sync response#7248
ike-kottlowski wants to merge 4 commits intomainfrom
auth/pm-21926/add-salt-to-vault-dtos

Conversation

@ike-kottlowski
Copy link
Contributor

@ike-kottlowski ike-kottlowski commented Mar 18, 2026

🎟️ Tracking

PM-30370

📔 Objective

On sync retrieve the User.GetMasterPasswordSalt() method instead of the email.

@ike-kottlowski ike-kottlowski added the ai-review Request a Claude code review label Mar 18, 2026
@claude
Copy link
Contributor

claude bot commented Mar 18, 2026

Claude finished @ike-kottlowski's task in 2m 47s —— View job


Code Review: PM-30370 Add salt to vault sync response

  • Gather context and review PR diff
  • Analyze changed files
  • Post review findings

Critical Finding

GetMasterPasswordSalt() never uses the MasterPasswordSalt propertysrc/Core/Entities/User.cs:117-120

The method currently always returns Email.ToLowerInvariant().Trim(), completely ignoring the MasterPasswordSalt property:

public string GetMasterPasswordSalt()
{
    return Email.ToLowerInvariant().Trim();
}

This means:

  1. The two new tests (Get_HaveExplicitMasterPasswordSalt_SaltReturnedInSync and Constructor_UserWithExplicitSalt_UsesMasterPasswordSalt) that set MasterPasswordSalt = "explicit-salt-value" and assert on that value will fail.
  2. The PR's goal — returning an explicit salt when one exists — does not actually work yet.

The fix should add a null-coalescing fallback in the method:

public string GetMasterPasswordSalt()
{
    return MasterPasswordSalt ?? Email.ToLowerInvariant().Trim();
}

Fix this →


Other Changes Look Good

  • SyncResponseModel.cs: Correctly swaps user.Email.ToLowerInvariant() for user.GetMasterPasswordSalt() — this is the right call site change.
  • Unit tests (SyncResponseModelTests.cs): Good coverage with both null-salt and explicit-salt scenarios. The user.MasterPasswordSalt = null setup on the existing test is a nice touch.
  • Integration test (SyncControllerTests.cs): End-to-end test correctly sets explicit salt and verifies it round-trips through sync.
  • Unit test (SyncControllerTests.cs): Assertion updated consistently.

All tests are well-structured and will pass once GetMasterPasswordSalt() is fixed.


},
MasterKeyEncryptedUserKey = user.Key!,
Salt = user.Email.ToLowerInvariant()
Salt = user.GetMasterPasswordSalt()
Copy link
Contributor

Choose a reason for hiding this comment

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

CRITICAL: GetMasterPasswordSalt() never reads User.MasterPasswordSalt -- it always returns Email.ToLowerInvariant().Trim(), so the new explicit-salt tests will fail and the feature does not work.

Details and fix

Commit 0240c94ad message says "add null coalesce to GetMasterPasswordSalt" but the method body in src/Core/Entities/User.cs line 117-120 was never updated:

public string GetMasterPasswordSalt()
{
    return Email.ToLowerInvariant().Trim();
}

It should be:

public string GetMasterPasswordSalt()
{
    return MasterPasswordSalt ?? Email.ToLowerInvariant().Trim();
}

Without this change, both Get_HaveExplicitMasterPasswordSalt_SaltReturnedInSync and Constructor_UserWithExplicitSalt_UsesMasterPasswordSalt will fail because they set MasterPasswordSalt = "explicit-salt-value" but the method ignores it and returns the email.

},
MasterKeyEncryptedUserKey = user.Key!,
Salt = user.Email.ToLowerInvariant()
Salt = user.GetMasterPasswordSalt()
Copy link
Contributor

Choose a reason for hiding this comment

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

🚨 CRITICALGetMasterPasswordSalt() in src/Core/Entities/User.cs:117-120 never checks the MasterPasswordSalt property — it always returns Email.ToLowerInvariant().Trim(). The two new tests that set MasterPasswordSalt = "explicit-salt-value" will fail.

Suggested fix in User.cs:

public string GetMasterPasswordSalt()
{
    return MasterPasswordSalt ?? Email.ToLowerInvariant().Trim();
}

@sonarqubecloud
Copy link

@github-actions
Copy link
Contributor

Logo
Checkmarx One – Scan Summary & Details8de3d6fe-f817-4f02-abbe-b1a064f1f837

Great job! No new security vulnerabilities introduced in this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant