Skip to content

Conversation

@mzieniukbw
Copy link
Contributor

@mzieniukbw mzieniukbw commented Dec 23, 2025

๐ŸŽŸ๏ธ Tracking

https://bitwarden.atlassian.net/browse/PM-27281

๐Ÿ“” Objective

Updated the server API POST /account/set-password to support User Crypto V2 for JIT (Just-In-Time) initial master password registration flow.

This endpoint is used for two SSO user flows.

  • Master Password decryption. Account keys needs to be set for the user account.
  • Existing TDE user (registered and account crypto keys initialised) that was granted manage account recovery permission - user will be asked to set master password upon new login. Account keys are already setup. Since there are slightly different requirements on the validation and crypto initialisation logic, i decided to separate this flow into it's separate command.

Other changes:

  • Moved existing command logic with V1 suffix into SetInitialMasterPasswordCommandV1, will be easier to remove later.
  • Added UserRepository.UpdateUserDataAsync function for the TDE decryption MP onboarding user flow, since they already have the account keys and only need MP set. Since we already have SetMasterPassword that is used for both flows (MP and TDE decryption) and this function returns a "task" (does not execute against database), it make sense to re-use it. This function is technically a "run multiple tasks in one transaction" orchestrator, which we might want to do going forward anyway for complex database operations, that needs multiple steps done within one transaction and requires minimal changes to the repository.

๐Ÿ“ธ Screenshots

โฐ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

๐Ÿฆฎ Reviewer guidelines

  • ๐Ÿ‘ (:+1:) or similar for great changes
  • ๐Ÿ“ (:memo:) or โ„น๏ธ (:information_source:) for notes or general info
  • โ“ (:question:) for questions
  • ๐Ÿค” (:thinking:) or ๐Ÿ’ญ (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • ๐ŸŽจ (:art:) for suggestions / improvements
  • โŒ (:x:) or โš ๏ธ (:warning:) for more significant problems or concerns needing attention
  • ๐ŸŒฑ (:seedling:) or โ™ป๏ธ (:recycle:) for future improvements or indications of technical debt
  • โ› (:pick:) for minor or nitpick changes

@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

โŒ Patch coverage is 86.11111% with 45 lines in your changes missing coverage. Please review.
โœ… Project coverage is 59.00%. Comparing base (484a8e4) to head (38c17f9).
โš ๏ธ Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
...frastructure.Dapper/Repositories/UserRepository.cs 0.00% 40 Missing โš ๏ธ
...asterPassword/SetInitialMasterPasswordCommandV1.cs 94.23% 2 Missing and 1 partial โš ๏ธ
...ure.EntityFramework/Repositories/UserRepository.cs 94.59% 2 Missing โš ๏ธ
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6777      +/-   ##
==========================================
+ Coverage   58.83%   59.00%   +0.17%     
==========================================
  Files        1925     1933       +8     
  Lines       85355    85756     +401     
  Branches     7652     7681      +29     
==========================================
+ Hits        50217    50604     +387     
- Misses      33269    33283      +14     
  Partials     1869     1869              

โ˜” View full report in Codecov by Sentry.
๐Ÿ“ข Have feedback on the report? Share it here.

๐Ÿš€ New features to boost your workflow:
  • โ„๏ธ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • ๐Ÿ“ฆ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 23, 2025

Logo
Checkmarx One โ€“ Scan Summary & Details โ€“ ffb3dbac-de34-4229-9cca-dfb459b670ac

New Issues (5)

Checkmarx found the following issues in this Pull Request

# Severity Issue Source File / Package Checkmarx Insight
1 MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 217
detailsMethod at line 217 of /src/Api/Auth/Controllers/AccountsController.cs gets a parameter from a user request from model. This parameter value flow...
Attack Vector
2 MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 1170
detailsMethod at line 1170 of /src/Api/Vault/Controllers/CiphersController.cs gets a parameter from a user request from id. This parameter value flows ...
Attack Vector
3 MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 1060
detailsMethod at line 1060 of /src/Api/Vault/Controllers/CiphersController.cs gets a parameter from a user request from id. This parameter value flows ...
Attack Vector
4 MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 1519
detailsMethod at line 1519 of /src/Api/Vault/Controllers/CiphersController.cs gets a parameter from a user request from id. This parameter value flows ...
Attack Vector
5 MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 1395
detailsMethod at line 1395 of /src/Api/Vault/Controllers/CiphersController.cs gets a parameter from a user request from id. This parameter value flows ...
Attack Vector
Fixed Issues (3)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
MEDIUM CSRF /src/Api/Billing/Controllers/VNext/AccountBillingVNextController.cs: 98
MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 211
MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 293

@mzieniukbw mzieniukbw changed the title [PM-27281] Support v2 account registration on JIT master password signups [PM-27281] Support v2 account encryption on JIT master password signups Dec 28, 2025
@mzieniukbw mzieniukbw requested a review from quexten December 28, 2025 12:11
@mzieniukbw mzieniukbw marked this pull request as ready for review December 31, 2025 11:45
@mzieniukbw mzieniukbw requested review from a team as code owners December 31, 2025 11:45
@mzieniukbw mzieniukbw requested a review from rr-bw December 31, 2025 11:45
@mzieniukbw mzieniukbw marked this pull request as draft January 1, 2026 13:09
@mzieniukbw
Copy link
Contributor Author

Adding test coverage, turning to draft for now

Copy link
Contributor

@quexten quexten left a comment

Choose a reason for hiding this comment

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

I see you moved this to draft; Adding the comments I had so far.

@mzieniukbw mzieniukbw marked this pull request as ready for review January 2, 2026 12:54
@mzieniukbw mzieniukbw marked this pull request as draft January 2, 2026 13:11
@mzieniukbw mzieniukbw marked this pull request as ready for review January 2, 2026 15:03
@mzieniukbw
Copy link
Contributor Author

Test coverage added, redy to review

@mzieniukbw mzieniukbw requested a review from quexten January 2, 2026 15:04
@ike-kottlowski ike-kottlowski self-requested a review January 2, 2026 20:03
Copy link
Contributor

@mkincaid-bw mkincaid-bw left a comment

Choose a reason for hiding this comment

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

Couple minor things.

Copy link
Contributor

@ike-kottlowski ike-kottlowski left a comment

Choose a reason for hiding this comment

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

Just a few comments mainly around test coverage and possible improvements therein.

Copy link
Contributor

@quexten quexten left a comment

Choose a reason for hiding this comment

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

Very nice work! I don't have much to comment on this / concerns were addressed or are addressed at some point in the future in other work.

Copy link
Contributor

@mkincaid-bw mkincaid-bw left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@ike-kottlowski ike-kottlowski left a comment

Choose a reason for hiding this comment

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

Excellent test coverage, thank you! Just a non-blocking ๐ŸŽจ comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

๐ŸŽจ : We try to not name things V1/Vn because of the ambiguity that comes with it. I think something akin to SetInitialMasterPasswordWithSymetricKeyEncryptionCommand - really rolls off the tongue ๐Ÿซ  - is not ambiguous.

The current SetInitialMasterPasswordCommand could be SetInitialMasterPasswordWithCborEncryptionCommand. The usage can be denoted with comments in code pointing to the preferred when creating a password, so developers know which command to prefer.

This is not a blocker, but I think removes ambiguity from the code.

@mzieniukbw mzieniukbw merged commit 2e92a53 into main Jan 9, 2026
106 checks passed
@mzieniukbw mzieniukbw deleted the km/pm-27281-v2-encryption-on-jit-password-signups branch January 9, 2026 08:17
mzieniukbw added a commit to bitwarden/sdk-internal that referenced this pull request Jan 9, 2026
## ๐ŸŽŸ๏ธ Tracking

https://bitwarden.atlassian.net/browse/PM-27277

## ๐Ÿ“” Objective

Encryption V2 for SSO JIT master password account registration.

Changed the default Kdf for Encryption V2 accounts, which uses Argon2Id
with more iOS mobile friendly parameters (less memory, but more
iterations). Refactored the Kdf default functions, so we only expose
`Kdf::default_pbkdf2` or `Kdf::default_argon2id`.

Requires bitwarden/server#6777, for the
autogenerated models, which is manually committed in `bitwarden-api-api`
crate temporarily, until the server PR is done.

Updated WASM build script only to format autogenerated TS files, since
the JS file got too big for `npm prettier` to handle and is not
necessary for non-TS files.

## ๐Ÿšจ Breaking Changes

None, new functionality.

## โฐ Reminders before review

- Contributor guidelines followed
- All formatters and local linters executed and passed
- Written new unit and / or integration tests where applicable
- Protected functional changes with optionality (feature flags)
- Used internationalization (i18n) for all UI strings
- CI builds passed
- Communicated to DevOps any deployment requirements
- Updated any necessary documentation (Confluence, contributing docs) or
informed the documentation
  team

## ๐Ÿฆฎ Reviewer guidelines

<!-- Suggested interactions but feel free to use (or not) as you desire!
-->

- ๐Ÿ‘ (`:+1:`) or similar for great changes
- ๐Ÿ“ (`:memo:`) or โ„น๏ธ (`:information_source:`) for notes or general info
- โ“ (`:question:`) for questions
- ๐Ÿค” (`:thinking:`) or ๐Ÿ’ญ (`:thought_balloon:`) for more open inquiry
that's not quite a confirmed
  issue and could potentially benefit from discussion
- ๐ŸŽจ (`:art:`) for suggestions / improvements
- โŒ (`:x:`) or โš ๏ธ (`:warning:`) for more significant problems or
concerns needing attention
- ๐ŸŒฑ (`:seedling:`) or โ™ป๏ธ (`:recycle:`) for future improvements or
indications of technical debt
- โ› (`:pick:`) for minor or nitpick changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants