feat(kdf-settings-validator): Enforce salt cannot be empty string.#7628
Conversation
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR layers defense-in-depth against null/empty/whitespace master-password salts. Code Review DetailsNo findings. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## auth/pm-35393/master-password-service-auth-integration #7628 +/- ##
=======================================================================================
Coverage 59.87% 59.88%
=======================================================================================
Files 2124 2124
Lines 93469 93492 +23
Branches 8307 8311 +4
=======================================================================================
+ Hits 55965 55988 +23
Misses 35527 35527
Partials 1977 1977 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ike-kottlowski
left a comment
There was a problem hiding this comment.
🎨 I'm thinking we can tighten up the data annotation on the request model themselves as well. This would give us the benefit of failing closer to the controller and the KdfSettingsValidator changes act as a safety net that should be unreachable in practice.
// MasterPasswordAuthenticationDataRequestModel.cs
[Required(AllowEmptyStrings = false)]
[StringLength(256)]
public required string Salt { get; init; }
// MasterPasswordUnlockDataRequestModel.cs
[Required(AllowEmptyStrings = false)]
[StringLength(256)]
public required string Salt { get; init; }
|



🎟️ Tracking
PM-35393
📔 Objective
[Required]attribution onsalt-related fields enforces by default that salt cannot be null, empty, or whitespace. However, this is a configurable opinion. While it should probably not be configured to allow whitespace, because this is a critical path, reinforcement should be present to guard against configuration drift, which would otherwise be invisible to this logic.string.IsNullOrWhitespaceproperly captures all of these.Tests have been added to support.