[PM-33500] - delete attachments from deleted ciphers#7208
Open
jaasen-livefront wants to merge 1 commit intomainfrom
Open
[PM-33500] - delete attachments from deleted ciphers#7208jaasen-livefront wants to merge 1 commit intomainfrom
jaasen-livefront wants to merge 1 commit intomainfrom
Conversation
|
Contributor
|
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7208 +/- ##
==========================================
+ Coverage 57.44% 57.46% +0.01%
==========================================
Files 2032 2032
Lines 89410 89428 +18
Branches 7951 7954 +3
==========================================
+ Hits 51366 51388 +22
+ Misses 36201 36196 -5
- Partials 1843 1844 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
JaredScar
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-33500
📔 Objective
Fix orphaned attachment files left behind when ciphers are deleted in bulk, an organization vault is purged, or an organization is deleted.
When a single cipher is deleted via
CipherService.DeleteAsync, attachment files are properly removed from blob/disk storage viaDeleteAttachmentsForCipherAsync. However, three other deletion paths only removed DB records, leaving attachment files permanently orphaned in storage:CipherService.DeleteManyAsync(bulk cipher delete) — deleted cipher rows but never cleaned up attachment storage.CipherService.PurgeAsync(org vault purge) — deleted cipher rows but never cleaned up attachment storage.OrganizationDeleteCommand.DeleteAsync(org deletion) — cascade-deleted cipher rows via SQL stored proc but never cleaned up attachment storage.Changes
CipherService.DeleteManyAsync: After DB deletion, iterate deleted ciphers and callDeleteAttachmentsForCipherAsyncfor each.CipherService.PurgeAsync: Fetch org cipher IDs before DB deletion, then clean up each cipher's attachments after.OrganizationDeleteCommand.DeleteAsync: InjectICipherRepositoryandIAttachmentStorageService. Fetch org cipher IDs before DB cascade delete, then clean up each cipher's attachments after.DeleteManyAsync(org admin + personal owner paths) andOrganizationDeleteCommand.Delete_Successto assert attachment cleanup. Added newPurgeAsync_WithOrganizationId_DeletesCiphersAndAttachmentstest.📸 Screenshots