fix(security): force attachment disposition for SVG uploads#3023
Open
tomqiaozc wants to merge 1 commit into
Open
fix(security): force attachment disposition for SVG uploads#3023tomqiaozc wants to merge 1 commit into
tomqiaozc wants to merge 1 commit into
Conversation
SVG files are XML and can carry <script>, <foreignObject>, or onload= attributes that execute in the document's origin when rendered inline. The upload handler maps .svg to image/svg+xml, and storage backends (local + S3) previously set Content-Disposition: inline based on the image/ prefix in isInlineContentType. A workspace member could upload a crafted SVG, share its attachment URL in an issue or comment, and any teammate who clicks the link would execute attacker-controlled JS in the application's first-party origin (reading auth cookies, posting to authenticated endpoints). Exclude image/svg+xml from isInlineContentType so both storage paths serve SVG with Content-Disposition: attachment. Test coverage: - New util_test.go covers the inline/attachment matrix including SVG. - Existing local_test.go ContentDisposition table gains an SVG case.
|
@tomqiaozc is attempting to deploy a commit to the IndexLabs Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
Fixes #3022.
Uploaded SVG files were served with
Content-Disposition: inlinebecauseisInlineContentTypereturnedtruefor anyimage/*MIME type. SVG is XML —<script>,<foreignObject>, andonload=execute when rendered inline — so a workspace member could upload a crafted.svg, share its attachment URL, and any clicker would execute attacker-controlled JS in the application's first-party origin (cookie theft, authenticated API calls).This PR excludes
image/svg+xmlfromisInlineContentType, so the local and S3 storage backends both serve SVG withContent-Disposition: attachment. Browsers do not run scripts in downloaded files.Why this approach
Test plan
server/internal/storage/util_test.gocoversisInlineContentTypewithimage/svg+xml→falseand the existing inline types →true.TestLocalStorage_ServeFile_ContentDispositionFromSidecarwith an SVG case assertingContent-Disposition: attachment; filename="logo.svg".make test(reviewer-side; my local environment lacks Go).