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.

Restrict purchase return HTTP callbacks to loopback

rcourtmande99fcb1f048
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 4104b9feeb..197275d172 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -861,6 +861,11 @@ runtime may keep the operator on the compare-plans prompt, but any visible
`Compare plans` action must still route through owned
`GET /auth/license-purchase-start?feature=self_hosted_plan` instead of
constructing a direct Pulse Account URL in the browser.
+That same purchase-return contract also narrows the insecure local-development
+carve-out: signed purchase-return callbacks may use plain HTTP only for
+loopback hosts such as `localhost` or `127.0.0.1`. RFC1918, `.local`, and
+other LAN-visible hosts must use HTTPS so the token-bearing return state is
+not exposed to same-subnet sniffing during commercial checkout return.
That destination split is canonical commercial truth, but navigation semantics
are not owned here. `frontend-modern/src/utils/pricingHandoff.ts` and
`frontend-modern/src/stores/license.ts` decide which href each commercial
diff --git a/pkg/licensing/purchase_return.go b/pkg/licensing/purchase_return.go
index 007901651f..74ab3ec94b 100644
--- a/pkg/licensing/purchase_return.go
+++ b/pkg/licensing/purchase_return.go
@@ -3,6 +3,7 @@ package licensing
import (
"errors"
"fmt"
+ "net"
"net/url"
"strings"
"time"
@@ -181,7 +182,7 @@ func ValidatePurchaseReturnURL(raw, expectedInstanceHost string) (string, error)
switch strings.ToLower(strings.TrimSpace(parsed.Scheme)) {
case "https":
case "http":
- if !isAllowedInsecureTrialActivationReturnHost(host) {
+ if !isAllowedInsecurePurchaseReturnReturnHost(host) {
return "", ErrPurchaseReturnReturnURLInvalid
}
default:
@@ -194,3 +195,15 @@ func ValidatePurchaseReturnURL(raw, expectedInstanceHost string) (string, error)
}
return host, nil
}
+
+func isAllowedInsecurePurchaseReturnReturnHost(host string) bool {
+ host = strings.ToLower(strings.TrimSpace(host))
+ if host == "" {
+ return false
+ }
+ if host == "localhost" {
+ return true
+ }
+ ip := net.ParseIP(host)
+ return ip != nil && ip.IsLoopback()
+}
diff --git a/pkg/licensing/purchase_return_test.go b/pkg/licensing/purchase_return_test.go
index 40c6525c84..998959160d 100644
--- a/pkg/licensing/purchase_return_test.go
+++ b/pkg/licensing/purchase_return_test.go
@@ -80,6 +80,11 @@ func TestValidatePurchaseReturnURL(t *testing.T) {
raw: "http://localhost:7655/auth/license-purchase-activate",
wantHost: "localhost",
},
+ {
+ name: "http loopback ip allowed",
+ raw: "http://127.0.0.1:7655/auth/license-purchase-activate",
+ wantHost: "127.0.0.1",
+ },
{
name: "missing return url",
raw: "",
@@ -90,6 +95,21 @@ func TestValidatePurchaseReturnURL(t *testing.T) {
raw: "http://pulse.example.com/auth/license-purchase-activate",
wantErr: ErrPurchaseReturnReturnURLInvalid,
},
+ {
+ name: "http private ip rejected",
+ raw: "http://192.168.1.10:7655/auth/license-purchase-activate",
+ wantErr: ErrPurchaseReturnReturnURLInvalid,
+ },
+ {
+ name: "http local domain rejected",
+ raw: "http://pulse.local:7655/auth/license-purchase-activate",
+ wantErr: ErrPurchaseReturnReturnURLInvalid,
+ },
+ {
+ name: "http bare host rejected",
+ raw: "http://pulsebox:7655/auth/license-purchase-activate",
+ wantErr: ErrPurchaseReturnReturnURLInvalid,
+ },
{
name: "query string rejected",
raw: "https://pulse.example.com/auth/license-purchase-activate?token=x",