Skip to content
This repository was archived by the owner on Jun 17, 2022. It is now read-only.

Conversation

@eliykat
Copy link
Member

@eliykat eliykat commented Mar 1, 2022

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

Fix bitwarden/cli#490.

encOrgKeys are never migrated properly because stateMigrationService does not reference the correct storage key - it incorrectly appends the userId to the storage key. This means that org items cannot be decrypted in CLI after an upgrade. I assume that other clients hid this issue by syncing to get account keys, whereas CLI is less automatic in this respect.

For reference, here's the setOrgKeys method immediately before account switching was merged. Note the lack of userId suffix:

return this.storageService.save(Keys.encOrgKeys, orgKeys);

The migration of provider enc keys also follow this pattern, and I also note that the pre-account switching logic doesn't have this suffix (although I haven't tested this one):

return this.storageService.save(Keys.encProviderKeys, providerKeys);

This will not help users who have already upgraded (I believe the migration clears the old v0 data, so it's gone), but will fix the issue for any late upgraders.

Code changes

Remove userId suffixes when fetching v0 org and provider keys.

Testing requirements

  1. Use an account with access to organization items
  2. Follow the upgrade path from pre-account switching to post-account switching.
  3. Confirm that all org items are available after the upgrade. Especially for CLI where this bug was first reported.

Repeat the above as a provider user who only has access to an org via their provider.

Before you submit

  • I have checked for linting errors (npm run lint) (required)
  • I have added unit tests where it makes sense to do so (encouraged but not required)
  • This change requires a documentation update (notify the documentation team)
  • This change has particular deployment requirements (notify the DevOps team)

@eliykat eliykat requested review from a team and removed request for a team March 1, 2022 00:10
@eliykat eliykat merged commit c1a37ea into master Mar 1, 2022
@eliykat eliykat deleted the fix/org-key-migration branch March 1, 2022 21:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.21.1 regressed compared to 1.19.1. bw list items became unreliable

3 participants