Skip to content

Conversation

@quexten
Copy link
Contributor

@quexten quexten commented Oct 29, 2025

🎟️ Tracking

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

📔 Objective

This is part of a set of changes getting rid of decrypt on EncString which must be removed to get rid of active user state. This PR specifically forces the use of the passed in key, instead of relying on decrypt implementations to dynamically get a key based on userid / orgid.

The now unused parameters will be removed in a subsequent PR.

Vault will eventually drop the typescript implementation here, but until then this updates the code to no longer use orgid / userid as parameters, so that in a later PR we can get rid of it in platform code. All that is passed through is the decryption key.

📸 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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 29, 2025

Logo
Checkmarx One – Scan Summary & Details9a86ab18-7876-4298-82ee-18e936987029

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

@quexten quexten changed the title Remove orgid in vault decryption code [PM-27591] Remove orgid in vault decryption code Oct 29, 2025
@quexten quexten marked this pull request as ready for review October 29, 2025 17:37
@quexten quexten requested review from a team as code owners October 29, 2025 17:37
@quexten quexten marked this pull request as draft October 29, 2025 17:38
@claude

This comment was marked as resolved.

@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 79.06977% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.63%. Comparing base (275c6a9) to head (cfe2bc8).
⚠️ Report is 7 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/cli/src/commands/edit.command.ts 0.00% 3 Missing ⚠️
apps/cli/src/commands/get.command.ts 0.00% 2 Missing ⚠️
apps/cli/src/vault/create.command.ts 0.00% 2 Missing ⚠️
libs/common/src/vault/models/domain/cipher.ts 90.90% 1 Missing ⚠️
...src/importers/bitwarden/bitwarden-json-importer.ts 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17099      +/-   ##
==========================================
+ Coverage   40.53%   40.63%   +0.09%     
==========================================
  Files        3531     3531              
  Lines      101035   101073      +38     
  Branches    15127    15123       -4     
==========================================
+ Hits        40956    41068     +112     
+ Misses      58341    58272      -69     
+ Partials     1738     1733       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@quexten quexten marked this pull request as ready for review October 29, 2025 18:51
@quexten quexten requested a review from djsmith85 October 29, 2025 19:55
Copy link
Contributor

@djsmith85 djsmith85 left a comment

Choose a reason for hiding this comment

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

❓ I don't see any changes related to send models. Are the changes on the send-specs necessary

@quexten
Copy link
Contributor Author

quexten commented Nov 3, 2025

❓ I don't see any changes related to send models. Are the changes on the send-specs necessary

@djsmith85 Yes, one of the follow-up PR's that changes EncString would otherwise break the vault tests. If you prefer I can move the spec changes to there, but that just means one extra vault review.

@quexten quexten requested a review from djsmith85 November 6, 2025 13:37
djsmith85
djsmith85 previously approved these changes Nov 10, 2025
dereknance
dereknance previously approved these changes Nov 10, 2025
Copy link
Collaborator

@nick-livefront nick-livefront left a comment

Choose a reason for hiding this comment

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

Much improved! I'm only requesting changes for moving the assertNonNullish within the respective try/catch. If I'm missing something there feel free to point it out!

@quexten quexten dismissed stale reviews from dereknance and djsmith85 via 793eb74 November 10, 2025 16:06
// We will refactor the EncString.decrypt() in https://bitwarden.atlassian.net/browse/PM-3762 to remove the dependency on the organizationId.
async decrypt(encKey: SymmetricCryptoKey): Promise<CipherView> {
async decrypt(userKeyOrOrgKey: SymmetricCryptoKey): Promise<CipherView> {
assertNonNullish(userKeyOrOrgKey, "userKeyOrOrgKey", "Cipher decryption");

This comment was marked as duplicate.

}

let folderView = await folder.decrypt();
const userKey = await firstValueFrom(this.keyService.userKey$(activeUserId));
Copy link

Choose a reason for hiding this comment

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

⚠️ This line is not covered by tests. Consider adding test coverage for the userKey retrieval and folder decryption with explicit key passing.

private async getFolder(id: string) {
let decFolder: FolderView = null;
const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
const userKey = await firstValueFrom(this.keyService.userKey$(activeUserId));
Copy link

Choose a reason for hiding this comment

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

⚠️ This line is not covered by tests. Consider adding test coverage for the userKey retrieval path.

private async createFolder(req: FolderExport) {
const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
const userKey = await this.keyService.getUserKey(activeUserId);
const userKey = await firstValueFrom(this.keyService.userKey$(activeUserId));
Copy link

Choose a reason for hiding this comment

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

⚠️ This line is not covered by tests. Consider adding test coverage for the userKey retrieval using the Observable pattern.

}
}

await this.decryptObj<Cipher, CipherView>(
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ should we also update the decryptObj method and remove the orgId parameter since we always pass null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially it was split this wait to try to have the changes limited to vault, but that failed and we had to drag in tools / platform anyways, so you're right. It can be removed. cfe2bc8

@quexten quexten requested review from dereknance and djsmith85 and removed request for jaasen-livefront November 10, 2025 17:27
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.

6 participants