Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Reject recovery via untrusted XFF

rcourtmand25781556434
diff --git a/internal/api/recovery_proxy_bypass_test.go b/internal/api/recovery_proxy_bypass_test.go
new file mode 100644
index 0000000000..7590b07965
--- /dev/null
+++ b/internal/api/recovery_proxy_bypass_test.go
@@ -0,0 +1,25 @@
+package api
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+)
+
+func TestRecoveryEndpointRejectsForwardedLoopbackFromUntrustedProxy(t *testing.T) {
+ router := newRecoveryRouter(t)
+
+ // No trusted proxies configured; forwarded loopback should be rejected.
+ req := httptest.NewRequest(http.MethodPost, "/api/security/recovery", strings.NewReader(`{"action":"status"}`))
+ req.RemoteAddr = "203.0.113.77:12345"
+ req.Header.Set("Content-Type", "application/json")
+ req.Header.Set("X-Forwarded-For", "127.0.0.1")
+ rec := httptest.NewRecorder()
+
+ router.mux.ServeHTTP(rec, req)
+
+ if rec.Code != http.StatusForbidden {
+ t.Fatalf("expected 403 for forwarded loopback from untrusted proxy, got %d", rec.Code)
+ }
+}