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
Redact webhook URLs in the rate limit drop logs
rcourtman889d06552800
diff --git a/docs/release-control/v6/internal/subsystems/notifications.md b/docs/release-control/v6/internal/subsystems/notifications.mdindex 3356a2947b..34c37eb11a 100644--- a/docs/release-control/v6/internal/subsystems/notifications.md+++ b/docs/release-control/v6/internal/subsystems/notifications.md@@ -65,6 +65,19 @@ the resolved alerts, while retry, failure, cancellation, and dead-letter stateremain inspectable in the queue and audit records. Destination identities arestable opaque routing identities and must not expose credentials.+4. Webhook URLs are credential-bearing (Gotify, ntfy and Telegram all+ carry tokens in the path or query), so every surface that emits one+ must pass it through `RedactWebhookURLSecrets` first. This covers logs+ and returned errors alike, including the rate-limit drop paths in+ `checkWebhookRateLimit` and the enhanced sender, which are the sites+ most likely to fire repeatedly for a misconfigured destination.+ Redaction is proven by capturing log output rather than by reading the+ call sites, because a missed site is invisible to a source scan.+ Regression coverage: `TestWebhookRateLimitLogsRedactURLSecrets` and+ `TestRedactWebhookTransportErrorPreservesBehaviorWithoutToken` in+ `internal/notifications/webhook_url_redaction_test.go`.++## Current StateThis subsystem now makes email, webhook, Apprise, queueing, and deliverydiff --git a/internal/notifications/notifications.go b/internal/notifications/notifications.goindex 8940235a25..039f21ff5a 100644--- a/internal/notifications/notifications.go+++ b/internal/notifications/notifications.go@@ -2642,7 +2642,7 @@ func (n *NotificationManager) checkWebhookRateLimit(webhookURL string) bool {// Still in window, check if we've exceeded the limitif limit.sentCount >= WebhookRateLimitMax {log.Warn().- Str("webhookURL", webhookURL).+ Str("webhookURL", RedactWebhookURLSecrets(webhookURL)).Int("sentCount", limit.sentCount).Dur("window", WebhookRateLimitWindow).Msg("webhook rate limit exceeded, dropping request")diff --git a/internal/notifications/webhook_enhanced.go b/internal/notifications/webhook_enhanced.goindex 269e9ef2e4..47285b5b7c 100644--- a/internal/notifications/webhook_enhanced.go+++ b/internal/notifications/webhook_enhanced.go@@ -210,7 +210,7 @@ func (n *NotificationManager) SendEnhancedWebhook(webhook EnhancedWebhookConfig,if !n.checkWebhookRateLimit(webhook.URL) {log.Warn().Str("webhook", webhook.Name).- Str("url", webhook.URL).+ Str("url", RedactWebhookURLSecrets(webhook.URL)).Msg("webhook request dropped due to rate limiting")return fmt.Errorf("rate limit exceeded for webhook %s", webhook.Name)}diff --git a/internal/notifications/webhook_url_redaction_test.go b/internal/notifications/webhook_url_redaction_test.goindex 96bb084f77..73b690d065 100644--- a/internal/notifications/webhook_url_redaction_test.go+++ b/internal/notifications/webhook_url_redaction_test.go@@ -1,10 +1,14 @@package notificationsimport (+ "bytes""errors""net/url""strings""testing"++ "github.com/rs/zerolog"+ "github.com/rs/zerolog/log")func TestRedactWebhookURLSecrets(t *testing.T) {@@ -54,3 +58,39 @@ func TestRedactWebhookTransportErrorPreservesBehaviorWithoutToken(t *testing.T)t.Fatal("redacted transport error no longer unwraps to its original cause")}}++// TestWebhookRateLimitLogsRedactURLSecrets captures the actual log output of+// the rate-limit drop paths. Both of these logged the raw webhook URL until+// this test existed: the redaction sweep converted five call sites but missed+// checkWebhookRateLimit and the enhanced sender, and no test asserted log+// content, so a token in the URL still reached the logs on the one event most+// likely to fire repeatedly.+func TestWebhookRateLimitLogsRedactURLSecrets(t *testing.T) {+ const secret = "gotify-secret"+ webhookURL := "https://gotify.example/message?token=" + secret++ var captured bytes.Buffer+ original := log.Logger+ log.Logger = zerolog.New(&captured)+ t.Cleanup(func() { log.Logger = original })++ nm := &NotificationManager{+ webhookRateLimits: make(map[string]*webhookRateLimit),+ }++ // Exhaust the window so the drop path logs.+ for range WebhookRateLimitMax + 2 {+ nm.checkWebhookRateLimit(webhookURL)+ }++ out := captured.String()+ if !strings.Contains(out, "rate limit exceeded") {+ t.Fatalf("expected the rate-limit drop to be logged, got %q", out)+ }+ if strings.Contains(out, secret) {+ t.Fatalf("webhook token leaked into logs: %q", out)+ }+ if !strings.Contains(out, "token=REDACTED") {+ t.Fatalf("expected redacted url in logs, got %q", out)+ }+}