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.

Add an explicit operator override for plaintext HTTP to non-local Pulse hosts

rcourtman93fff4f1d85a
diff --git a/cmd/pulse-agent/main.go b/cmd/pulse-agent/main.go
index 8eeea9ad1e..fe9025e672 100644
--- a/cmd/pulse-agent/main.go
+++ b/cmd/pulse-agent/main.go
@@ -33,6 +33,7 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/remoteconfig"
"github.com/rcourtman/pulse-go-rewrite/internal/utils"
agentshost "github.com/rcourtman/pulse-go-rewrite/pkg/agents/host"
+ "github.com/rcourtman/pulse-go-rewrite/pkg/securityutil"
"github.com/rs/zerolog"
gohost "github.com/shirou/gopsutil/v4/host"
"golang.org/x/sync/errgroup"
@@ -316,6 +317,12 @@ func run(ctx context.Context, args []string, getenv func(string) string) error {
Bool("auto_update", !cfg.DisableAutoUpdate).
Msg("Starting Pulse Unified Agent")
+ if cfg.AllowPlaintextHTTP {
+ logger.Warn().
+ Str("pulse_url", cfg.PulseURL).
+ Msg("--allow-plaintext-http is set: the agent API token travels in cleartext to any non-loopback Pulse URL; only use this on a network you fully control")
+ }
+
// 5. Set prometheus info metric
agentInfo.WithLabelValues(
Version,
@@ -766,6 +773,7 @@ type Config struct {
AgentIDFile string
Tags []string
InsecureSkipVerify bool
+ AllowPlaintextHTTP bool
CACertPath string
ServerFingerprint string
DeploySSHUser string
@@ -909,6 +917,7 @@ func loadConfig(args []string, getenv func(string) string) (Config, error) {
agentIDFlag := fs.String("agent-id", envAgentID, "Override agent identifier")
agentIDFileFlag := fs.String("agent-id-file", envAgentIDFile, "Path to a file storing the agent identifier (read on start, written on first start). Mount this file as a volume to keep the agent identity stable across container recreation.")
insecureFlag := fs.Bool("insecure", utils.ParseBool(envInsecure), "Skip TLS verification")
+ allowPlaintextHTTPFlag := fs.Bool("allow-plaintext-http", utils.ParseBool(strings.TrimSpace(getenv("PULSE_AGENT_ALLOW_PLAINTEXT_HTTP"))), "Allow plain HTTP to a Pulse server that does not look local (sends the API token in cleartext; only for networks you fully control)")
caCertFlag := fs.String("cacert", envCACertPath, "Path to custom CA bundle for agent HTTPS transport")
serverFingerprintFlag := fs.String("server-fingerprint", envServerFingerprint, "Expected Pulse server TLS certificate fingerprint (SHA256)")
deploySSHUserFlag := fs.String("deploy-ssh-user", envDeploySSHUser, "SSH user for peer deploy fan-out (default: root; non-root requires passwordless sudo)")
@@ -962,6 +971,10 @@ func loadConfig(args []string, getenv func(string) string) (Config, error) {
pulseURL = "http://localhost:7655"
}
+ // Record operator plaintext consent before any module validates the Pulse
+ // URL; the startup warning is emitted once the logger exists in run().
+ securityutil.SetOperatorPlaintextHTTPConsent(*allowPlaintextHTTPFlag)
+
// Resolve token with priority: --token > --token-file > env > default file
token := resolveToken(*tokenFlag, *tokenFileFlag, envToken)
@@ -1041,6 +1054,7 @@ func loadConfig(args []string, getenv func(string) string) (Config, error) {
AgentIDFile: strings.TrimSpace(*agentIDFileFlag),
Tags: tags,
InsecureSkipVerify: *insecureFlag,
+ AllowPlaintextHTTP: *allowPlaintextHTTPFlag,
CACertPath: strings.TrimSpace(*caCertFlag),
ServerFingerprint: strings.TrimSpace(*serverFingerprintFlag),
DeploySSHUser: deploySSHUser,
diff --git a/cmd/pulse-agent/main_test.go b/cmd/pulse-agent/main_test.go
index 46730ef449..8fb41eedb4 100644
--- a/cmd/pulse-agent/main_test.go
+++ b/cmd/pulse-agent/main_test.go
@@ -22,6 +22,7 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/dockeragent"
"github.com/rcourtman/pulse-go-rewrite/internal/hostagent"
"github.com/rcourtman/pulse-go-rewrite/internal/kubernetesagent"
+ "github.com/rcourtman/pulse-go-rewrite/pkg/securityutil"
"github.com/rs/zerolog"
)
@@ -2210,3 +2211,36 @@ func TestDockerAgentImplementsTypedContainerUpdater(t *testing.T) {
// method signature drifts, updates silently refuse at runtime. Pin it.
var _ hostagent.DockerContainerUpdater = (*dockeragent.Agent)(nil)
}
+
+func TestAllowPlaintextHTTPFlagParsesAndDefaultsClosed(t *testing.T) {
+ t.Cleanup(func() { securityutil.SetOperatorPlaintextHTTPConsent(false) })
+
+ cfg, err := loadConfig([]string{"--url", "http://192.168.1.10:7655", "--token", "t"}, func(string) string { return "" })
+ if err != nil {
+ t.Fatal(err)
+ }
+ if cfg.AllowPlaintextHTTP {
+ t.Fatal("plaintext override must default to false")
+ }
+
+ cfg, err = loadConfig([]string{"--url", "http://192.168.1.10:7655", "--token", "t", "--allow-plaintext-http"}, func(string) string { return "" })
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !cfg.AllowPlaintextHTTP {
+ t.Fatal("--allow-plaintext-http flag was not applied")
+ }
+
+ cfg, err = loadConfig([]string{"--url", "http://192.168.1.10:7655", "--token", "t"}, func(key string) string {
+ if key == "PULSE_AGENT_ALLOW_PLAINTEXT_HTTP" {
+ return "true"
+ }
+ return ""
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !cfg.AllowPlaintextHTTP {
+ t.Fatal("PULSE_AGENT_ALLOW_PLAINTEXT_HTTP env was not applied")
+ }
+}
diff --git a/docs/UNIFIED_AGENT.md b/docs/UNIFIED_AGENT.md
index 70927b9f1b..907cefe9fd 100644
--- a/docs/UNIFIED_AGENT.md
+++ b/docs/UNIFIED_AGENT.md
@@ -109,6 +109,7 @@ curl -fsSL http://<pulse-ip>:7655/install.sh | \
| `--disable-auto-update` | `PULSE_DISABLE_AUTO_UPDATE` | Disable auto-updates | `false` |
| `--disable-docker-update-checks` | `PULSE_DISABLE_DOCKER_UPDATE_CHECKS` | Disable Docker image update detection | `false` |
| `--insecure` | `PULSE_INSECURE_SKIP_VERIFY` | Skip TLS verification | `false` |
+| `--allow-plaintext-http` | `PULSE_AGENT_ALLOW_PLAINTEXT_HTTP` | Allow plain HTTP to a Pulse server that does not look local (private IP, single-label, `.local`/`.lan`/`.home`/`.home.arpa`/`.internal`, or resolves to private addresses). Sends the API token in cleartext; only for networks you fully control, e.g. internal networks numbered from public IP space | `false` |
| `--hostname` | `PULSE_HOSTNAME` | Override hostname | *(OS hostname)* |
| `--agent-id` | `PULSE_AGENT_ID` | Unique agent identifier | *(machine-id)* |
| `--report-ip` | `PULSE_REPORT_IP` | Override reported IP (multi-NIC) | *(auto)* |
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index fa66ed6a07..2d305cbe1a 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -1386,6 +1386,7 @@ the intentionally sparse public response.
8. Add or change the unified agent CLI entrypoint, version/help exit semantics, or startup argument/error routing through `cmd/pulse-agent/main.go`.
The CLI entrypoint owns propagation of persistence context into runtime-owned helpers. When installer-selected state roots differ from the default, `cmd/pulse-agent/main.go` must pass that exact `StateDir` through both the host-agent runtime and updater startup paths instead of letting one path silently fall back to `/var/lib/pulse-agent`.
The same runtime-owned boundary also owns Pulse control-plane URL validation for agent startup, remote config, updater continuity, and command transport. Public control-plane hostnames remain HTTPS/WSS, but self-hosted local control planes may use plain HTTP/WS when the host is loopback, a private, link-local, or carrier-grade NAT IP, a single-label LAN name, or a local DNS suffix such as `.local`, `.lan`, `.home`, `.home.arpa`, or `.internal`; installer-persisted local HTTP URLs must not be accepted by one runtime path and rejected by another.
+ Plaintext to a host that does not look local is available only as an explicit operator override: the `--allow-plaintext-http` flag (`PULSE_AGENT_ALLOW_PLAINTEXT_HTTP`) records process-wide consent through `securityutil.SetOperatorPlaintextHTTPConsent` before any module validates a URL, applies uniformly to every agent transport (HTTP and WS), warns at startup that the API token travels in cleartext, defaults closed, and is never emitted by generated install commands. It exists for self-hosted networks numbered from nominally public IP space; the Pulse server never sets it.
The unified agent CLI copy follows the same command-execution vocabulary as the install surface. `cmd/pulse-agent/main.go` may keep the `--enable-commands` flag name for compatibility, but the help text and inline comments must describe command execution as Pulse command execution for Patrol actions and governed Proxmox LXC Docker inventory rather than reviving AI auto-fix language.
The unified agent CLI copy also owns operator-facing Docker / Podman runtime
labels. `cmd/pulse-agent/main.go` may keep the historical
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index a8b99c2a3d..dea13ec655 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -497,6 +497,11 @@ Docker/Podman, Kubernetes, remote configuration, commands, and self-update.
Custom CA bundles and SHA-256 leaf-certificate pins are runtime trust inputs,
not monitoring data, and malformed pins must fail during client construction
instead of silently degrading to system roots or blanket skip-verification.
+Plaintext transport to a non-local-looking control plane is never implicit:
+it requires the operator's explicit `--allow-plaintext-http` consent recorded
+once at agent startup, is logged as a warning naming the cleartext token
+exposure, and cannot be enabled by the server, by remote configuration, or by
+generated install commands.
Installer persistence may carry the non-secret pin into service arguments, but
must not copy API tokens or certificate material into reports or diagnostics.
diff --git a/internal/remoteconfig/client_additional_test.go b/internal/remoteconfig/client_additional_test.go
index fd55a86b67..c7a5f10f72 100644
--- a/internal/remoteconfig/client_additional_test.go
+++ b/internal/remoteconfig/client_additional_test.go
@@ -14,6 +14,7 @@ import (
"testing"
"time"
+ "github.com/rcourtman/pulse-go-rewrite/pkg/securityutil"
"github.com/rs/zerolog"
)
@@ -676,3 +677,23 @@ func decodeLastLogEntry(t *testing.T, logs *bytes.Buffer) map[string]interface{}
return entry
}
+
+func TestNormalizePulseURLHonorsOperatorPlaintextConsent(t *testing.T) {
+ // pulse.example.com is a dotted public name with no local suffix, so the
+ // default posture refuses plain HTTP for it (resolution either fails or
+ // yields public addresses).
+ if _, err := normalizePulseURL("http://pulse.plaintext-consent.invalid:7655"); err == nil {
+ t.Fatal("plain HTTP to a non-local host was accepted without operator consent")
+ }
+
+ securityutil.SetOperatorPlaintextHTTPConsent(true)
+ t.Cleanup(func() { securityutil.SetOperatorPlaintextHTTPConsent(false) })
+
+ normalized, err := normalizePulseURL("http://pulse.plaintext-consent.invalid:7655")
+ if err != nil {
+ t.Fatalf("operator consent did not reach remote-config URL validation: %v", err)
+ }
+ if normalized != "http://pulse.plaintext-consent.invalid:7655" {
+ t.Fatalf("unexpected normalized URL %q", normalized)
+ }
+}
diff --git a/pkg/securityutil/httpurl.go b/pkg/securityutil/httpurl.go
index 3042f68b5b..812171fe29 100644
--- a/pkg/securityutil/httpurl.go
+++ b/pkg/securityutil/httpurl.go
@@ -10,6 +10,7 @@ import (
"path"
"strconv"
"strings"
+ "sync/atomic"
"time"
)
@@ -209,6 +210,26 @@ type PulseURLValidationOptions struct {
// AllowLocalNetworkHTTP may permit plaintext transport. When unset, the
// system resolver is used.
ResolveIPAddrs func(ctx context.Context, host string) ([]net.IPAddr, error)
+
+ // AllowOperatorPlaintextHTTP permits plain HTTP/WS to ANY host. This is
+ // the explicit operator override for self-hosted networks that number
+ // from nominally public IP space; it sends the agent API token in
+ // cleartext on that path and must never be a default.
+ AllowOperatorPlaintextHTTP bool
+}
+
+// operatorPlaintextHTTPConsent is process-wide operator consent to plaintext
+// transport regardless of how local the host looks. It exists because the
+// URL validation sites are leaf helpers spread across every agent module;
+// consent is set exactly once from the agent entrypoint's --allow-plaintext-http
+// flag before any module starts, and is never set by the Pulse server.
+var operatorPlaintextHTTPConsent atomic.Bool
+
+// SetOperatorPlaintextHTTPConsent records the operator's explicit choice to
+// allow plaintext HTTP/WS to hosts that do not look local. Call before any
+// URL validation runs; intended solely for agent entrypoints.
+func SetOperatorPlaintextHTTPConsent(allowed bool) {
+ operatorPlaintextHTTPConsent.Store(allowed)
}
// NormalizePulseHTTPBaseURL validates a Pulse control-plane base URL.
@@ -343,6 +364,9 @@ func pulseURLAllowsPlaintextHost(host string, opts PulseURLValidationOptions) bo
if IsLoopbackHost(host) {
return true
}
+ if opts.AllowOperatorPlaintextHTTP || operatorPlaintextHTTPConsent.Load() {
+ return true
+ }
if !(opts.AllowInsecureHTTP || opts.AllowLocalNetworkHTTP) {
return false
}
diff --git a/pkg/securityutil/httpurl_test.go b/pkg/securityutil/httpurl_test.go
index 5494c8a0bb..029807610b 100644
--- a/pkg/securityutil/httpurl_test.go
+++ b/pkg/securityutil/httpurl_test.go
@@ -126,3 +126,38 @@ func TestNormalizePulseWebSocketBaseURLWithOptionsAllowsResolvedCGNATDNS(t *test
t.Fatalf("NormalizePulseWebSocketBaseURLWithOptions() = %q", got.String())
}
}
+
+func TestOperatorPlaintextHTTPOverrides(t *testing.T) {
+ const publicHTTP = "http://pulse.internal.example.com:7655"
+ resolvePublic := func(context.Context, string) ([]net.IPAddr, error) {
+ return []net.IPAddr{{IP: net.ParseIP("192.20.10.5")}}, nil
+ }
+
+ if _, err := NormalizePulseHTTPBaseURLWithOptions(publicHTTP, PulseURLValidationOptions{
+ AllowLocalNetworkHTTP: true,
+ ResolveIPAddrs: resolvePublic,
+ }); err == nil {
+ t.Fatal("plain HTTP to a public-resolving host was accepted without operator consent")
+ }
+
+ if _, err := NormalizePulseHTTPBaseURLWithOptions(publicHTTP, PulseURLValidationOptions{
+ AllowOperatorPlaintextHTTP: true,
+ ResolveIPAddrs: resolvePublic,
+ }); err != nil {
+ t.Fatalf("per-call operator consent was refused: %v", err)
+ }
+
+ SetOperatorPlaintextHTTPConsent(true)
+ t.Cleanup(func() { SetOperatorPlaintextHTTPConsent(false) })
+ if _, err := NormalizePulseHTTPBaseURLWithOptions(publicHTTP, PulseURLValidationOptions{
+ AllowLocalNetworkHTTP: true,
+ ResolveIPAddrs: resolvePublic,
+ }); err != nil {
+ t.Fatalf("process-wide operator consent was refused: %v", err)
+ }
+ if _, err := NormalizePulseWebSocketBaseURLWithOptions("ws://pulse.internal.example.com:7655", PulseURLValidationOptions{
+ ResolveIPAddrs: resolvePublic,
+ }); err != nil {
+ t.Fatalf("operator consent did not extend to the websocket channel: %v", err)
+ }
+}