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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Keep capped foreign redirects private and terminal
pulse-triage[bot]9188d0f442a5
diff --git a/docs/release-control/v6/internal/subsystems/notifications.md b/docs/release-control/v6/internal/subsystems/notifications.mdindex 7b840bb8cf..56d172017b 100644--- a/docs/release-control/v6/internal/subsystems/notifications.md+++ b/docs/release-control/v6/internal/subsystems/notifications.md@@ -24,8 +24,10 @@ is not permission to receive private alert bodies, custom authentication headersor signed requests. HTTP/HTTPS changes are also refused. Same-origin paths andqueries remain supported, including default-port and equivalent IPv6 spellings;the existing redirect limit, DNS pinning, URL validation and TLS checks remain.-Foreign redirects stop before target DNS resolution, validation logging or a-second request. A fixed configuration failure advises the operator to configure+Foreign redirects stop before target DNS resolution, validation logging or any+request to that receiver. Origin refusal precedes the redirect-count error, so+an exhausted same-origin chain cannot expose its final foreign Location or+change that refusal into an unknown/retryable error. A fixed configuration failure advises the operator to configurethe final destination URL, without copying the receiver-controlled Location.That typed failure stops both enhanced transport retries and the queue's retry@@ -37,7 +39,9 @@ Apprise retains the same safe guidance and existing opaque diagnostic policy.redirect statuses, foreign ports/hostname aliases, authenticated HTTPS downgradewith and without the existing TLS override, every sender path and the realqueue's firing/recovery dead-letter, audit and receipt lifecycle. Same-origin-controls verify unchanged methods, payloads, credentials and signatures.+controls verify unchanged methods, payloads, credentials and signatures. Capped+chains exercise direct, enhanced-retry and HTTP Apprise paths; the unchanged+same-origin redirect-count controls remain.`notification_redirect_origin_test.go` covers origin equivalence and separation.Existing redirect-chain controls now exercise paths on one receiver, not threedifferent receivers. This is source privacy/compatibility proof, not installeddiff --git a/internal/notifications/notification_redirect_test.go b/internal/notifications/notification_redirect_test.goindex 3b88e298fa..a2872baaae 100644--- a/internal/notifications/notification_redirect_test.go+++ b/internal/notifications/notification_redirect_test.go@@ -371,3 +371,61 @@ func TestNotificationRedirectOriginQueue(t *testing.T) {}}}++// The count limit must not hide an origin refusal: net/http attaches the final+// Location to its error even when it never requests that receiver.+func TestNotificationRedirectOriginAtLimit(t *testing.T) {+ for _, status := range []int{http.StatusTemporaryRedirect, http.StatusPermanentRedirect} {+ for _, path := range []string{"request", "enhanced-retry", "apprise"} {+ t.Run(fmt.Sprintf("%d/%s", status, path), func(t *testing.T) {+ captured := captureAppriseLogs(t)+ initial, final := ¬ificationRedirectCapture{}, ¬ificationRedirectCapture{}+ sink := newIPv4HTTPServer(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ final.record(t, r)+ w.WriteHeader(http.StatusAccepted)+ }))+ defer sink.Close()+ origin := newIPv4HTTPServer(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ initial.record(t, r)+ target := sink.URL + "/" + redirectPrivateLocation+ switch r.URL.Path {+ case "/same-origin-1":+ target = "/same-origin-2"+ case "/same-origin-2":+ default:+ target = "/same-origin-1"+ }+ http.Redirect(w, r, target, status)+ }))+ defer origin.Close()+ n := notificationRedirectManager(t)+ webhook := WebhookConfig{Name: "capped redirect fixture", URL: origin.URL + "/entry",+ Headers: map[string]string{"X-Receiver-Key": redirectPrivateHeader}}+ var err error+ switch path {+ case "request":+ _, err = n.executeWebhookRequest(webhook, []byte(redirectPrivateBody), webhookRequestOptions{validateURL: true})+ case "enhanced-retry":+ err = n.sendWebhookWithRetry(EnhancedWebhookConfig{WebhookConfig: webhook, RetryCount: 1}, []byte(redirectPrivateBody), "fixture:alert")+ case "apprise":+ cfg := AppriseConfig{Enabled: true, Mode: AppriseModeHTTP, ServerURL: origin.URL, APIKey: redirectPrivateHeader, APIKeyHeader: "X-Receiver-Key", TimeoutSeconds: 5}+ err = n.sendGroupedApprise(cfg, []*alerts.Alert{{ID: "capped-redirect", Message: redirectPrivateBody}})+ }+ assertNotificationRedirectRefused(t, err)+ if len(initial.snapshot()) != WebhookMaxRedirects || len(final.snapshot()) != 0 {+ t.Error("capped foreign redirect was retried or contacted its receiver")+ }+ assertNotificationRedirectPrivate(t, captured.String())+ if path == "enhanced-retry" {+ history := n.GetWebhookHistory()+ if len(history) != 1 || history[0].Success || history[0].RetryAttempts != 0 {+ t.Error("capped foreign redirect lost its one-attempt failure state")+ }+ if len(history) == 1 {+ assertNotificationRedirectPrivate(t, history[0].ErrorMessage)+ }+ }+ })+ }+ }+}diff --git a/internal/notifications/notifications.go b/internal/notifications/notifications.goindex 577119100d..1262364a06 100644--- a/internal/notifications/notifications.go+++ b/internal/notifications/notifications.go@@ -195,14 +195,17 @@ func (n *NotificationManager) createSecureWebhookClientWithURLDiagnostics(timeouTimeout: timeout,Transport: transport,CheckRedirect: func(req *http.Request, via []*http.Request) error {- if len(via) >= WebhookMaxRedirects {- return fmt.Errorf("stopped after %d redirects", WebhookMaxRedirects)- }// SSRF admission is not permission to forward private alert bodies,// custom authentication headers or signatures to a different receiver.if len(via) == 0 || via[0] == nil || !sameNotificationOrigin(via[0].URL, req.URL) {return FailWithClass(NotificationFailureConfiguration, errNotificationRedirectOrigin)}+ // Origin refusal takes precedence even when the redirect budget is+ // exhausted: a foreign Location must not enter diagnostics or become+ // an unknown/retryable error instead of a local configuration failure.+ if len(via) >= WebhookMaxRedirects {+ return fmt.Errorf("stopped after %d redirects", WebhookMaxRedirects)+ }// Re-validate strictly on an admitted redirect, including DNS/IP// changes. Foreign origins are rejected before resolution or logging.return n.validateWebhookURL(req.URL.String(), diagnosticURL)