From 1fddbec07f64d59a3092f2fcd3d5a78d69179146 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Wed, 4 Feb 2026 12:05:32 +0000 Subject: [PATCH] Ensure public download endpoints bypass auth --- internal/api/security_regression_test.go | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/internal/api/security_regression_test.go b/internal/api/security_regression_test.go index b7e11b243..f58ded1c7 100644 --- a/internal/api/security_regression_test.go +++ b/internal/api/security_regression_test.go @@ -2737,6 +2737,39 @@ func TestSetupScriptIsPublicEvenWhenAuthConfigured(t *testing.T) { } } +func TestPublicDownloadEndpointsBypassAuth(t *testing.T) { + cfg := newTestConfigWithTokens(t) + cfg.AuthUser = "admin" + cfg.AuthPass = "hashed" + router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0") + + paths := []string{ + "/install-docker-agent.sh", + "/install-container-agent.sh", + "/download/pulse-docker-agent", + "/install-host-agent.sh", + "/install-host-agent.ps1", + "/uninstall-host-agent.sh", + "/uninstall-host-agent.ps1", + "/download/pulse-host-agent", + "/install.sh", + "/install.ps1", + "/download/pulse-agent", + } + + for idx, path := range paths { + ip := "203.0.113." + strconv.Itoa(70+idx) + ResetRateLimitForIP(ip) + req := httptest.NewRequest(http.MethodPost, path, nil) + req.RemoteAddr = ip + ":1234" + rec := httptest.NewRecorder() + router.Handler().ServeHTTP(rec, req) + if rec.Code != http.StatusMethodNotAllowed { + t.Fatalf("expected 405 for public download endpoint %s, got %d", path, rec.Code) + } + } +} + func TestOIDCLoginBypassesAuth(t *testing.T) { cfg := newTestConfigWithTokens(t) cfg.AuthUser = "admin"