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.

Bound unattended installer downloads before signed execution

pulse-triage[bot]c1139b83ecff
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 6d6d67c114..1ca8c91856 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -7522,6 +7522,14 @@ symlinks/non-regular snapshot sources, allocation/copy/comparison failures and
failed download/signature verification stop before installer mutation. An
unneeded pre-mutation snapshot and verification files are removed on return.
+Both versioned installer and signature transfers ignore ambient curl settings,
+allow only HTTPS (including redirects), and have a five-second connection and
+sixty-second whole-transfer limit. Partial data after connection, HTTP or timeout
+failure cannot reach signature verification or installer execution; there is no
+download retry or alternate source. These per-transfer bounds leave time inside
+the unchanged ten-minute systemd transaction for installation and recovery.
+They do not extend a stop/restart deadline or relax the pinned SSH verifier.
+
Installer failure, mismatched version and failure to restore a previously active
service share one rollback path. It stops the service, stages and compares all
saved files before any replacement, and renames each into its recorded original
@@ -7556,6 +7564,15 @@ cleanup. Exact-parent negative controls must reject ignored snapshot failures
and loss of the backup after a failed restore. Synthetic proof is not a deployed
update, native systemd migration or reporter confirmation.
+`TestAutoUpdateAssetTransport` uses real curl and disposable trusted HTTPS
+servers to check complete/redirected bytes, certificate refusal, HTTPS-to-HTTP
+refusal and an actual stalled-transfer deadline. `TestAutoUpdateDownloadFailures`
+runs the complete conditional updater with partial connection/HTTP/timeout
+failures for either asset and both prior-active states, requiring unchanged
+binary/version/configuration/identity, no installer/manager mutation, exact
+requests, and removal of all temporary files. These controls do not establish
+published-installer or installed-host recovery.
+
### Governed dependency floors for the go-minor-patch group
The managed `go-minor-patch` group advances three direct modules together with
diff --git a/scripts/installtests/install_sh_test.go b/scripts/installtests/install_sh_test.go
index 1336bccd8b..9ebadf24dc 100644
--- a/scripts/installtests/install_sh_test.go
+++ b/scripts/installtests/install_sh_test.go
@@ -5478,7 +5478,8 @@ url=""
while [[ $# -gt 0 ]]; do
case "$1" in
-o) out="$2"; shift 2 ;;
- -fsSL) shift ;;
+ --disable|-fsSL) shift ;;
+ --connect-timeout|--max-time|--proto|--proto-redir) shift 2 ;;
*) [[ -z "$url" ]] || exit 95; url="$1"; shift ;;
esac
done
@@ -5580,8 +5581,9 @@ fi
return
}
logContent, err := os.ReadFile(filepath.Join(tmpDir, "curl.log"))
- want := "-fsSL https://github.com/rcourtman/Pulse/releases/download/v9.9.9/install.sh -o "
- wantSignature := "-fsSL https://github.com/rcourtman/Pulse/releases/download/v9.9.9/install.sh.sshsig -o "
+ policy := "--disable -fsSL --connect-timeout 5 --max-time 60 --proto =https --proto-redir =https "
+ want := policy + "https://github.com/rcourtman/Pulse/releases/download/v9.9.9/install.sh -o "
+ wantSignature := policy + "https://github.com/rcourtman/Pulse/releases/download/v9.9.9/install.sh.sshsig -o "
requests := strings.Split(strings.TrimSpace(string(logContent)), "\n")
if err != nil || len(requests) != 2 || !strings.HasPrefix(requests[0], want) ||
!strings.HasPrefix(requests[1], wantSignature) {
diff --git a/scripts/installtests/pulse_auto_update_download_test.go b/scripts/installtests/pulse_auto_update_download_test.go
new file mode 100644
index 0000000000..8df0db007a
--- /dev/null
+++ b/scripts/installtests/pulse_auto_update_download_test.go
@@ -0,0 +1,116 @@
+package installtests
+
+import (
+ "context"
+ "encoding/pem"
+ "io"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "sync/atomic"
+ "testing"
+ "time"
+)
+
+// Actual curl/TLS/deadline behavior, without contacting a provider or running an
+// installer. The complete transaction/failure controls below remain separate.
+func TestAutoUpdateAssetTransport(t *testing.T) {
+ if _, err := exec.LookPath("curl"); err != nil {
+ t.Fatal("curl is required for the updater transport controls")
+ }
+ var insecureRequests atomic.Int32
+ insecure := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ insecureRequests.Add(1)
+ _, _ = io.WriteString(w, "must not be downloaded")
+ }))
+ defer insecure.Close()
+ server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ switch r.URL.Path {
+ case "/redirect":
+ http.Redirect(w, r, "/asset", http.StatusFound)
+ case "/downgrade":
+ http.Redirect(w, r, insecure.URL, http.StatusFound)
+ case "/stalled":
+ w.Header().Set("Content-Length", "100")
+ _, _ = io.WriteString(w, "partial bytes")
+ w.(http.Flusher).Flush()
+ <-r.Context().Done()
+ default:
+ _, _ = io.WriteString(w, "complete signed-asset fixture\n")
+ }
+ }))
+ defer server.Close()
+ for _, tc := range []struct {
+ name, path string
+ trusted bool
+ exit int
+ }{
+ {"complete", "/asset", true, 0},
+ {"https_redirect", "/redirect", true, 0},
+ {"untrusted_certificate", "/asset", false, 60},
+ {"http_downgrade", "/downgrade", true, 1},
+ {"stalled_transfer", "/stalled", true, 28},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ dir := t.TempDir()
+ ca := filepath.Join(dir, "ca.pem")
+ if err := os.WriteFile(ca, pem.EncodeToMemory(&pem.Block{
+ Type: "CERTIFICATE", Bytes: server.Certificate().Raw,
+ }), 0600); err != nil {
+ t.Fatal(err)
+ }
+ // A broken ambient proxy would fail even the complete control if
+ // --disable were absent or ceased to be curl's first argument.
+ if err := os.WriteFile(filepath.Join(dir, ".curlrc"), []byte("proxy = http://127.0.0.1:1\n"), 0600); err != nil {
+ t.Fatal(err)
+ }
+ updater, err := filepath.Abs(repoFile("scripts", "pulse-auto-update.sh"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ asset := filepath.Join(dir, "asset")
+ ctx, cancel := context.WithTimeout(context.Background(), 80*time.Second)
+ defer cancel()
+ cmd := exec.CommandContext(ctx, "bash", "-c",
+ `source "$PULSE_TEST_UPDATER"; download_update_asset "$PULSE_TEST_URL" "$PULSE_TEST_ASSET"`)
+ cmd.Env = append(os.Environ(), "PULSE_TEST_UPDATER="+updater,
+ "PULSE_TEST_URL="+server.URL+tc.path, "PULSE_TEST_ASSET="+asset,
+ "CURL_HOME="+dir, "HOME="+dir, "NO_PROXY=", "no_proxy=",
+ "HTTPS_PROXY=", "https_proxy=", "ALL_PROXY=", "all_proxy=", "SSL_CERT_FILE=")
+ if tc.trusted {
+ cmd.Env = append(cmd.Env, "CURL_CA_BUNDLE="+ca)
+ } else {
+ cmd.Env = append(cmd.Env, "CURL_CA_BUNDLE=")
+ }
+ started := time.Now()
+ out, err := cmd.CombinedOutput()
+ elapsed := time.Since(started)
+ exit := 0
+ if err != nil {
+ failure, ok := err.(*exec.ExitError)
+ if !ok {
+ t.Fatalf("transport command result unavailable: %v", err)
+ }
+ exit = failure.ExitCode()
+ }
+ if ctx.Err() != nil || exit != tc.exit {
+ t.Fatalf("transport exit=%d want=%d context=%v: %s", exit, tc.exit, ctx.Err(), out)
+ }
+ bytes, readErr := os.ReadFile(asset)
+ if tc.exit == 0 && (readErr != nil || string(bytes) != "complete signed-asset fixture\n") {
+ t.Fatalf("successful transfer bytes: %v %q", readErr, bytes)
+ }
+ if tc.path == "/stalled" {
+ if elapsed < 55*time.Second || elapsed > 75*time.Second || string(bytes) != "partial bytes" {
+ t.Fatalf("stalled transfer elapsed=%v bytes=%q read=%v", elapsed, bytes, readErr)
+ }
+ }
+ t.Logf("curl exit=%d elapsed=%s asset_bytes=%d", exit, elapsed.Round(time.Millisecond), len(bytes))
+ })
+ }
+ if got := insecureRequests.Load(); got != 0 {
+ t.Fatalf("HTTPS downgrade reached the HTTP destination %d times", got)
+ }
+}
diff --git a/scripts/installtests/pulse_auto_update_test.go b/scripts/installtests/pulse_auto_update_test.go
index 1cbc7110cf..7249d67708 100644
--- a/scripts/installtests/pulse_auto_update_test.go
+++ b/scripts/installtests/pulse_auto_update_test.go
@@ -136,6 +136,25 @@ func TestAutoUpdateServiceDiscoveryAndInstallerHandoff(t *testing.T) {
}
}
+func TestAutoUpdateDownloadFailures(t *testing.T) {
+ ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
+ defer cancel()
+ cmd := exec.CommandContext(ctx, "python3", repoFile("scripts", "tests", "test_auto_update_service_state.py"), "-v", "UpdateDownloads")
+ cmd.Env = append(os.Environ(), "PULSE_AUTO_UPDATER_UNDER_TEST="+repoFile("scripts", "pulse-auto-update.sh"))
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ t.Fatalf("complete updater download-failure controls: %v\n%s", err, out)
+ }
+ for _, name := range []string{
+ "test_both_complete_downloads_keep_the_exact_signed_installer_handoff",
+ "test_partial_failed_downloads_never_execute_or_mutate_the_install",
+ } {
+ if !strings.Contains(string(out), fmt.Sprintf("%s (", name)) {
+ t.Fatalf("missing updater download control %s:\n%s", name, out)
+ }
+ }
+}
+
// Service-state admission is independent of the signed/metadata transaction
// matrix below; no native service or published input is used by this fixture.
func TestAutoUpdateServiceStateFailsClosed(t *testing.T) {
diff --git a/scripts/pulse-auto-update.sh b/scripts/pulse-auto-update.sh
index 974f7cdb4b..d51ce53b91 100755
--- a/scripts/pulse-auto-update.sh
+++ b/scripts/pulse-auto-update.sh
@@ -391,6 +391,15 @@ resolve_install_script_url() {
printf 'https://github.com/%s/releases/download/%s/install.sh\n' "$GITHUB_REPO" "$target_version"
}
+# Small signed installer assets must not consume the systemd transaction's
+# entire ten-minute budget before installation/recovery can even start. Ignore
+# ambient curl configuration and refuse a redirect that downgrades HTTPS.
+# Signature verification remains mandatory after both complete transfers.
+download_update_asset() {
+ curl --disable -fsSL --connect-timeout 5 --max-time 60 \
+ --proto '=https' --proto-redir '=https' "$1" -o "$2"
+}
+
# Read a complete, bounded manager observation. An is-active failure conflates
# an inactive unit with an unavailable manager; neither missing text nor a
# plausible partial result grants an update, restart or rollback.
@@ -643,11 +652,11 @@ perform_update() {
return 1
fi
- if ! curl -fsSL "$install_script_url" -o "$installer_tmp"; then
+ if ! download_update_asset "$install_script_url" "$installer_tmp"; then
log error "Failed to download installer from $install_script_url"
return 1
fi
- if ! curl -fsSL "$install_signature_url" -o "$signature_tmp"; then
+ if ! download_update_asset "$install_signature_url" "$signature_tmp"; then
log error "Failed to download installer signature from $install_signature_url"
return 1
fi
diff --git a/scripts/tests/test_auto_update_service_state.py b/scripts/tests/test_auto_update_service_state.py
index 4726535aa5..007bf5fb42 100644
--- a/scripts/tests/test_auto_update_service_state.py
+++ b/scripts/tests/test_auto_update_service_state.py
@@ -102,12 +102,18 @@ mktemp() {
command mktemp "${args[@]}"
}
curl() {
+ printf '%s\000' "$#" "$@" >> "$FIXTURE/curl-calls"
local out="" url=""
while (( $# )); do
case "$1" in -o) out="$2"; shift ;; https://*) url="$1" ;; esac
shift
done
printf '%s\n' "$url" >> "$FIXTURE/downloads"
+ if [[ "$DOWNLOAD_FAULT" == installer:* && "$url" != *.sshsig ]] ||
+ [[ "$DOWNLOAD_FAULT" == signature:* && "$url" == *.sshsig ]]; then
+ printf 'partial unverified input\n' > "$out"
+ return "${DOWNLOAD_FAULT#*:}"
+ fi
if [[ "$url" == *.sshsig ]]; then printf 'fixture signature\n' > "$out"
else command cp "$FIXTURE/installer" "$out"; fi
}
@@ -175,7 +181,7 @@ def read_logger_calls(path):
class UpdaterFixture(unittest.TestCase):
def run_fixture(self, *, mode="normal", state="active", load="loaded", success=False, flow="update",
installer_exit=None, collector_exit=0, installer_output=None, collector_failures=None,
- real_log=False, runtime_exit=0, installer_state=None):
+ real_log=False, runtime_exit=0, installer_state=None, download_fault=""):
with tempfile.TemporaryDirectory(prefix="pulse-updater-state-") as directory:
f = Path(directory)
for name in ("tools", "tmp", "install/bin", "config"):
@@ -215,6 +221,7 @@ class UpdaterFixture(unittest.TestCase):
INSTALLER_EXIT=str(installer_exit) if installer_exit is not None else ("0" if success else "23"),
COLLECTOR_EXIT=str(collector_exit),
REAL_LOG="true" if real_log else "false", RUNTIME_EXIT=str(runtime_exit),
+ DOWNLOAD_FAULT=download_fault,
PATH=str(f / "tools") + os.pathsep + os.environ["PATH"])
for line, status in (collector_failures or {}).items():
env[f"COLLECTOR_EXIT_{line}"] = str(status)
@@ -231,6 +238,8 @@ class UpdaterFixture(unittest.TestCase):
if (f / "runtime-probes").exists() else [],
collected=int((f / "collector-count").read_text()) if (f / "collector-count").exists() else 0,
logger_calls=read_logger_calls(f / "logger-calls"),
+ curl_calls=read_logger_calls(f / "curl-calls"),
+ temporary_files=[p.name for p in (f / "tmp").iterdir()],
started=(f / "start-ran").exists(), state=(f / "state").read_text().strip(),
binary=(f / "install/bin/pulse").read_bytes(), version=(f / "install/VERSION").read_text(),
backups=[(b / "pulse-bin").read_bytes() for b in backups],
@@ -244,6 +253,45 @@ class UpdaterFixture(unittest.TestCase):
return observation
+class UpdateDownloads(UpdaterFixture):
+ def assert_download_policy(self, calls):
+ self.assertTrue(calls)
+ for args in calls:
+ self.assertEqual(args[:10], ["--disable", "-fsSL", "--connect-timeout", "5",
+ "--max-time", "60", "--proto", "=https",
+ "--proto-redir", "=https"])
+ self.assertEqual(len(args), 13)
+ self.assertTrue(args[10].startswith("https://github.com/rcourtman/Pulse/releases/download/v6.6.0/"))
+ self.assertEqual(args[11], "-o")
+
+ def test_both_complete_downloads_keep_the_exact_signed_installer_handoff(self):
+ result = self.run_fixture(success=True, installer_state="active")
+ self.assertEqual(result["exit"], 0, result)
+ self.assertTrue(result["installer_finished"])
+ self.assert_download_policy(result["curl_calls"])
+ self.assertEqual([args[10].rsplit("/", 1)[1] for args in result["curl_calls"]],
+ ["install.sh", "install.sh.sshsig"])
+ self.assertEqual(result["temporary_files"], [])
+
+ def test_partial_failed_downloads_never_execute_or_mutate_the_install(self):
+ for asset in ("installer", "signature"):
+ for status in (7, 22, 28): # Connection, HTTP refusal, timeout.
+ for state in ("active", "inactive"):
+ with self.subTest(asset=asset, status=status, state=state):
+ result = self.run_fixture(state=state, download_fault=f"{asset}:{status}")
+ self.assertEqual(result["exit"], 1, result)
+ self.assertFalse(result["installed"])
+ self.assertFalse(result["stopped"])
+ self.assertFalse(result["started"])
+ self.assertEqual(result["state"], state)
+ self.assertEqual(result["binary"], b"#!/bin/sh\necho 'Pulse v6.5.0'\n")
+ self.assertEqual(result["version"], "v6.5.0\n")
+ self.assertEqual(result["temporary_files"], [])
+ self.assertEqual(len(result["curl_calls"]), 1 if asset == "installer" else 2)
+ self.assert_download_policy(result["curl_calls"])
+ self.assertIn("Failed to download installer", result["output"])
+
+
class UpdateLogSinks(UpdaterFixture):
def test_logger_double_keeps_complete_argument_frames_and_exit_sequence(self):
with tempfile.TemporaryDirectory(prefix="pulse-updater-logger-") as directory: