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
Verify SSHSIG on in-app update artifacts
rcourtman2f0468a87be6
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.mdindex dbd2a8d06c..0b0e3cfb24 100644--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md@@ -743,7 +743,17 @@ root `install.sh`, its generated update helper, and`scripts/pulse-auto-update.sh` must verify downloaded release tarballs andinstaller scripts against the pinned release `.sshsig` sidecars beforeexecution, rather than treating same-origin checksum files as a sufficient-trust anchor.+trust anchor. The in-app updater binds to the same invariant: every+release artifact the Go updater fetches before applying or rolling back —+the update tarball in `internal/updates/manager.go::ApplyUpdate`, the+`install.sh` piped into bash by `internal/updates/adapter_installsh.go::downloadInstallScript`,+and the rollback binary tarball in+`internal/updates/adapter_installsh.go::downloadBinary` — must verify+its `.sshsig` sidecar against the pinned `pulse-installer` ed25519 key+(identity `pulse-installer`, namespace `pulse-install`) and refuse to+proceed if the sidecar is missing, malformed, or fails verification. The+in-app and unattended paths must share the same trust root so the UI's+"Update now" button cannot run at a lower bar than the systemd timer.The unattended auto-update path is also fail-closed on prerelease channelcrossing: `scripts/pulse-auto-update.sh` must refuse to act on any tag thatcarries a semver prerelease suffix (`-rc.N`, `-beta.N`, `-alpha.N`,diff --git a/internal/updates/adapter_installsh.go b/internal/updates/adapter_installsh.goindex d3de63b6a4..fe7d22983b 100644--- a/internal/updates/adapter_installsh.go+++ b/internal/updates/adapter_installsh.go@@ -526,6 +526,13 @@ func (a *InstallShAdapter) downloadBinary(ctx context.Context, version string) (log.Debug().Err(removeErr).Str("path", checksumPath).Msg("Failed to remove checksum file")}+ // Verify the SSHSIG sidecar against the pinned pulse-installer key — same+ // trust root the unattended timer and public install.sh enforce.+ if err := fetchAndVerifyReleaseSignature(ctx, url, tarballPath); err != nil {+ os.RemoveAll(tmpDir)+ return "", fmt.Errorf("signature verification failed for %s: %w", tarballName, err)+ }+// Extract tarball to get the binaryextractDir := filepath.Join(tmpDir, "extracted")if err := os.MkdirAll(extractDir, 0755); err != nil {@@ -699,6 +706,13 @@ func (a *InstallShAdapter) downloadInstallScript(ctx context.Context, version streturn "", fmt.Errorf("install.sh checksum verification failed")}+ // Verify the SSHSIG sidecar before we pipe install.sh into bash as root.+ // scripts/pulse-auto-update.sh and the public scripts/install.sh both+ // require this; the in-app updater must too.+ if err := fetchAndVerifyReleaseSignature(ctx, installScriptURL, scriptPath); err != nil {+ return "", fmt.Errorf("install.sh signature verification failed: %w", err)+ }+content, err := os.ReadFile(scriptPath)if err != nil {return "", fmt.Errorf("failed to read install.sh: %w", err)diff --git a/internal/updates/adapter_installsh_exec_test.go b/internal/updates/adapter_installsh_exec_test.goindex ca5abf0e4c..4c5bbc1c8d 100644--- a/internal/updates/adapter_installsh_exec_test.go+++ b/internal/updates/adapter_installsh_exec_test.go@@ -12,6 +12,7 @@ import ()func TestInstallShAdapter_DownloadBinary(t *testing.T) {+ stubReleaseSignatureVerification(t)tarball := filepath.Join(t.TempDir(), "pulse.tar.gz")writeTarGz(t, tarball, map[string]string{"bin/pulse": "binary",diff --git a/internal/updates/adapter_installsh_execute_test.go b/internal/updates/adapter_installsh_execute_test.goindex 6980d98e47..49f20b6841 100644--- a/internal/updates/adapter_installsh_execute_test.go+++ b/internal/updates/adapter_installsh_execute_test.go@@ -85,6 +85,7 @@ func setupBashArgCaptureStub(t *testing.T, argsFile string) string {}func TestInstallShAdapterExecuteSuccess(t *testing.T) {+ stubReleaseSignatureVerification(t)scriptContent := "echo ok"curlDir := setupInstallShCurlStub(t, scriptContent)bashDir := setupBashStub(t)@@ -121,6 +122,7 @@ func TestInstallShAdapterExecuteSuccess(t *testing.T) {}func TestInstallShAdapterExecuteInvalidVersion(t *testing.T) {+ stubReleaseSignatureVerification(t)scriptContent := "echo ok"curlDir := setupInstallShCurlStub(t, scriptContent)t.Setenv("PATH", curlDir+string(os.PathListSeparator)+os.Getenv("PATH"))@@ -140,6 +142,7 @@ func TestInstallShAdapterExecuteInvalidVersion(t *testing.T) {}func TestInstallShAdapterExecuteForceDoesNotPassUnsupportedFlag(t *testing.T) {+ stubReleaseSignatureVerification(t)scriptContent := "echo ok"curlDir := setupInstallShCurlStub(t, scriptContent)argsFile := filepath.Join(t.TempDir(), "bash-args.txt")diff --git a/internal/updates/adapter_installsh_extra_test.go b/internal/updates/adapter_installsh_extra_test.goindex b2c9609b3f..66367f615d 100644--- a/internal/updates/adapter_installsh_extra_test.go+++ b/internal/updates/adapter_installsh_extra_test.go@@ -76,6 +76,7 @@ exit 0}func TestInstallShAdapterDownloadInstallScript(t *testing.T) {+ stubReleaseSignatureVerification(t)content := []byte("#!/bin/sh\necho ok\n")sum := sha256.Sum256(content)@@ -113,6 +114,7 @@ func TestInstallShAdapterDownloadInstallScript(t *testing.T) {}func TestInstallShAdapterDownloadBinary(t *testing.T) {+ stubReleaseSignatureVerification(t)extractDir := t.TempDir()tarball := filepath.Join(extractDir, "pulse-v1.2.3-linux-amd64.tar.gz")writeTarGz(t, tarball, map[string]string{diff --git a/internal/updates/adapter_installsh_helpers_test.go b/internal/updates/adapter_installsh_helpers_test.goindex ea78a1abf8..78b25b45c6 100644--- a/internal/updates/adapter_installsh_helpers_test.go+++ b/internal/updates/adapter_installsh_helpers_test.go@@ -38,6 +38,7 @@ exit 0}func TestInstallShAdapter_DownloadInstallScript(t *testing.T) {+ stubReleaseSignatureVerification(t)content := "echo hi"sum := sha256.Sum256([]byte(content))checksum := hex.EncodeToString(sum[:])diff --git a/internal/updates/manager.go b/internal/updates/manager.goindex a44edb813e..fa43a1aa1d 100644--- a/internal/updates/manager.go+++ b/internal/updates/manager.go@@ -597,6 +597,18 @@ func (m *Manager) ApplyUpdate(ctx context.Context, req ApplyUpdateRequest) error})}+ // Verify SSHSIG signature against the pinned pulse-installer key. This is+ // the same trust root scripts/pulse-auto-update.sh and scripts/install.sh+ // already enforce; the in-app updater must not run at a lower bar.+ m.updateStatus("verifying", 25, "Verifying signature...")+ if err := m.downloadAndVerifyReleaseSignature(ctx, validatedDownloadURL, tarballPath); err != nil {+ sigErr := fmt.Errorf("signature verification failed: %w", err)+ m.updateStatus("error", 25, "Failed to verify update signature", sigErr)+ runErr = sigErr+ return runErr+ }+ log.Info().Msg("Signature verification passed")+// Verify checksum if availablem.updateStatus("verifying", 30, "Verifying download...")if err := m.verifyChecksum(ctx, req.DownloadURL, tarballPath); err != nil {diff --git a/internal/updates/signature.go b/internal/updates/signature.gonew file mode 100644index 0000000000..303011bc43--- /dev/null+++ b/internal/updates/signature.go@@ -0,0 +1,174 @@+package updates++import (+ "context"+ "fmt"+ "io"+ "net/http"+ "net/url"+ "os"+ "os/exec"+ "path/filepath"+ "strings"+ "time"+)++// SSHSIG verification constants for release artifacts.+//+// The release-build pipeline (scripts/build-release.sh, scripts/release_asset_common.sh)+// signs every published asset with ssh-keygen -Y sign using these identity+// and namespace values. The unattended timer (scripts/pulse-auto-update.sh)+// and the public bootstrap (scripts/install.sh, /install.sh) verify against+// the same pinned key. Anything that opens up a release artifact for+// installation must verify against the same trust root, otherwise the in-app+// path runs at a lower trust bar than the shell paths.+//+// If the signing key is rotated, all four locations need to move together:+// - scripts/pulse-auto-update.sh PINNED_RELEASE_SSH_PUBLIC_KEY+// - scripts/install.sh PINNED_INSTALLER_SSH_PUBLIC_KEY (template-filled)+// - /install.sh PINNED_RELEASE_SSH_PUBLIC_KEY (public bootstrap)+// - this file+const (+ releaseSignatureIdentity = "pulse-installer"+ releaseSignatureNamespace = "pulse-install"+ pinnedReleaseSSHPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMZd/DaH+BldzOkq1A8KVTcFk73nAyrE8aJOyf7i00jm pulse-installer"++ maxReleaseSignatureBytes int64 = 16 * 1024+ signatureFetchTimeout = 30 * time.Second+)++// verifyReleaseSignatureFunc is the package-level signature verifier. Tests+// override it to avoid requiring ssh-keygen on the build host.+var verifyReleaseSignatureFunc = verifyReleaseSignatureExec++// verifyReleaseSignatureExec verifies that signaturePath is a valid SSHSIG+// over the contents of targetPath, signed by the pinned pulse-installer key.+// Shells out to ssh-keygen -Y verify so the in-app updater shares the exact+// trust path used by scripts/pulse-auto-update.sh and scripts/install.sh.+func verifyReleaseSignatureExec(ctx context.Context, targetPath, signaturePath string) error {+ if _, err := exec.LookPath("ssh-keygen"); err != nil {+ return fmt.Errorf("ssh-keygen is required to verify release signatures: %w", err)+ }++ allowed, err := os.CreateTemp("", "pulse-allowed-signers-*")+ if err != nil {+ return fmt.Errorf("create allowed_signers file: %w", err)+ }+ allowedPath := allowed.Name()+ defer os.Remove(allowedPath)++ if _, err := fmt.Fprintf(allowed, "%s %s\n", releaseSignatureIdentity, pinnedReleaseSSHPublicKey); err != nil {+ allowed.Close()+ return fmt.Errorf("write allowed_signers file: %w", err)+ }+ if err := allowed.Close(); err != nil {+ return fmt.Errorf("close allowed_signers file: %w", err)+ }++ target, err := os.Open(targetPath)+ if err != nil {+ return fmt.Errorf("open signed payload %q: %w", targetPath, err)+ }+ defer target.Close()++ cmd := exec.CommandContext(ctx, "ssh-keygen",+ "-Y", "verify",+ "-f", allowedPath,+ "-I", releaseSignatureIdentity,+ "-n", releaseSignatureNamespace,+ "-s", signaturePath,+ )+ cmd.Stdin = target+ out, err := cmd.CombinedOutput()+ if err != nil {+ return fmt.Errorf("ssh-keygen verify: %w (output: %s)", err, strings.TrimSpace(string(out)))+ }+ return nil+}++// signatureURLFor returns the .sshsig sidecar URL for a given release-asset URL.+func signatureURLFor(assetURL *url.URL) *url.URL {+ sigURL := *assetURL+ sigURL.Path = assetURL.Path + ".sshsig"+ sigURL.RawPath = ""+ return &sigURL+}++// downloadAndVerifyReleaseSignature fetches the .sshsig sidecar for assetURL+// and verifies it against assetPath, fail-closed. The signature is downloaded+// to a temp file in the same directory as assetPath and removed before+// returning. If ssh-keygen is missing, the signature endpoint is unreachable,+// or verification fails, the caller must abort the update.+func (m *Manager) downloadAndVerifyReleaseSignature(ctx context.Context, assetURL *url.URL, assetPath string) error {+ sigURL := signatureURLFor(assetURL)++ client := &http.Client{Timeout: signatureFetchTimeout}+ resp, err := m.getWithRetry(ctx, client, sigURL, nil, "download release signature")+ if err != nil {+ return fmt.Errorf("fetch %s: %w", sigURL.String(), err)+ }+ defer resp.Body.Close()++ return readSignatureAndVerify(ctx, resp, sigURL.String(), assetPath)+}++// fetchAndVerifyReleaseSignature is the http.Get-based counterpart to+// downloadAndVerifyReleaseSignature, used by callers that aren't on Manager.+// It is a package-level variable so tests can stub the full fetch+verify+// without standing up a real .sshsig endpoint.+var fetchAndVerifyReleaseSignature = fetchAndVerifyReleaseSignatureReal++func fetchAndVerifyReleaseSignatureReal(ctx context.Context, assetURL string, assetPath string) error {+ parsed, err := url.Parse(assetURL)+ if err != nil {+ return fmt.Errorf("parse asset URL: %w", err)+ }+ sigURL := signatureURLFor(parsed)++ req, err := http.NewRequestWithContext(ctx, http.MethodGet, sigURL.String(), nil)+ if err != nil {+ return fmt.Errorf("build signature request: %w", err)+ }++ client := &http.Client{Timeout: signatureFetchTimeout}+ resp, err := client.Do(req)+ if err != nil {+ return fmt.Errorf("fetch %s: %w", sigURL.String(), err)+ }+ defer resp.Body.Close()++ return readSignatureAndVerify(ctx, resp, sigURL.String(), assetPath)+}++func readSignatureAndVerify(ctx context.Context, resp *http.Response, sigURL string, assetPath string) error {+ if resp.StatusCode != http.StatusOK {+ return fmt.Errorf("signature URL %s returned status %d", sigURL, resp.StatusCode)+ }++ sigPath := assetPath + ".sshsig"+ sigFile, err := os.OpenFile(sigPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)+ if err != nil {+ return fmt.Errorf("create signature file: %w", err)+ }+ defer os.Remove(sigPath)++ written, err := io.Copy(sigFile, io.LimitReader(resp.Body, maxReleaseSignatureBytes+1))+ closeErr := sigFile.Close()+ if err != nil {+ return fmt.Errorf("read signature body: %w", err)+ }+ if closeErr != nil {+ return fmt.Errorf("close signature file: %w", closeErr)+ }+ if written > maxReleaseSignatureBytes {+ return fmt.Errorf("signature %s exceeds %d bytes", filepath.Base(sigPath), maxReleaseSignatureBytes)+ }+ if written == 0 {+ return fmt.Errorf("signature %s was empty", filepath.Base(sigPath))+ }++ if err := verifyReleaseSignatureFunc(ctx, assetPath, sigPath); err != nil {+ return fmt.Errorf("verify signature for %s: %w", filepath.Base(assetPath), err)+ }+ return nil+}diff --git a/internal/updates/signature_test.go b/internal/updates/signature_test.gonew file mode 100644index 0000000000..ec57718a12--- /dev/null+++ b/internal/updates/signature_test.go@@ -0,0 +1,186 @@+package updates++import (+ "context"+ "errors"+ "net/http"+ "net/http/httptest"+ "net/url"+ "os"+ "path/filepath"+ "strings"+ "testing"+)++// stubReleaseSignatureVerification replaces the package-level signature+// verifier and fetch-and-verify helper with no-op stubs so tests that+// exercise update paths don't need ssh-keygen or a real .sshsig endpoint.+// The previous values are restored via t.Cleanup.+func stubReleaseSignatureVerification(t *testing.T) {+ t.Helper()+ prevFetch := fetchAndVerifyReleaseSignature+ prevVerify := verifyReleaseSignatureFunc+ fetchAndVerifyReleaseSignature = func(ctx context.Context, assetURL, assetPath string) error { return nil }+ verifyReleaseSignatureFunc = func(ctx context.Context, targetPath, signaturePath string) error { return nil }+ t.Cleanup(func() {+ fetchAndVerifyReleaseSignature = prevFetch+ verifyReleaseSignatureFunc = prevVerify+ })+}++func TestSignatureURLForAppendsSshsig(t *testing.T) {+ parsed, err := url.Parse("https://github.com/rcourtman/Pulse/releases/download/v6.0.0/pulse-v6.0.0-linux-amd64.tar.gz")+ if err != nil {+ t.Fatalf("parse: %v", err)+ }+ got := signatureURLFor(parsed).String()+ want := "https://github.com/rcourtman/Pulse/releases/download/v6.0.0/pulse-v6.0.0-linux-amd64.tar.gz.sshsig"+ if got != want {+ t.Fatalf("signatureURLFor() = %q, want %q", got, want)+ }+}++func TestFetchAndVerifyReleaseSignatureSuccess(t *testing.T) {+ dir := t.TempDir()+ assetPath := filepath.Join(dir, "asset.bin")+ if err := os.WriteFile(assetPath, []byte("payload"), 0600); err != nil {+ t.Fatalf("write asset: %v", err)+ }++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if !strings.HasSuffix(r.URL.Path, ".sshsig") {+ http.NotFound(w, r)+ return+ }+ w.WriteHeader(http.StatusOK)+ w.Write([]byte("-----BEGIN SSH SIGNATURE-----\nfake\n-----END SSH SIGNATURE-----\n"))+ }))+ defer server.Close()++ prev := verifyReleaseSignatureFunc+ verifyReleaseSignatureFunc = func(ctx context.Context, targetPath, signaturePath string) error {+ if targetPath != assetPath {+ t.Errorf("target path = %q, want %q", targetPath, assetPath)+ }+ if _, err := os.Stat(signaturePath); err != nil {+ t.Errorf("signature file missing: %v", err)+ }+ return nil+ }+ t.Cleanup(func() { verifyReleaseSignatureFunc = prev })++ if err := fetchAndVerifyReleaseSignatureReal(context.Background(), server.URL+"/asset.bin", assetPath); err != nil {+ t.Fatalf("fetchAndVerifyReleaseSignatureReal error: %v", err)+ }+}++func TestFetchAndVerifyReleaseSignatureFailsOnMissingSidecar(t *testing.T) {+ dir := t.TempDir()+ assetPath := filepath.Join(dir, "asset.bin")+ if err := os.WriteFile(assetPath, []byte("payload"), 0600); err != nil {+ t.Fatalf("write asset: %v", err)+ }++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ http.NotFound(w, r)+ }))+ defer server.Close()++ err := fetchAndVerifyReleaseSignatureReal(context.Background(), server.URL+"/asset.bin", assetPath)+ if err == nil || !strings.Contains(err.Error(), "404") {+ t.Fatalf("expected 404 error, got: %v", err)+ }+}++func TestFetchAndVerifyReleaseSignatureFailsOnEmptySignature(t *testing.T) {+ dir := t.TempDir()+ assetPath := filepath.Join(dir, "asset.bin")+ if err := os.WriteFile(assetPath, []byte("payload"), 0600); err != nil {+ t.Fatalf("write asset: %v", err)+ }++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ w.WriteHeader(http.StatusOK)+ }))+ defer server.Close()++ err := fetchAndVerifyReleaseSignatureReal(context.Background(), server.URL+"/asset.bin", assetPath)+ if err == nil || !strings.Contains(err.Error(), "empty") {+ t.Fatalf("expected empty-signature error, got: %v", err)+ }+}++func TestFetchAndVerifyReleaseSignatureFailsWhenVerifierRejects(t *testing.T) {+ dir := t.TempDir()+ assetPath := filepath.Join(dir, "asset.bin")+ if err := os.WriteFile(assetPath, []byte("payload"), 0600); err != nil {+ t.Fatalf("write asset: %v", err)+ }++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ w.WriteHeader(http.StatusOK)+ w.Write([]byte("not a real signature"))+ }))+ defer server.Close()++ prev := verifyReleaseSignatureFunc+ verifyReleaseSignatureFunc = func(ctx context.Context, targetPath, signaturePath string) error {+ return errors.New("signature does not match")+ }+ t.Cleanup(func() { verifyReleaseSignatureFunc = prev })++ err := fetchAndVerifyReleaseSignatureReal(context.Background(), server.URL+"/asset.bin", assetPath)+ if err == nil || !strings.Contains(err.Error(), "signature does not match") {+ t.Fatalf("expected verifier rejection, got: %v", err)+ }+}++func TestFetchAndVerifyReleaseSignatureFailsOnOversizedSignature(t *testing.T) {+ dir := t.TempDir()+ assetPath := filepath.Join(dir, "asset.bin")+ if err := os.WriteFile(assetPath, []byte("payload"), 0600); err != nil {+ t.Fatalf("write asset: %v", err)+ }++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ w.WriteHeader(http.StatusOK)+ oversized := make([]byte, maxReleaseSignatureBytes+128)+ for i := range oversized {+ oversized[i] = 'x'+ }+ w.Write(oversized)+ }))+ defer server.Close()++ err := fetchAndVerifyReleaseSignatureReal(context.Background(), server.URL+"/asset.bin", assetPath)+ if err == nil || !strings.Contains(err.Error(), "exceeds") {+ t.Fatalf("expected oversize error, got: %v", err)+ }+}++func TestManagerDownloadAndVerifyReleaseSignatureAbortsOnFailure(t *testing.T) {+ dir := t.TempDir()+ assetPath := filepath.Join(dir, "asset.bin")+ if err := os.WriteFile(assetPath, []byte("payload"), 0600); err != nil {+ t.Fatalf("write asset: %v", err)+ }++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ w.WriteHeader(http.StatusOK)+ w.Write([]byte("fake-signature-content"))+ }))+ defer server.Close()++ prev := verifyReleaseSignatureFunc+ verifyReleaseSignatureFunc = func(ctx context.Context, targetPath, signaturePath string) error {+ return errors.New("rejected")+ }+ t.Cleanup(func() { verifyReleaseSignatureFunc = prev })++ manager := NewManager(nil)+ parsed, _ := url.Parse(server.URL + "/asset.bin")+ err := manager.downloadAndVerifyReleaseSignature(context.Background(), parsed, assetPath)+ if err == nil || !strings.Contains(err.Error(), "rejected") {+ t.Fatalf("expected verifier rejection, got: %v", err)+ }+}