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
fix(notifications): mask Discord webhook credentials in diagnostics
pulse-triage[bot]3c77ecb338ee
diff --git a/docs/release-control/v6/internal/subsystems/notifications.md b/docs/release-control/v6/internal/subsystems/notifications.mdindex 13423eb554..57e75b308e 100644--- a/docs/release-control/v6/internal/subsystems/notifications.md+++ b/docs/release-control/v6/internal/subsystems/notifications.md@@ -715,3 +715,17 @@ Queue-free regression tests cover both hosts, encoded and legacy paths,lookalike/unrelated hosts, transport errors and actual rate-limit log output.This does not establish customer exposure, recipient receipt or recognition ofarbitrary custom webhook secrets.++### Discord webhook diagnostic path confidentiality++On exact `discord.com` and legacy `discordapp.com` hosts, the shared redactor+masks the suffix after `/webhooks/`, including the webhook ID and token.+Versioned API prefixes remain visible; encoded paths, host casing and ports+cannot bypass masking. Unrelated paths and lookalike hosts are unchanged.+Configured destinations and transport error causes are not modified.++[Discord's webhook reference](https://docs.discord.com/developers/resources/webhook)+identifies the secure webhook token and token-authorised operations. Focused+synthetic regressions cover helper output, transport diagnostics and actual+rate-limit logs. This is not evidence of customer exposure, recipient receipt,+release qualification, or protection of arbitrary custom-host credentials.diff --git a/internal/notifications/webhook_url_redaction.go b/internal/notifications/webhook_url_redaction.goindex af202224e7..26ba2f75e0 100644--- a/internal/notifications/webhook_url_redaction.go+++ b/internal/notifications/webhook_url_redaction.go@@ -33,6 +33,15 @@ func RedactWebhookURLSecrets(urlString string) string {}parsed.RawPath = ""urlString = parsed.String()+ case "discord.com", "discordapp.com":+ // Discord webhook IDs and tokens follow /webhooks/ in both+ // unversioned and versioned API paths. Mask the entire suffix,+ // including escaped credentials and compatibility endpoint paths.+ if idx := strings.Index(parsed.Path, "/webhooks/"); idx != -1 {+ parsed.Path = parsed.Path[:idx] + "/webhooks/REDACTED"+ parsed.RawPath = ""+ urlString = parsed.String()+ }}// Telegram bot credentials are path components rather than query values.diff --git a/internal/notifications/webhook_url_redaction_test.go b/internal/notifications/webhook_url_redaction_test.goindex edd7a1479c..ec2ff8290b 100644--- a/internal/notifications/webhook_url_redaction_test.go+++ b/internal/notifications/webhook_url_redaction_test.go@@ -16,6 +16,13 @@ func TestRedactWebhookURLSecrets(t *testing.T) {input stringwant string}{+ "discord": {input: "https://discord.com/api/webhooks/123/discord-secret", want: "https://discord.com/api/webhooks/REDACTED"},+ "discord versioned": {input: "https://discord.com/api/v10/webhooks/123/discord-secret", want: "https://discord.com/api/v10/webhooks/REDACTED"},+ "discord legacy": {input: "https://discordapp.com/api/webhooks/123/discord-secret", want: "https://discordapp.com/api/webhooks/REDACTED"},+ "discord encoded": {input: "https://user:[email protected]:443/api/webhooks/123/discord%2Dsecret", want: "https://[email protected]:443/api/webhooks/REDACTED"},+ "discord query": {input: "https://discord.com/api/webhooks/123/discord-secret?wait=true&token=query-secret", want: "https://discord.com/api/webhooks/REDACTED?wait=true&token=REDACTED"},+ "discord lookalike": {input: "https://discord.com.example.org/api/webhooks/status", want: "https://discord.com.example.org/api/webhooks/status"},+ "discord unrelated": {input: "https://discord.com/api/status", want: "https://discord.com/api/status"},"slack": {input: "https://hooks.slack.com/services/T-test/B-test/slack-secret", want: "https://hooks.slack.com/services/REDACTED"},"gov slack": {input: "https://hooks.slack-gov.com/services/T-test/B-test/slack-secret?token=query-secret&channel=ops", want: "https://hooks.slack-gov.com/services/REDACTED?token=REDACTED&channel=ops"},"slack encoded path and authority": {input: "https://user:[email protected]:443/serv%69ces/T-test/B-test/slack%2Dsecret", want: "https://[email protected]:443/services/REDACTED"},@@ -148,3 +155,27 @@ func TestSlackWebhookDiagnosticsRedactPath(t *testing.T) {t.Fatalf("unsafe rate-limit diagnostic: %s", out)}}+func TestDiscordWebhookDiagnosticsRedactPath(t *testing.T) {+ const webhookURL = "https://discord.com/api/webhooks/123/discord-secret"+ cause := errors.New("connection refused")+ original := &url.Error{Op: "Post", URL: webhookURL, Err: cause}+ redacted := redactWebhookTransportError(original)+ if strings.Contains(redacted.Error(), "discord-secret") || !strings.Contains(redacted.Error(), "/api/webhooks/REDACTED") {+ t.Fatalf("unsafe transport diagnostic: %v", redacted)+ }+ if original.URL != webhookURL || !errors.Is(redacted, cause) {+ t.Fatal("transport error identity or cause changed")+ }+ var captured bytes.Buffer+ logger := log.Logger+ log.Logger = zerolog.New(&captured)+ t.Cleanup(func() { log.Logger = logger })+ nm := &NotificationManager{webhookRateLimits: make(map[string]*webhookRateLimit)}+ for range WebhookRateLimitMax + 2 {+ nm.checkWebhookRateLimit(webhookURL)+ }+ out := captured.String()+ if !strings.Contains(out, "rate limit exceeded") || !strings.Contains(out, "/api/webhooks/REDACTED") || strings.Contains(out, "discord-secret") {+ t.Fatalf("unsafe rate-limit diagnostic: %s", out)+ }+}