[PM-32597] - create short-lived signed attachment URL for self-hosted instances#7100
Open
jaasen-livefront wants to merge 1 commit intomainfrom
Open
[PM-32597] - create short-lived signed attachment URL for self-hosted instances#7100jaasen-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❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7100 +/- ##
==========================================
- Coverage 56.76% 56.74% -0.02%
==========================================
Files 2014 2013 -1
Lines 88218 88239 +21
Branches 7855 7864 +9
==========================================
- Hits 50073 50069 -4
- Misses 36321 36348 +27
+ Partials 1824 1822 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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/VULN-386
📔 Objective
In self-hosted Bitwarden, cipher attachment download URLs were predictable (
/attachments/{cipherId}/{attachmentId}) and served by a static file server with no authentication. An attacker with knowledge of a cipher ID and attachment ID could download encrypted attachment files without authorization.Changes
Signed download URLs for local storage — When
FileUploadTypeisDirect(local/self-hosted),CipherService.GetAttachmentDownloadDataAsyncnow generates a time-limited, cryptographically signed token using ASP.NET Core Data Protection instead of returning a bare static file path. Tokens expire after 1 minute, matching the short-lived nature of Azure SAS URLs used in cloud deployments.New download endpoint — Added
GET /ciphers/attachment/download?token=...([AllowAnonymous]) toCiphersController. This endpoint validates the signed token, resolves the cipher and attachment, and streams the file. The token itself is the authorization — it can only be obtained through the existing authenticatedGET /ciphers/{id}/attachment/{attachmentId}endpoint.GetAttachmentReadStreamAsync— Added toIAttachmentStorageServiceand all implementations.LocalAttachmentStorageServicereturns aFileStream; Azure and Noop implementations returnnull(Azure uses SAS URLs directly).Null check hardening —
GetAttachmentDatanow explicitly throwsNotFoundExceptionwhen the cipher is not found.Security considerations
GET /ciphers/{id}/attachment/{attachmentId}still requires[Authorize("Application")]{cipherId}|{attachmentId}, encrypted and time-limited viaITimeLimitedDataProtectorutil/Servershould separately be configured to stop serving the/attachmentsdirectory, but this change ensures that even if it does, the API no longer returns those predictable URLsFiles changed
ParseAttachmentDownloadToken,CreateAttachmentDownloadProtectorCreateAttachmentDownloadProtector()GetAttachmentReadStreamAsyncGetAttachmentReadStreamAsyncGetAttachmentReadStreamAsync(returns null)GetAttachmentReadStreamAsync(returns null)DownloadAttachmentAsyncendpoint, null check inGetAttachmentData📸 Screenshots