fix(api): download attachments instead of rendering them inline#368
fix(api): download attachments instead of rendering them inline#368cavidelizade wants to merge 1 commit into
Conversation
Attachment uploads don't validate content-type, and ServeFile streamed every object back with Content-Disposition: inline. A member could upload an HTML file (or an SVG with script) and have it execute on the API origin when another member opened the attachment URL. Force Content-Disposition: attachment for the attachments/ prefix so the browser downloads rather than renders it. The uploads/ prefix (avatars, covers, logos) is validated as images and stays inline. Closes Devlaner#328 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Attachment uploads don't validate content-type, and
ServeFilestreamed every object back withContent-Disposition: inline. A member could upload an HTML file (or an SVG with script) and have it execute on the API origin when another member opened the attachment URL.Linked issues
Closes #328
Type of change
fix:)Surface
apps/api/)What changed
ServeFilenow forcesContent-Disposition: attachmentfor theattachments/prefix, so the browser downloads the file rather than rendering it. Theuploads/prefix (avatars, covers, logos) is validated as images and staysinline.Test plan
go build,go vet,go test ./...greenContent-Disposition: attachmentthe browser won't render the response in-page regardless of its declared type, which neutralizes the stored-XSS vectorNote
This is the low-risk mitigation. Validating/allow-listing content-type on upload (like the image path does) would be a good follow-up, but forcing download closes the XSS on its own.
AI assistance
Claude Code (Opus 4.8), commits carry aCo-Authored-By:trailer