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): reject encoded dead-man event endpoints

pulse-triage[bot]69b88efe28da
diff --git a/docs/release-control/v6/internal/subsystems/notifications.md b/docs/release-control/v6/internal/subsystems/notifications.md
index a8ac05badf..6760b98d85 100644
--- a/docs/release-control/v6/internal/subsystems/notifications.md
+++ b/docs/release-control/v6/internal/subsystems/notifications.md
@@ -512,6 +512,15 @@ passphrase-encrypted configuration bundle, and represented to API clients by a
redacted sentinel. URLs are bounded to HTTP(S), exclude userinfo, fragments,
localhost, loopback, unspecified, and link-local targets, and must name the
base success endpoint rather than `/start`, `/fail`, or `/log`.
+Endpoint suffix validation inspects the once-decoded URL path, including
+encoded separators and an encoded trailing slash, so percent-encoded event
+names cannot bypass this success-only guard. Encoded base tokens and suffix
+words in query values remain valid; the configured URL is not rewritten.
+`TestValidateDeadManPingURL` covers these rejected and accepted forms.
+`TestDeadManRunCycleRejectsEncodedNonSuccessEndpoint` proves rejection before
+transport, a misconfigured state without a success timestamp, and no token in
+the diagnostic. These are local validation/runtime proofs, not installed
+watchdog acceptance or recipient delivery evidence.
Literal addresses are also compared against every Pulse host interface, while
the monitoring dialer repeats that comparison after DNS resolution. Failure to
enumerate local interfaces fails closed. A private LAN watchdog remains valid
diff --git a/internal/monitoring/deadman_test.go b/internal/monitoring/deadman_test.go
index 50c182b256..7bebe29032 100644
--- a/internal/monitoring/deadman_test.go
+++ b/internal/monitoring/deadman_test.go
@@ -74,6 +74,32 @@ func TestDeadManRunCycleSendsHealthySignalAndPersistsProgress(t *testing.T) {
}
}
+func TestDeadManRunCycleRejectsEncodedNonSuccessEndpoint(t *testing.T) {
+ for _, suffix := range []string{"%66ail", "st%61rt", "lo%67"} {
+ t.Run(suffix, func(t *testing.T) {
+ now := time.Date(2026, 9, 8, 3, 0, 0, 0, time.UTC)
+ calls := 0
+ runtime := newDeadManTestRuntime(t, now, deadManRoundTripFunc(func(*http.Request) (*http.Response, error) {
+ calls++
+ return deadManResponse(http.StatusOK, "OK"), nil
+ }))
+ runtime.runCycle(context.Background(),
+ func() string { return "https://watchdog.example.com/ping/secret-token/" + suffix },
+ func() time.Time { return now }, nil)
+ if calls != 0 {
+ t.Fatalf("invalid endpoint received %d requests", calls)
+ }
+ status := runtime.statusSnapshot()
+ if status.State != "misconfigured" || status.LastSuccessAt != nil {
+ t.Fatalf("invalid endpoint status = %+v", status)
+ }
+ if strings.Contains(status.LastError, "secret-token") {
+ t.Fatal("configuration error exposed the destination token")
+ }
+ })
+ }
+}
+
func TestDeadManRunCycleSignalsFailureWhenCanonicalMonitorStalls(t *testing.T) {
now := time.Date(2026, 8, 27, 12, 0, 0, 0, time.UTC)
var method, path, body string
diff --git a/internal/notifications/deadman_config.go b/internal/notifications/deadman_config.go
index 6d5d817363..3a1c147e64 100644
--- a/internal/notifications/deadman_config.go
+++ b/internal/notifications/deadman_config.go
@@ -69,7 +69,9 @@ func ValidateDeadManPingURL(value string) error {
}
}
- path := strings.TrimSuffix(strings.ToLower(parsed.EscapedPath()), "/")
+ // Inspect the decoded path, so percent-encoded endpoint names and
+ // separators cannot turn a nominal success URL into a start/fail/log ping.
+ path := strings.TrimSuffix(strings.ToLower(parsed.Path), "/")
for _, suffix := range []string{"/start", "/fail", "/log"} {
if strings.HasSuffix(path, suffix) {
return fmt.Errorf("dead-man ping URL must be the base success URL, without %s", suffix)
diff --git a/internal/notifications/deadman_config_test.go b/internal/notifications/deadman_config_test.go
index 81b98847d6..c54768c685 100644
--- a/internal/notifications/deadman_config_test.go
+++ b/internal/notifications/deadman_config_test.go
@@ -34,6 +34,14 @@ func TestValidateDeadManPingURL(t *testing.T) {
{name: "failure suffix slash", value: "https://watchdog.example.com/ping/token/fail/", wantErr: true},
{name: "start suffix", value: "https://watchdog.example.com/ping/token/start", wantErr: true},
{name: "log suffix", value: "https://watchdog.example.com/ping/token/log", wantErr: true},
+ {name: "encoded failure suffix", value: "https://watchdog.example.com/ping/token/%66ail", wantErr: true},
+ {name: "encoded start suffix", value: "https://watchdog.example.com/ping/token/st%61rt", wantErr: true},
+ {name: "encoded log suffix", value: "https://watchdog.example.com/ping/token/lo%67", wantErr: true},
+ {name: "encoded suffix separator", value: "https://watchdog.example.com/ping/token%2Ffail", wantErr: true},
+ {name: "encoded trailing slash", value: "https://watchdog.example.com/ping/token/fail%2f", wantErr: true},
+ {name: "encoded base token", value: "https://watchdog.example.com/ping/secret%2Dtoken"},
+ {name: "suffix word in token", value: "https://watchdog.example.com/ping/token%2Dfail"},
+ {name: "suffix word in query", value: "https://watchdog.example.com/ping/token?value=/fail"},
{name: "oversized", value: "https://watchdog.example.com/ping/" + strings.Repeat("x", MaxDeadManPingURLLength), wantErr: true},
}