[PM-2572] Add new cipher encryption on attachments without key when moving cipher to an org#3238
[PM-2572] Add new cipher encryption on attachments without key when moving cipher to an org#3238LRNcardozoWDF wants to merge 3957 commits intomainfrom
Conversation
Co-authored-by: bitwarden-devops-bot <106330231+bitwarden-devops-bot@users.noreply.github.com>
* Update AppResources.af.resx * Update AnonAddy references * Reverted AnonAddy to AddyIo refactor, keeping text and url changes --------- Co-authored-by: Andre Rosado <arosado@bitwarden.com>
* [PM-3606] Fix 2FA for autofill * [PM-3606] Fix autofill when user doesn't have a login method available. * [PM-3606] PR fixes * [PM-3606] Add logout logic to other extension projects * [PM-3606] Move code to base class. * Transform into property instead of field Co-authored-by: Federico Maccaroni <fedemkr@gmail.com> * Remove double ";" Co-authored-by: Federico Maccaroni <fedemkr@gmail.com> * [PM-3606] Fix iOS extension by changing base class of LockPasswordViewController --------- Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
Co-authored-by: bitwarden-devops-bot <106330231+bitwarden-devops-bot@users.noreply.github.com>
…cally log out TDE users (#2747) * [PM-3393] Log user out on biometric exceed attempts * [PM-3393] Move duplicated code to AppHelpers * [PM-3393] Update copy on new pop up * [PM-3393] Moved VaultTimeoutService to LazyResolve. * [PM-3382] Change IVaultTimeoutService for messaging * [PM-3393] Use default values.
…roduction environments (#2773)
Co-authored-by: bitwarden-devops-bot <106330231+bitwarden-devops-bot@users.noreply.github.com>
* [PM-3726] prevent legacy user login * [PM-3726] prevent unlock or auto key migration if legacy user * [PM-3726] add legacy checks to lock page and refactor * [PM-3726] rethrow exception from pin * formatting * [PM-3726] add changes to LockViewController, consolidate logout calls * formatting * [PM-3726] pr feedback * generate resx * formatting
Co-authored-by: bitwarden-devops-bot <106330231+bitwarden-devops-bot@users.noreply.github.com>
Co-authored-by: bitwarden-devops-bot <106330231+bitwarden-devops-bot@users.noreply.github.com>
* PM-3811 Unified passkeys view and moved both inside Login as an array of FIdo2Key * PM-3811 Passkeys unification => updated cipher details view an helpers * PM-3811 Updated passkeys creation date time format
Co-authored-by: bitwarden-devops-bot <106330231+bitwarden-devops-bot@users.noreply.github.com>
…oard for autofill (#2764) * [PM-3446] Check if user has mp and allow autofill to use items with mp re-prompt
* [PM-2658] Settings Reorganization Init (#2697) * PM-2658 Started settings reorganization (settings main + vault + about) * PM-2658 Added settings controls based on templates and implemented OtherSettingsPage * PM-2658 Fix format * [PM-3512] Settings Appearance (#2703) * PM-3512 Implemented new Appearance Settings * PM-3512 Fix format * [PM-3510] Implement Account Security Settings view (#2714) * PM-3510 Implemented Security settings view * PM-3510 Fix format * PM-3510 Added empty placeholder to pending login requests and also improved a11y on security settings view. * PM-3511 Implemented autofill settings view (#2735) * [PM-3695] Add Connect to Watch to Other settings (#2736) * PM-3511 Implemented autofill settings view * PM-3695 Add Connect to watch setting to other settings view * [PM-3693] Clear old Settings approach (#2737) * PM-3511 Implemented autofill settings view * PM-3693 Remove old Settings approach * PM-3845 Fix default dark theme description verbiage (#2759) * PM-3839 Fix allow screen capture and submit crash logs to init their state when the page appears (#2760) * PM-3834 Fix dialogs strings on settings (#2758) * [PM-3834] Fix import items link (#2782) * PM-3834 Fix import items link * PM-3834 Fix import items link, removed old link. * [PM-4092] Fix vault timeout policies on new Settings (#2796) * PM-4092 Fix vault timeout policy on settings for disabling controls and reset timeout when surpassing maximum * PM-4092 Removed testing hardcoding of policy data
* PM-115 Added new cipher key and encryption/decryption mechanisms on cipher * PM-115 fix format * PM-115 removed ForceKeyRotation from new cipher encryption model given that another approach will be taken * [PM-1690] Added minimum server version restriction to cipher key encryption (#2463) * PM-1690 added minimum server version restriction to cipher key encryption and also change the force key rotation flag * PM-1690 Updated min server version for new cipher encryption key and fixed configService registration * PM-1690 removed forcekeyrotation * PM-115 Temporarily Changed cipher key new encryption config to help testing (this change should be reseted eventually) * PM-2456 Fix attachment encryption on new cipher item encryption model (#2556) * PM-2531 Fix new cipher encryption on adding attachments on ciphers with no item level key (#2559) * PM-115 Changed temporarily cipher key encryption min server version to 2023.6.0 to test * PM-115 Reseted cipher key encryption minimum server version to 2023.5.0 and disable new cipher key on local cipher creation * Added Key value to the cipher export model (#2628) * Update Constants.cs Updated minimum encryption server version to 2023.9.0 so QA can test its behavior * PM-115 Fix file format * PM-115 Changed new encryption off and minimum new encryption server version to 2023.8.0 for testing purposes * PM-115 Changed CIpher key encryption minimum server version to 2023.9.0 * PM-3737 Remove suffix on client version sent to server (#2779) * PM-115 QA testing server min version and enable new cipher key encryption * PM-115 Disable new cipher encryption creation and change minimum server encryption version to 2023.9.1 --------- Co-authored-by: aj-rosado <109146700+aj-rosado@users.noreply.github.com>
* [PM-868] Check for previous page before loading vault. Remove exception throw. * [PM-868] Continue to throw exceptions
Co-authored-by: bitwarden-devops-bot <106330231+bitwarden-devops-bot@users.noreply.github.com>
Co-authored-by: bitwarden-devops-bot <106330231+bitwarden-devops-bot@users.noreply.github.com>
* [PM-3741] [PM-3750] Improvements to local storage handling * Update src/Android/MainActivity.cs Co-authored-by: Federico Maccaroni <fedemkr@gmail.com> --------- Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
Co-authored-by: bitwarden-devops-bot <106330231+bitwarden-devops-bot@users.noreply.github.com>
Co-authored-by: bitwarden-devops-bot <106330231+bitwarden-devops-bot@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
src/Core/Services/CipherService.cs
Outdated
| if(cipherView.Key == null) | ||
| { | ||
| foreach (var attachment in cipher.Attachments) | ||
| cipher = await EncryptAsync(cipherView); | ||
| var putCipherRequest = new CipherRequest(cipher); | ||
| var putCipherResponse = await _apiService.PutCipherAsync(cipherView.Id, putCipherRequest); | ||
| var cipherData = new CipherData(putCipherResponse, await _stateService.GetActiveUserIdAsync()); | ||
| await UpsertAsync(cipherData); | ||
| cipher = await GetAsync(cipherView.Id); | ||
| cipherView = await cipher.DecryptAsync(); | ||
| } |
There was a problem hiding this comment.
💡 Nice idea to update the cipher key here if it doesn't have one before updating the attachments.
🤔 I think that doing this you don't need the CipherKey in the Attachment neither the cipherKey added in the StringContent for the MultipartFormDataContent. Because I don't see a situation where the cipher doesn't have an item level encryption key and the attachment is migrated with it. Did you find one and that's why you left the CipherKey in the attachment?
🎨 Could you extract the common parts into a method (can be local function as you want)? So it's shared with lines 604...609
There was a problem hiding this comment.
Well, that was my interpretation of the steps in the task. I honestly thought we were just being extra careful.
Co-authored-by: bitwarden-devops-bot <106330231+bitwarden-devops-bot@users.noreply.github.com>
src/Core/Services/CipherService.cs
Outdated
| if (cipher.Attachments != null) | ||
| Cipher cipher = null; | ||
| //If the cipher doesn't have a key, we update it | ||
| if(cipherView.Key == null) |
There was a problem hiding this comment.
🎨 I think we could improve this checking if we should use cipher key encryption by calling ShouldUseCipherKeyEncryptionAsync, so we save a sever call if that's not the case.
src/Core/Services/CipherService.cs
Outdated
| { | ||
| foreach (var attachment in cipher.Attachments) | ||
| cipher = await EncryptAsync(cipherView); | ||
| await UpdateAndUpsertAsync(async () => await _apiService.PutCipherAsync(cipherView.Id, new CipherRequest(cipher))); |
There was a problem hiding this comment.
⛏️ You can omit the async and await inside the lambda.
src/Core/Services/CipherService.cs
Outdated
| await UpsertAsync(data); | ||
| cipherView.OrganizationId = organizationId; | ||
| cipherView.CollectionIds = collectionIds; | ||
| cipher = await EncryptAsync(cipherView); |
There was a problem hiding this comment.
🎨 You can move encrypting into UpdateAndUpsertAsync as well.
There was a problem hiding this comment.
I didn't do that because I need the cipher to create two different requests, CipherRequest and CipherShareRequest. I could add in the api call but I think there's already too much happening in one line of code.
await UpdateAndUpsertAsync(async () => await _apiService.PutShareCipherAsync(cipherView.Id, new CipherShareRequest(await EncryptAsync(cipherView))), collectionIds);
There was a problem hiding this comment.
Oh I see, I think it's fine to pass the CipherView as a parameter to the func to construct such requests.
src/Core/Services/CipherService.cs
Outdated
| } | ||
| } | ||
|
|
||
| private async Task UpdateAndUpsertAsync(Func<Task<CipherResponse>> func, HashSet<string> collectionIds = null) |
There was a problem hiding this comment.
⛏️ I'd rename the func parameter to callPutCipherApi or something that indicates the purpose of such func.
fedemkr
left a comment
There was a problem hiding this comment.
Great just one small thing and it's done 😄 🎉
src/Core/Services/CipherService.cs
Outdated
| if (cipher.Attachments != null) | ||
| Cipher cipher = null; | ||
| //If the cipher doesn't have a key, we update it | ||
| if(await ShouldUseCipherKeyEncryptionAsync() && cipherView.Key == null) |
There was a problem hiding this comment.
⛏️ Invert the order so it doesn't waste time firing the task when Key != null
| if(await ShouldUseCipherKeyEncryptionAsync() && cipherView.Key == null) | |
| if (cipherView.Key == null && await ShouldUseCipherKeyEncryptionAsync()) |
Co-authored-by: bitwarden-devops-bot <106330231+bitwarden-devops-bot@users.noreply.github.com>
Co-authored-by: bitwarden-devops-bot <106330231+bitwarden-devops-bot@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…h-actions/download-artifacts` (#3278)
Co-authored-by: bitwarden-devops-bot <106330231+bitwarden-devops-bot@users.noreply.github.com>
Type of change
Objective
When an attachment file gets reencrypted and reuploaded, the new key is ignored by the server. This PR prepares the fix for the mobile side by adding the cipher.key in the attachment's metadata.
Code changes
Before you submit
dotnet format --verify-no-changes) (required)