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.

fix(notifications): clamp retry seconds before duration conversion

pulse-triage[bot]8970c3b1b446
diff --git a/docs/release-control/v6/internal/subsystems/notifications.md b/docs/release-control/v6/internal/subsystems/notifications.md
index fead8f181b..fc986a4047 100644
--- a/docs/release-control/v6/internal/subsystems/notifications.md
+++ b/docs/release-control/v6/internal/subsystems/notifications.md
@@ -121,6 +121,24 @@ stable opaque routing identities and must not expose credentials.
## Current State
+### Webhook retry delay conversion
+
+`parseRetryAfterBackoff` bounds parsed integer seconds before multiplying by
+`time.Second`, so large provider values cannot overflow into an immediate
+retry. Signed 64-bit integer parsing makes this independent of native integer
+width. Positive parsed seconds above the existing `WebhookMaxBackoff` cap
+return that cap (30 seconds); non-positive parsed values retain the existing
+immediate fallback. HTTP-date parsing and invalid-value fallback are unchanged;
+integers outside signed 64-bit range remain invalid. Negative-value acceptance
+is compatibility behaviour, not the non-negative delay-seconds grammar of
+[RFC 9110 section 10.2.3](https://www.rfc-editor.org/rfc/rfc9110.html#section-10.2.3).
+
+`TestParseRetryAfterBackoff` in
+`internal/notifications/webhook_enhanced_test.go` pins both large positive and
+negative overflow cases alongside ordinary seconds, dates, whitespace and
+invalid inputs. This is pure parser proof: it does not establish elapsed HTTP
+retry timing, queue persistence, provider acceptance or recipient receipt.
+
Notification-management HTTP production and its unit/contract proof now live
together under `internal/api/alerting/`. Router-level scope and integration
tests remain in `internal/api`, while the compatibility aliases there keep the
diff --git a/internal/notifications/webhook_enhanced.go b/internal/notifications/webhook_enhanced.go
index 17e89a83fe..48d346eab8 100644
--- a/internal/notifications/webhook_enhanced.go
+++ b/internal/notifications/webhook_enhanced.go
@@ -482,7 +482,15 @@ func parseRetryAfterBackoff(retryAfter string, now time.Time) (time.Duration, bo
return backoff
}
- if seconds, err := strconv.Atoi(retryAfter); err == nil {
+ if seconds, err := strconv.ParseInt(retryAfter, 10, 64); err == nil {
+ // Clamp in seconds before conversion: multiplying an untrusted value
+ // by time.Second can overflow and turn a long delay into no delay.
+ if seconds <= 0 {
+ return 0, true
+ }
+ if seconds > int64(WebhookMaxBackoff/time.Second) {
+ return WebhookMaxBackoff, true
+ }
return clampBackoff(time.Duration(seconds) * time.Second), true
}
diff --git a/internal/notifications/webhook_enhanced_test.go b/internal/notifications/webhook_enhanced_test.go
index e0167322ec..d47f4f482a 100644
--- a/internal/notifications/webhook_enhanced_test.go
+++ b/internal/notifications/webhook_enhanced_test.go
@@ -251,6 +251,18 @@ func TestParseRetryAfterBackoff(t *testing.T) {
want: WebhookMaxBackoff,
ok: true,
},
+ {
+ name: "large seconds cannot overflow duration",
+ retryAfter: "9223372036854775807",
+ want: WebhookMaxBackoff,
+ ok: true,
+ },
+ {
+ name: "large negative seconds stay immediate",
+ retryAfter: "-9223372036854775807",
+ want: 0,
+ ok: true,
+ },
{
name: "http date capped at max backoff",
retryAfter: "Fri, 13 Mar 2026 19:05:00 GMT",