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
Harden secure agent recovery transports
rcourtmanf967857928a9
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 5de71de12e..be7cc8521a 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -186,7 +186,15 @@ check before classification or rewrite. Stop failure or a still-active processretains every backup and never restores predecessor files beneath that process.Indeterminate activation recovery may unmask and re-enable the runner onlyafter rebuilding and durably committing both files; otherwise it leaves the-unit masked, disabled, and backed up.+unit masked, disabled, and backed up. Before that recovery path restarts a+retained replacement, it must reload and revalidate the effective FragmentPath,+drop-in absence, executable, identity, environment file, address families, and+hardening properties. A failed effective-target check retains the exact new+credential and runtime but re-establishes the disabled runtime mask instead of+starting the rejected root unit. Re-fencing is itself fail-closed: disable,+runtime-mask, daemon-reload, and inactive-state checks must all succeed before+the installer may claim the rejected unit is fenced or discard predecessor+repair artifacts.Issuance and every runner boundary use the samebounded action-identity vocabulary. Credentialrotation is a prepare/commit transaction. Issuance stores a ten-minute pending@@ -2374,6 +2382,13 @@ agent inventory, registration state, or command-channel readiness.rolling back, or deleting the recovery handoff.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.+ Bearer-bearing collector HTTP requests never inherit an ambient proxy for a+ plaintext destination, including an explicitly allowed local/private or+ operator-consented URL. They connect directly to the selected destination+ so `HTTP_PROXY` cannot silently receive the cleartext credential. HTTPS+ destinations may continue to use the operator's proxy environment because+ the bearer stays inside the authenticated TLS tunnel; redirects remain+ forbidden in both cases.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 `--disk-exclude` help text must describe device names or paths andmount-point patterns, and the repeatable flag must append values rather thandiff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.mdindex e9e0c9e236..097c095969 100644--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md@@ -682,6 +682,17 @@ artifact-selection behaviour.path must run the reusable lifecycle harness rather than stopping at aparser check or foreground self-test.8. `scripts/install.sh` shared with `agent-lifecycle`: the shell installer is both a deployment installability entry point and a canonical agent lifecycle runtime continuity boundary.+ Action-runner recovery must keep the root service disabled and runtime-masked+ when its effective systemd target fails the installer-owned FragmentPath,+ drop-in, executable, identity, environment, network, or hardening checks.+ An indeterminate server activation may retain the replacement credential and+ files, but it may restart them only after a fresh daemon reload and complete+ effective-target validation; repair-required state is never permission to+ start a unit the same transaction rejected.+ If re-establishing that repair fence fails after inspection temporarily+ unmasks the unit, the installer must surface the fence failure and retain+ predecessor repair artifacts; it must not claim the unit is masked or+ discard the only local evidence needed for manual recovery.A caller-supplied `--state-dir` must remain canonical across renderedsystemd, launchd, OpenRC, rc.d, SysV, NAS wrapper, bootstrap, and referenceenvironment artifacts. Update and uninstall without a repeated custom pathdiff --git a/internal/hostagent/agent.go b/internal/hostagent/agent.goindex 8e4bd51cb4..1ed5bad135 100644--- a/internal/hostagent/agent.go+++ b/internal/hostagent/agent.go@@ -12,6 +12,7 @@ import ("net""net/http""net/netip"+ "net/url""os""os/exec""path/filepath"@@ -501,6 +502,23 @@ func (a *Agent) nextReportSequenceID() string {return agentshost.FormatReportSequenceID(a.reportStreamID, a.reportSequence.Add(1))}+func agentControlPlaneProxy(request *http.Request) (*url.URL, error) {+ return resolveAgentControlPlaneProxy(request, http.ProxyFromEnvironment)+}++func resolveAgentControlPlaneProxy(request *http.Request, ambient func(*http.Request) (*url.URL, error)) (*url.URL, error) {+ if request == nil || request.URL == nil || strings.EqualFold(request.URL.Scheme, "http") {+ // Plaintext self-hosted control-plane traffic already carries its bearer+ // in the clear on the explicitly selected local/private path. Never let+ // ambient process state silently redirect that credential to a proxy.+ return nil, nil+ }+ if ambient == nil {+ return nil, nil+ }+ return ambient(request)+}+func newAgentHTTPClient(caCertPath string, insecureSkipVerify bool, serverFingerprint string) (*http.Client, error) {tlsConfig, err := agenttls.NewClientTLSConfig(caCertPath, insecureSkipVerify, serverFingerprint)if err != nil {@@ -509,7 +527,7 @@ func newAgentHTTPClient(caCertPath string, insecureSkipVerify bool, serverFingerreturn &http.Client{Timeout: 15 * time.Second,Transport: &http.Transport{- Proxy: http.ProxyFromEnvironment,+ Proxy: agentControlPlaneProxy,TLSClientConfig: tlsConfig,},// Redirects can rewrite report POSTs to GETs and must never cross andiff --git a/internal/hostagent/agent_new_test.go b/internal/hostagent/agent_new_test.goindex 426eda0bbd..bfa4e99348 100644--- a/internal/hostagent/agent_new_test.go+++ b/internal/hostagent/agent_new_test.go@@ -7,6 +7,7 @@ import ("errors""net""net/http"+ "net/url""os""path/filepath""reflect"@@ -80,6 +81,51 @@ func TestNew_AllowsLocalNetworkHTTPPulseURL(t *testing.T) {}}+func TestAgentControlPlaneProxyKeepsPlaintextBearerTrafficDirect(t *testing.T) {+ proxyURL, err := url.Parse("http://proxy.example:3128")+ if err != nil {+ t.Fatal(err)+ }+ ambientCalls := 0+ ambient := func(*http.Request) (*url.URL, error) {+ ambientCalls+++ return proxyURL, nil+ }++ plaintext, err := http.NewRequest(http.MethodPost, "http://192.168.0.98:7655/api/agents/report", nil)+ if err != nil {+ t.Fatal(err)+ }+ got, err := resolveAgentControlPlaneProxy(plaintext, ambient)+ if err != nil {+ t.Fatal(err)+ }+ if got != nil || ambientCalls != 0 {+ t.Fatalf("plaintext proxy = %v, ambient calls = %d; want direct transport", got, ambientCalls)+ }++ secure, err := http.NewRequest(http.MethodPost, "https://pulse.example/api/agents/report", nil)+ if err != nil {+ t.Fatal(err)+ }+ got, err = resolveAgentControlPlaneProxy(secure, ambient)+ if err != nil {+ t.Fatal(err)+ }+ if got == nil || got.String() != proxyURL.String() || ambientCalls != 1 {+ t.Fatalf("HTTPS proxy = %v, ambient calls = %d; want %s", got, ambientCalls, proxyURL)+ }++ client, err := newAgentHTTPClient("", false, "")+ if err != nil {+ t.Fatal(err)+ }+ transport, ok := client.Transport.(*http.Transport)+ if !ok || transport.Proxy == nil {+ t.Fatal("agent HTTP transport does not use the credential-aware proxy policy")+ }+}+func TestNew_ResolvesProxmoxVEHostIdentity(t *testing.T) {mc := &mockCollector{hostInfoFn: func(context.Context) (*gohost.InfoStat, error) {diff --git a/scripts/install.sh b/scripts/install.shindex 995bbea862..b653b471d7 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -1496,6 +1496,15 @@ action_runner_health_matches_activation() {[[ "$health_agent_id" == "$expected_agent_id" && "$health_activation_nonce" == "$expected_nonce" ]]}+action_runner_reestablish_repair_fence() {+ local runner_service="${ACTION_RUNNER_NAME}.service"++ systemctl disable "$runner_service" 2>/dev/null || return 1+ systemctl mask --runtime "$runner_service" 2>/dev/null || return 1+ systemctl daemon-reload 2>/dev/null || return 1+ ! systemctl is-active --quiet "$runner_service" 2>/dev/null+}+# Print pending or active for the exact installed runner credential. Failure is# intentionally indeterminate: callers must not restore a predecessor because# an unreachable server may already have committed and revoked it.@@ -1768,14 +1777,23 @@ provision_action_runner() {log_error "The exact replacement credential and runtime were retained durably; repair is required."replacement_action_token=""rm -f "${ACTION_RUNNER_BINARY_PATH}.new" "${ACTION_RUNNER_SERVICE_UNIT}.new"+ if systemctl unmask --runtime "${ACTION_RUNNER_NAME}.service" 2>/dev/null &&+ systemctl daemon-reload 2>/dev/null &&+ action_runner_verify_effective_target; then+ systemctl enable --now "${ACTION_RUNNER_NAME}.service" 2>/dev/null || true+ else+ log_error "The retained action-runner unit did not pass effective-target validation; re-establishing the repair fence."+ if ! action_runner_reestablish_repair_fence; then+ ACTION_RUNNER_ACTIVATION_NONCE=""+ fail "Action runner recovery could not re-establish the disabled runtime mask after rejecting the effective unit; every local recovery artifact was retained" "$EXIT_GENERAL"+ fi+ log_error "The retained action-runner unit remains stopped, disabled, and runtime-masked."+ firm -f \"${ACTION_RUNNER_BINARY_PATH}${backup_suffix}" \"${ACTION_RUNNER_SERVICE_UNIT}${backup_suffix}" \"${ACTION_RUNNER_ENV_FILE}${backup_suffix}" \"${ACTION_RUNNER_TOKEN_FILE}${backup_suffix}"- systemctl daemon-reload 2>/dev/null || true- systemctl unmask --runtime "${ACTION_RUNNER_NAME}.service" 2>/dev/null || true- systemctl enable --now "${ACTION_RUNNER_NAME}.service" 2>/dev/null || trueACTION_RUNNER_ACTIVATION_NONCE=""fail "Action runner activation requires repair; the new credential and runtime were retained and the previous credential was not restored" "$EXIT_GENERAL"fidiff --git a/scripts/installtests/install_sh_test.go b/scripts/installtests/install_sh_test.goindex 6daac6cff4..18f2c06c55 100644--- a/scripts/installtests/install_sh_test.go+++ b/scripts/installtests/install_sh_test.go@@ -6676,33 +6676,48 @@ func TestInstallSHActionRunnerPostCommitReadinessFailureRetainsReplacement(t *terecoveryConfigFailure boolstopFailure boolrollback bool+ effectiveTargetValid bool+ effectiveTargetDrifts bool+ remaskFailure booltokenWriteBody stringwantToken string}{{name: "durable pending cancellation authorizes rollback", cancelBody: `[[ "$3" == "new-runner-token" ]] || return 1; return 0`, rollback: true,- tokenWriteBody: `printf 'new-runner-token\n' > "$ACTION_RUNNER_TOKEN_FILE"`, wantToken: "old:token\n",+ effectiveTargetValid: true, tokenWriteBody: `printf 'new-runner-token\n' > "$ACTION_RUNNER_TOKEN_FILE"`, wantToken: "old:token\n",},{name: "activation committed or cancel indeterminate", cancelBody: `[[ "$3" == "new-runner-token" ]] || return 1; return 1`,- tokenWriteBody: `printf 'new-runner-token\n' > "$ACTION_RUNNER_TOKEN_FILE"`, wantToken: "new-runner-token\n",+ effectiveTargetValid: true, tokenWriteBody: `printf 'new-runner-token\n' > "$ACTION_RUNNER_TOKEN_FILE"`, wantToken: "new-runner-token\n",+ },+ {+ name: "unsafe effective target stays fenced after indeterminate cancellation", cancelBody: `[[ "$3" == "new-runner-token" ]] || return 1; return 1`,+ effectiveTargetValid: false, tokenWriteBody: `printf 'new-runner-token\n' > "$ACTION_RUNNER_TOKEN_FILE"`, wantToken: "new-runner-token\n",+ },+ {+ name: "post-install effective target drift stays fenced", cancelBody: `[[ "$3" == "new-runner-token" ]] || return 1; return 1`,+ effectiveTargetValid: true, effectiveTargetDrifts: true, tokenWriteBody: `printf 'new-runner-token\n' > "$ACTION_RUNNER_TOKEN_FILE"`, wantToken: "new-runner-token\n",+ },+ {+ name: "effective target remask failure retains repair artifacts", cancelBody: `[[ "$3" == "new-runner-token" ]] || return 1; return 1`,+ effectiveTargetValid: false, remaskFailure: true, tokenWriteBody: `printf 'new-runner-token\n' > "$ACTION_RUNNER_TOKEN_FILE"`, wantToken: "new-runner-token\n",},{name: "replacement authority state durable write failure", cancelBody: "return 1", recoveryConfigFailure: true,- tokenWriteBody: `: > "$ACTION_RUNNER_TOKEN_FILE"`, wantToken: "",+ effectiveTargetValid: true, tokenWriteBody: `: > "$ACTION_RUNNER_TOKEN_FILE"`, wantToken: "",},{name: "failed stop retains fenced recovery material", cancelBody: "return 91", stopFailure: true,- tokenWriteBody: `printf 'new-runner-token\n' > "$ACTION_RUNNER_TOKEN_FILE"`, wantToken: "new-runner-token\n",+ effectiveTargetValid: true, tokenWriteBody: `printf 'new-runner-token\n' > "$ACTION_RUNNER_TOKEN_FILE"`, wantToken: "new-runner-token\n",},} {t.Run(test.name, func(t *testing.T) {- testInstallSHActionRunnerReadinessFailureRetainsReplacement(t, test.cancelBody, test.recoveryConfigFailure, test.stopFailure, test.rollback, test.tokenWriteBody, test.wantToken)+ testInstallSHActionRunnerReadinessFailureRetainsReplacement(t, test.cancelBody, test.recoveryConfigFailure, test.stopFailure, test.rollback, test.effectiveTargetValid, test.effectiveTargetDrifts, test.remaskFailure, test.tokenWriteBody, test.wantToken)})}}-func testInstallSHActionRunnerReadinessFailureRetainsReplacement(t *testing.T, cancelBody string, recoveryConfigFailure, stopFailure, rollback bool, tokenWriteBody, wantToken string) {+func testInstallSHActionRunnerReadinessFailureRetainsReplacement(t *testing.T, cancelBody string, recoveryConfigFailure, stopFailure, rollback, effectiveTargetValid, effectiveTargetDrifts, remaskFailure bool, tokenWriteBody, wantToken string) {t.Helper()cancelFunction := `cancel_pending_action_runner_credential() { ` + cancelBody + `; }`root := t.TempDir()@@ -6746,6 +6761,11 @@ CURL_CA_BUNDLE=""EXIT_GENERAL=1RECOVERY_CONFIG_FAILURE="` + strconv.FormatBool(recoveryConfigFailure) + `"STOP_FAILURE="` + strconv.FormatBool(stopFailure) + `"+EFFECTIVE_TARGET_VALID="` + strconv.FormatBool(effectiveTargetValid) + `"+EFFECTIVE_TARGET_DRIFTS="` + strconv.FormatBool(effectiveTargetDrifts) + `"+EFFECTIVE_TARGET_MARKER="` + filepath.Join(root, "effective-target-validated") + `"+REMASK_FAILURE="` + strconv.FormatBool(remaskFailure) + `"+MASK_COUNT_FILE="` + filepath.Join(root, "runtime-mask-count") + `"CONFIG_WRITE_MARKER="` + filepath.Join(root, "config-write-marker") + `"SERVICE_ACTIVE_MARKER="` + filepath.Join(root, "service-active-marker") + `"generate_action_runner_activation_nonce() { printf '%064d\n' 0; }@@ -6778,6 +6798,15 @@ stat() {systemctl() {printf '%s\n' "$*" >> "` + serviceLog + `"case "$1" in+ mask)+ mask_count=0+ if [[ -e "$MASK_COUNT_FILE" ]]; then read -r mask_count < "$MASK_COUNT_FILE"; fi+ mask_count=$((mask_count + 1))+ printf '%s\n' "$mask_count" > "$MASK_COUNT_FILE"+ if [[ "$REMASK_FAILURE" == "true" && "$mask_count" -gt 2 ]]; then+ return 1+ fi+ ;;restart) : > "$SERVICE_ACTIVE_MARKER" ;;stop)if [[ "$STOP_FAILURE" == "true" ]]; then@@ -6790,12 +6819,20 @@ systemctl() {return 0}action_runner_health_matches_activation() { return 1; }+action_runner_verify_effective_target() {+ [[ "$EFFECTIVE_TARGET_VALID" == "true" ]] || return 1+ if [[ "$EFFECTIVE_TARGET_DRIFTS" == "true" && -e "$EFFECTIVE_TARGET_MARKER" ]]; then+ return 1+ fi+ : > "$EFFECTIVE_TARGET_MARKER"+}resolve_action_runner_agent_id() { printf 'agent-1\n'; }` + cancelFunction + `sleep() { return 0; }log_error() { printf 'ERROR: %s\n' "$1" >&2; }log_info() { printf 'INFO: %s\n' "$1"; }fail() { printf 'FAIL: %s\n' "$1" >&2; exit "$2"; }+` + extractInstallShellFunction(t, "action_runner_reestablish_repair_fence") + `` + extractInstallShellFunction(t, "provision_action_runner") + `provision_action_runner`@@ -6844,10 +6881,11 @@ provision_action_runnerif err != nil {t.Fatal(err)}- if (recoveryConfigFailure || stopFailure) && len(backups) == 0 {+ retainsRepairArtifacts := recoveryConfigFailure || stopFailure || remaskFailure+ if retainsRepairArtifacts && len(backups) == 0 {t.Fatal("durable authority-state failure removed every predecessor backup before repair")}- if !recoveryConfigFailure && !stopFailure && len(backups) != 0 {+ if !retainsRepairArtifacts && len(backups) != 0 {t.Fatalf("revoked predecessor backups retained: %v", backups)}serviceCalls, err := os.ReadFile(serviceLog)@@ -6863,7 +6901,7 @@ provision_action_runnerif disableAt < 0 || maskAt < disableAt || writeAt < maskAt {t.Fatalf("runner was not disabled and runtime-masked before authority files changed: %s", serviceCalls)}- if (recoveryConfigFailure || stopFailure) && strings.Contains(string(serviceCalls), "enable --now pulse-agent-runner.service") {+ if (recoveryConfigFailure || stopFailure || remaskFailure) && strings.Contains(string(serviceCalls), "enable --now pulse-agent-runner.service") {t.Fatalf("runner restarted without a complete durable authority state: %s", serviceCalls)}serviceLines := "\n" + string(serviceCalls)@@ -6872,12 +6910,23 @@ provision_action_runnerif (recoveryConfigFailure || stopFailure) && lastMaskAt < lastUnmaskAt {t.Fatalf("runner remained unmasked without a complete durable authority state: %s", serviceCalls)}- if !recoveryConfigFailure && !stopFailure && !strings.Contains(string(serviceCalls), "enable --now pulse-agent-runner.service") {+ if !recoveryConfigFailure && !stopFailure && effectiveTargetValid && !effectiveTargetDrifts && !strings.Contains(string(serviceCalls), "enable --now pulse-agent-runner.service") {t.Fatalf("replacement was not stopped for classification and restarted for repair: %s", serviceCalls)}- if !recoveryConfigFailure && !stopFailure && lastUnmaskAt < lastMaskAt {+ if !recoveryConfigFailure && !stopFailure && effectiveTargetValid && !effectiveTargetDrifts && lastUnmaskAt < lastMaskAt {t.Fatalf("complete authority state was not unmasked for restart: %s", serviceCalls)}+ if !recoveryConfigFailure && !stopFailure && (!effectiveTargetValid || effectiveTargetDrifts) {+ if strings.Contains(string(serviceCalls), "enable --now pulse-agent-runner.service") {+ t.Fatalf("unsafe effective target was restarted: %s", serviceCalls)+ }+ if lastMaskAt < lastUnmaskAt || !strings.Contains(string(out), "effective-target validation") {+ t.Fatalf("unsafe effective target did not remain fenced with an actionable diagnostic:\n%s\n%s", serviceCalls, out)+ }+ }+ if remaskFailure && !strings.Contains(string(out), "could not re-establish the disabled runtime mask") {+ t.Fatalf("remask failure was not surfaced explicitly:\n%s\n%s", serviceCalls, out)+ }}func TestInstallSHActionRunnerAtomicCancelUsesPrivateGoTransportAndRequires204(t *testing.T) {