From 026a5c6e6c401e61c05e4ee6787f17e67cd1705a Mon Sep 17 00:00:00 2001 From: LinYushen Date: Tue, 9 Jun 2026 14:50:40 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"MUL-3132:=20harden=20/uploads/*=20(au?= =?UTF-8?q?th,=20no=20listing,=20nosniff,=20tight=20CSP)=20(#=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 8ff68502fcdbdcae19e5d1460953e08b2903f52d. --- server/cmd/server/router.go | 37 +- server/internal/handler/file.go | 95 --- server/internal/handler/local_upload.go | 140 ----- server/internal/handler/local_upload_test.go | 621 ------------------- server/internal/storage/local.go | 51 -- server/internal/storage/local_signed.go | 130 ---- server/internal/storage/local_signed_test.go | 162 ----- server/internal/storage/local_test.go | 87 --- 8 files changed, 3 insertions(+), 1320 deletions(-) delete mode 100644 server/internal/handler/local_upload.go delete mode 100644 server/internal/handler/local_upload_test.go delete mode 100644 server/internal/storage/local_signed.go delete mode 100644 server/internal/storage/local_signed_test.go diff --git a/server/cmd/server/router.go b/server/cmd/server/router.go index 406860bf13..d2674d634a 100644 --- a/server/cmd/server/router.go +++ b/server/cmd/server/router.go @@ -449,42 +449,11 @@ func NewRouterWithOptions(pool *pgxpool.Pool, hub *realtime.Hub, bus *events.Bus realtime.HandleWebSocket(hub, mc, pr, slugResolver, w, r) }) - // Local file serving (when using local storage). - // - // The disclosure (security-findings-2026-06-02) explicitly flagged this - // route as a layer in the SVG-XSS chain: it was unauthenticated, served - // directory listings, and lacked nosniff/CSP. The primary fix (PR #3023) - // broke the inline-render step by forcing Content-Disposition: attachment - // for non-media types, but the layered defenses here stay open until we - // add them. - // - // Auth dispatch is two-track: - // - Signed-query (?exp=&sig=): the route bypasses middleware.Auth and - // ServeLocalUpload validates the HMAC signature itself. This is the - // path used by token-auth clients (Desktop, legacy-token Web, - // mobile) for inline /