From 73bfeb00d0aaae1a9c11dd87ad5dcca8f82e8266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 10 Nov 2026 12:59:25 +0100 Subject: [PATCH] fix(middleware): do not build the XFF middleware without trusted proxies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Starting with chi v5.4.0, ClientIPFromXFF panics when no trusted prefix is given, so ClientIP would crash the proxy and collaboration services at startup when no trusted proxies are configured. Without trusted proxies every request uses the network address anyway, so return ClientIPFromRemoteAddr. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Jörn Friedrich Dreyer --- pkg/middleware/client_ip.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/middleware/client_ip.go b/pkg/middleware/client_ip.go index 1c0847210f..2b91a9fa58 100644 --- a/pkg/middleware/client_ip.go +++ b/pkg/middleware/client_ip.go @@ -60,6 +60,11 @@ func ParseTrustedProxies(list []string) ([]netip.Prefix, error) { // e.g. X-Real-IP or CF-Connecting-IP, it is its value. Without a usable // header, e.g. on health checks, it is the address of the proxy. func ClientIP(trusted []netip.Prefix, header string) func(http.Handler) http.Handler { + if len(trusted) == 0 { + // nobody may set the header, and chi's ClientIPFromXFF panics without + // a trusted prefix + return chimiddleware.ClientIPFromRemoteAddr + } cidrs := make([]string, len(trusted)) for i, p := range trusted { cidrs[i] = p.String()