Sanitize attachment download filenames#214
Conversation
|
Findings Bounty Readiness
Tests/Evidence Needed Suggested Labels MergeOS automated readiness signals:
|
|
Maintenance note: I checked the failing Backend build and test job on this PR. The failure is the shared base/toolchain govulncheck issue from backend/go.mod using Go 1.25.10, not this PR's local test suite. govulncheck reports standard-library issues GO-2026-5039 and GO-2026-5037 fixed in Go 1.25.11 before project tests run. I opened #218 to bump backend/go.mod to Go 1.25.11. #218 is now green across Backend build and test, Secret scan, frontend/admin/scan web checks, and MergeIDE. After that toolchain patch lands and this PR is updated against it, the backend check should no longer fail on the Go 1.25.10 standard-library findings. |
MergeOS PR #214 Verification ReportPR: #214 VerdictApprove from code review and available evidence. I found no blocking issue in the attachment filename sanitization change. Scope ReviewedChanged files:
The previous download header construction only removed double quotes: strings.ReplaceAll(attachment.OriginalName, "\"", "")PR #214 routes the filename through Content-Disposition: inline; filename="..."The new helper:
That covers the important header-safety issue: a submitted filename can no longer inject a second header line through CR/LF, break out of the quoted filename with Local ChecksDiff scope: Whitespace check: Go version used for local test: Targeted backend test: Result: Test Coverage ReviewThe added tests cover the two most important cases:
The assertions verify that unsafe characters are removed and expected readable fragments are preserved. This matches the implementation and the intended security behavior. CI ReviewCurrent PR checks:
The backend failure is the same repository/toolchain baseline issue seen on nearby PRs. The log shows
Because PR #214 only changes attachment filename handling and tests, I do not treat this backend CI failure as caused by the patch. RecommendationApprove/accept after maintainer review. No required code changes from my pass. Optional future hardening, not a blocker for this PR: if the project later needs full internationalized |
Claim
Description
Attachment download filenames were written into
Content-Dispositionwithout enough header-safe cleanup for characters such as quotes, CR/LF, tabs, slashes, and backslashes.This PR sanitizes download filenames before the header is written and falls back to a safe name when cleanup leaves an empty filename.
Evidence
Before:
Content-Dispositionvalue.After:
Additional logs or test output:
go test ./internal/core -run 'TestSafeAttachmentDownloadName'->ok mergeos/backend/internal/core 0.392sgovulncheckbaseline; Bump backend Go patch version #218 updates the backend Go patch version and is green. Secret scan, web checks, and MergeIDE are passing on this PR.Safety
Tests
Bounty Checklist