From dddcc2bc93c15df4d9b6a38e7f9a76d01fe8b384 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Fri, 28 May 2021 06:48:10 +1000 Subject: [PATCH] Add encKey validation for org import/export (#392) --- src/importers/bitwardenJsonImporter.ts | 3 ++- src/services/export.service.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/importers/bitwardenJsonImporter.ts b/src/importers/bitwardenJsonImporter.ts index 13c26b6c0d..195708c082 100644 --- a/src/importers/bitwardenJsonImporter.ts +++ b/src/importers/bitwardenJsonImporter.ts @@ -38,8 +38,9 @@ export class BitwardenJsonImporter extends BaseImporter implements Importer { private async parseEncrypted() { if (this.results.encKeyValidation_DO_NOT_EDIT != null) { + const orgKey = await this.cryptoService.getOrgKey(this.organizationId); const encKeyValidation = new EncString(this.results.encKeyValidation_DO_NOT_EDIT); - const encKeyValidationDecrypt = await this.cryptoService.decryptToUtf8(encKeyValidation); + const encKeyValidationDecrypt = await this.cryptoService.decryptToUtf8(encKeyValidation, orgKey); if (encKeyValidationDecrypt === null) { this.result.success = false; this.result.errorMessage = this.i18nService.t('importEncKeyError'); diff --git a/src/services/export.service.ts b/src/services/export.service.ts index a8b2071526..7afb69881f 100644 --- a/src/services/export.service.ts +++ b/src/services/export.service.ts @@ -289,8 +289,12 @@ export class ExportService implements ExportServiceAbstraction { await Promise.all(promises); + const orgKey = await this.cryptoService.getOrgKey(organizationId); + const encKeyValidation = await this.cryptoService.encrypt(Utils.newGuid(), orgKey); + const jsonDoc: any = { encrypted: true, + encKeyValidation_DO_NOT_EDIT: encKeyValidation.encryptedString, collections: [], items: [], };