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.

Keep infrastructure credentials inside their configured HTTP origin

pulse-triage[bot]971d403d014e
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index fc31225841..d58162dc6c 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -18,6 +18,33 @@
## Purpose
+### Infrastructure credentials remain within the configured HTTP origin
+
+The shared `tlsutil.CreateHTTPClientWithTimeout` transport permits redirects
+only within the first request's scheme, hostname and effective port. This
+protects token and ticket headers, CSRF headers and replayable password bodies
+before a redirected request reaches another service, subdomain or plaintext
+endpoint. Redirect userinfo and invalid authorities are refused. Hostname
+case, default ports and equivalent IPv6 literals are canonicalised; IPv6 zone
+case remains significant. The existing ten-redirect limit and same-origin
+proxy path/query redirects remain supported.
+
+System CA checks, configured leaf pins, the TLS floor, explicit verification
+opt-outs, initial HTTP configuration, DNS/proxy routing and independent cluster
+member admission do not change. Guest-agent commands and backup-lock evidence
+retain their stricter no-redirect policy, including same-origin redirects; an
+ordinary read's policy cannot admit a redirected guest command.
+
+`TestInfrastructureRedirectOriginPolicy`,
+`TestInfrastructureRedirectChainAndLimit` and
+`TestCreateHTTPClientRedirectAuthorityValidation` pin the shared boundary.
+`TestInfrastructureRedirectRefusesConnectedOriginChanges` uses actual owned
+TLS/plaintext sockets in CA, pin and explicit opt-out modes. PVE and PBS
+`client_redirect_test.go` exercise actual token, ticket/CSRF and password
+JSON/form flows plus retained same-origin proxy reads with synthetic credentials.
+These are bounded source controls, not an installed connection or an observed
+credential incident.
+
### Certificate capture uses the connection's socket authority
`tlsutil.FetchFingerprint` selects an explicit HTTP(S) URL's host and port,
diff --git a/pkg/tlsutil/fingerprint.go b/pkg/tlsutil/fingerprint.go
index d587d73b99..8f7a602939 100644
--- a/pkg/tlsutil/fingerprint.go
+++ b/pkg/tlsutil/fingerprint.go
@@ -214,6 +214,52 @@ func proxyFromEnvironmentBypassingLocalInfrastructure(req *http.Request) (*url.U
return http.ProxyFromEnvironment(req)
}
+// Infrastructure requests can carry tokens, tickets, CSRF headers or replayable
+// login bodies. Go's default redirect policy does not bind those to a port or
+// scheme, and may forward some credentials to subdomains. Allow proxy path
+// redirects only within the first request's origin, before any redirected dial.
+func infrastructureRedirectPolicy(req *http.Request, via []*http.Request) error {
+ if len(via) >= 10 {
+ return fmt.Errorf("stopped after 10 redirects")
+ }
+ if req == nil || len(via) == 0 || via[0] == nil {
+ return fmt.Errorf("infrastructure redirects require an original request")
+ }
+ origin, originErr := infrastructureRedirectOrigin(via[0].URL)
+ destination, destinationErr := infrastructureRedirectOrigin(req.URL)
+ if originErr != nil || destinationErr != nil || origin != destination {
+ return fmt.Errorf("infrastructure redirects must stay on the same origin")
+ }
+ return nil
+}
+
+func infrastructureRedirectOrigin(u *url.URL) (string, error) {
+ if u == nil || u.User != nil || u.Opaque != "" || (u.Scheme != "http" && u.Scheme != "https") || u.Hostname() == "" {
+ return "", fmt.Errorf("invalid HTTP origin")
+ }
+ host := u.Hostname()
+ if address, err := netip.ParseAddr(host); err == nil {
+ host = address.String() // Canonical IPv6, preserving zone case.
+ } else {
+ host = strings.ToLower(host)
+ }
+ port := u.Port()
+ if port == "" {
+ if strings.HasSuffix(u.Host, ":") {
+ return "", fmt.Errorf("port is empty")
+ }
+ port = "443"
+ if u.Scheme == "http" {
+ port = "80"
+ }
+ }
+ number, err := strconv.ParseUint(port, 10, 16)
+ if err != nil || number == 0 {
+ return "", fmt.Errorf("port must be between 1 and 65535")
+ }
+ return u.Scheme + "://" + net.JoinHostPort(host, strconv.FormatUint(number, 10)), nil
+}
+
// CreateHTTPClient creates an HTTP client with appropriate TLS configuration
func CreateHTTPClient(verifySSL bool, fingerprint string) *http.Client {
return CreateHTTPClientWithTimeout(verifySSL, fingerprint, 60*time.Second)
@@ -253,7 +299,8 @@ func CreateHTTPClientWithTimeout(verifySSL bool, fingerprint string, timeout tim
}
return &http.Client{
- Transport: transport,
- Timeout: timeout,
+ Transport: transport,
+ Timeout: timeout,
+ CheckRedirect: infrastructureRedirectPolicy,
}
}
diff --git a/pkg/tlsutil/tlsutil_test.go b/pkg/tlsutil/tlsutil_test.go
index da4dbf4641..3109fa1ea1 100644
--- a/pkg/tlsutil/tlsutil_test.go
+++ b/pkg/tlsutil/tlsutil_test.go
@@ -13,6 +13,55 @@ import (
"time"
)
+func TestCreateHTTPClientRedirectAuthorityValidation(t *testing.T) {
+ for _, mode := range []struct {
+ name string
+ verify bool
+ fingerprint string
+ }{
+ {"ca", true, ""},
+ {"pin", true, strings.Repeat("a", 64)},
+ {"explicit-opt-out", false, ""},
+ } {
+ t.Run(mode.name, func(t *testing.T) {
+ client := CreateHTTPClient(mode.verify, mode.fingerprint)
+ if client.CheckRedirect == nil {
+ t.Fatal("infrastructure client uses the unrestricted default redirect policy")
+ }
+ for _, pair := range []struct {
+ name, original, target string
+ allowed bool
+ }{
+ {"default-port", "https://pve.test", "https://PVE.test:0443/path", true},
+ {"ipv6", "https://[::1]:443", "https://[0:0:0:0:0:0:0:1]/path", true},
+ {"zone", "https://[fe80::1%25eth0]", "https://[fe80::1%25eth0]/path", true},
+ {"zone-case", "https://[fe80::1%25eth0]", "https://[fe80::1%25ETH0]/path", false},
+ {"empty-port", "https://pve.test", "https://pve.test:/path", false},
+ {"zero-port", "https://pve.test", "https://pve.test:0/path", false},
+ {"port-overflow", "https://pve.test", "https://pve.test:65536/path", false},
+ } {
+ t.Run(pair.name, func(t *testing.T) {
+ original, err := url.Parse(pair.original)
+ if err != nil {
+ t.Fatal(err)
+ }
+ target, err := url.Parse(pair.target)
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = client.CheckRedirect(&http.Request{URL: target}, []*http.Request{{URL: original}})
+ if (err == nil) != pair.allowed {
+ t.Fatalf("origin comparison allowed=%t: %v", pair.allowed, err)
+ }
+ })
+ }
+ if client.CheckRedirect(nil, nil) == nil || client.CheckRedirect(&http.Request{}, []*http.Request{nil}) == nil {
+ t.Fatal("missing origin evidence admitted a redirect")
+ }
+ })
+ }
+}
+
func TestFingerprintVerifier_NormalizesFingerprint(t *testing.T) {
// Fingerprint with colons
fp1 := "AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99"