mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-19 10:33:29 +00:00
Reject recovery via untrusted XFF
This commit is contained in:
parent
b35de694bb
commit
d257815564
1 changed files with 25 additions and 0 deletions
25
internal/api/recovery_proxy_bypass_test.go
Normal file
25
internal/api/recovery_proxy_bypass_test.go
Normal file
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue