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.

Require signed installer downloads and local release sidecars

rcourtman4720807ae597
diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml
index 3c41c6e988..48fb65bb39 100644
--- a/.github/workflows/create-release.yml
+++ b/.github/workflows/create-release.yml
@@ -291,6 +291,7 @@ jobs:
VERSION=${{ needs.prepare.outputs.tag }}
secrets: |
pulse_license_public_key=${{ secrets.PULSE_LICENSE_PUBLIC_KEY }}
+ pulse_update_signing_key=${{ secrets.PULSE_UPDATE_SIGNING_KEY }}
- name: Build Pulse agent image (verify only)
uses: docker/build-push-action@v6
@@ -308,6 +309,7 @@ jobs:
VERSION=${{ needs.prepare.outputs.tag }}
secrets: |
pulse_license_public_key=${{ secrets.PULSE_LICENSE_PUBLIC_KEY }}
+ pulse_update_signing_key=${{ secrets.PULSE_UPDATE_SIGNING_KEY }}
helm_smoke:
needs: prepare
@@ -326,10 +328,12 @@ jobs:
env:
DOCKER_BUILDKIT: 1
PULSE_LICENSE_PUBLIC_KEY: ${{ secrets.PULSE_LICENSE_PUBLIC_KEY }}
+ PULSE_UPDATE_SIGNING_KEY: ${{ secrets.PULSE_UPDATE_SIGNING_KEY }}
run: |
docker build \
--target runtime \
--secret id=pulse_license_public_key,env=PULSE_LICENSE_PUBLIC_KEY \
+ --secret id=pulse_update_signing_key,env=PULSE_UPDATE_SIGNING_KEY \
--build-arg VERSION="${{ needs.prepare.outputs.tag }}" \
-t pulse-helm-smoke:${{ needs.prepare.outputs.version }} \
.
@@ -731,6 +735,9 @@ jobs:
if ls release/*.sig 1> /dev/null 2>&1; then
gh release upload "${TAG}" release/*.sig --clobber
fi
+ if ls release/*.sshsig 1> /dev/null 2>&1; then
+ gh release upload "${TAG}" release/*.sshsig --clobber
+ fi
- name: Upload release assets
env:
diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml
index 1b90996bf9..80b910fa7b 100644
--- a/.github/workflows/publish-docker.yml
+++ b/.github/workflows/publish-docker.yml
@@ -142,6 +142,7 @@ jobs:
VERSION=${{ steps.version.outputs.tag }}
secrets: |
pulse_license_public_key=${{ secrets.PULSE_LICENSE_PUBLIC_KEY }}
+ pulse_update_signing_key=${{ secrets.PULSE_UPDATE_SIGNING_KEY }}
tags: |
rcourtman/pulse:${{ steps.version.outputs.tag }}
rcourtman/pulse:${{ steps.version.outputs.version }}
@@ -182,6 +183,7 @@ jobs:
VERSION=${{ steps.version.outputs.tag }}
secrets: |
pulse_license_public_key=${{ secrets.PULSE_LICENSE_PUBLIC_KEY }}
+ pulse_update_signing_key=${{ secrets.PULSE_UPDATE_SIGNING_KEY }}
tags: |
rcourtman/pulse-agent:${{ steps.version.outputs.tag }}
rcourtman/pulse-agent:${{ steps.version.outputs.version }}
diff --git a/Dockerfile b/Dockerfile
index 84fd2d3193..8caa1f6d7f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -32,7 +32,7 @@ ARG VERSION
WORKDIR /app
# Install build dependencies
-RUN apk add --no-cache git
+RUN apk add --no-cache git openssh-client
# Copy go mod files for better layer caching
COPY go.mod go.sum ./
@@ -45,6 +45,10 @@ COPY cmd/ ./cmd/
COPY internal/ ./internal/
COPY pkg/ ./pkg/
COPY scripts/release_ldflags.sh ./scripts/release_ldflags.sh
+COPY scripts/release_update_key.go ./scripts/release_update_key.go
+COPY scripts/render_installers.go ./scripts/render_installers.go
+COPY scripts/install.sh ./scripts/install.sh
+COPY scripts/install.ps1 ./scripts/install.ps1
COPY VERSION ./
# Copy the synced embed artifact from the frontend builder stage.
@@ -54,12 +58,17 @@ COPY --from=frontend-builder /app/internal/api/frontend-modern/dist ./internal/a
RUN --mount=type=cache,id=pulse-go-mod,target=/go/pkg/mod \
--mount=type=cache,id=pulse-go-build,target=/root/.cache/go-build \
--mount=type=secret,id=pulse_license_public_key,required=false \
+ --mount=type=secret,id=pulse_update_signing_key,required=false \
VERSION="${VERSION:-v$(cat VERSION | tr -d '\n')}" && \
BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") && \
GIT_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown") && \
LICENSE_PUBLIC_KEY="" && \
+ UPDATE_SIGNING_KEY="" && \
+ UPDATE_PUBLIC_KEYS="" && \
if [ -f /run/secrets/pulse_license_public_key ]; then LICENSE_PUBLIC_KEY="$(tr -d '\r\n' < /run/secrets/pulse_license_public_key)"; fi && \
- SERVER_LDFLAGS="$(if [ -n "${LICENSE_PUBLIC_KEY}" ]; then ./scripts/release_ldflags.sh server --version "${VERSION}" --build-time "${BUILD_TIME}" --git-commit "${GIT_COMMIT}" --license-public-key "${LICENSE_PUBLIC_KEY}"; else ./scripts/release_ldflags.sh server --version "${VERSION}" --build-time "${BUILD_TIME}" --git-commit "${GIT_COMMIT}"; fi)" && \
+ if [ -f /run/secrets/pulse_update_signing_key ]; then UPDATE_SIGNING_KEY="$(tr -d '\r\n' < /run/secrets/pulse_update_signing_key)"; fi && \
+ if [ -n "${UPDATE_SIGNING_KEY}" ]; then UPDATE_PUBLIC_KEYS="$(go run ./scripts/release_update_key.go public-key --private-key "${UPDATE_SIGNING_KEY}")"; fi && \
+ SERVER_LDFLAGS="$(./scripts/release_ldflags.sh server --version "${VERSION}" --build-time "${BUILD_TIME}" --git-commit "${GIT_COMMIT}" $(if [ -n "${LICENSE_PUBLIC_KEY}" ]; then printf '%s %s' --license-public-key "${LICENSE_PUBLIC_KEY}"; fi) $(if [ -n "${UPDATE_PUBLIC_KEYS}" ]; then printf '%s %s' --update-public-keys "${UPDATE_PUBLIC_KEYS}"; fi))" && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-tags release \
-ldflags="${SERVER_LDFLAGS}" \
@@ -76,8 +85,13 @@ RUN --mount=type=cache,id=pulse-go-mod,target=/go/pkg/mod \
# Build unified agent binaries for all platforms (for download endpoint)
RUN --mount=type=cache,id=pulse-go-mod,target=/go/pkg/mod \
--mount=type=cache,id=pulse-go-build,target=/root/.cache/go-build \
+ --mount=type=secret,id=pulse_update_signing_key,required=false \
VERSION="${VERSION:-v$(cat VERSION | tr -d '\n')}" && \
- AGENT_LDFLAGS="$(./scripts/release_ldflags.sh agent --version "${VERSION}")" && \
+ UPDATE_SIGNING_KEY="" && \
+ UPDATE_PUBLIC_KEYS="" && \
+ if [ -f /run/secrets/pulse_update_signing_key ]; then UPDATE_SIGNING_KEY="$(tr -d '\r\n' < /run/secrets/pulse_update_signing_key)"; fi && \
+ if [ -n "${UPDATE_SIGNING_KEY}" ]; then UPDATE_PUBLIC_KEYS="$(go run ./scripts/release_update_key.go public-key --private-key "${UPDATE_SIGNING_KEY}")"; fi && \
+ AGENT_LDFLAGS="$(./scripts/release_ldflags.sh agent --version "${VERSION}" $(if [ -n "${UPDATE_PUBLIC_KEYS}" ]; then printf '%s %s' --update-public-keys "${UPDATE_PUBLIC_KEYS}"; fi))" && \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags="${AGENT_LDFLAGS}" \
-trimpath \
@@ -127,6 +141,31 @@ RUN --mount=type=cache,id=pulse-go-mod,target=/go/pkg/mod \
-trimpath \
-o pulse-agent-freebsd-arm64 ./cmd/pulse-agent
+RUN --mount=type=cache,id=pulse-go-mod,target=/go/pkg/mod \
+ --mount=type=cache,id=pulse-go-build,target=/root/.cache/go-build \
+ --mount=type=secret,id=pulse_update_signing_key,required=false \
+ mkdir -p /app/rendered-installers && \
+ UPDATE_SIGNING_KEY="" && \
+ INSTALLER_SSH_PUBLIC_KEY="" && \
+ if [ -f /run/secrets/pulse_update_signing_key ]; then UPDATE_SIGNING_KEY="$(tr -d '\r\n' < /run/secrets/pulse_update_signing_key)"; fi && \
+ if [ -n "${UPDATE_SIGNING_KEY}" ]; then INSTALLER_SSH_PUBLIC_KEY="$(go run ./scripts/release_update_key.go public-key-ssh --private-key "${UPDATE_SIGNING_KEY}" --comment pulse-installer)"; fi && \
+ go run ./scripts/render_installers.go --source-dir ./scripts --output-dir /app/rendered-installers --installer-ssh-public-key "${INSTALLER_SSH_PUBLIC_KEY}" && \
+ if [ -n "${UPDATE_SIGNING_KEY}" ]; then \
+ OPENSSH_SIGNING_KEY=/tmp/pulse-update-signing-key && \
+ go run ./scripts/release_update_key.go openssh-private-key --private-key "${UPDATE_SIGNING_KEY}" --comment pulse-installer > "${OPENSSH_SIGNING_KEY}" && \
+ chmod 600 "${OPENSSH_SIGNING_KEY}" && \
+ for file in /app/pulse-agent-* /app/rendered-installers/install.sh /app/rendered-installers/install.ps1; do \
+ ssh-keygen -q -Y sign -f "${OPENSSH_SIGNING_KEY}" -n pulse-install "${file}" >/dev/null && \
+ mv "${file}.sig" "${file}.sshsig" && \
+ go run ./scripts/release_update_key.go sign --private-key "${UPDATE_SIGNING_KEY}" --file "${file}" > "${file}.sig"; \
+ done && \
+ rm -f "${OPENSSH_SIGNING_KEY}"; \
+ else \
+ for file in /app/pulse-agent-* /app/rendered-installers/install.sh /app/rendered-installers/install.ps1; do \
+ : > "${file}.sig" && : > "${file}.sshsig"; \
+ done; \
+ fi
+
# Runtime image for the Docker agent (offered via --target agent_runtime)
FROM alpine:3.20 AS agent_runtime
@@ -189,8 +228,12 @@ RUN chmod +x /docker-entrypoint.sh
RUN mkdir -p /opt/pulse/scripts
COPY scripts/install-container-agent.sh /opt/pulse/scripts/install-container-agent.sh
COPY scripts/install-docker.sh /opt/pulse/scripts/install-docker.sh
-COPY scripts/install.sh /opt/pulse/scripts/install.sh
-COPY scripts/install.ps1 /opt/pulse/scripts/install.ps1
+COPY --from=backend-builder /app/rendered-installers/install.sh /opt/pulse/scripts/install.sh
+COPY --from=backend-builder /app/rendered-installers/install.sh.sig /opt/pulse/scripts/install.sh.sig
+COPY --from=backend-builder /app/rendered-installers/install.sh.sshsig /opt/pulse/scripts/install.sh.sshsig
+COPY --from=backend-builder /app/rendered-installers/install.ps1 /opt/pulse/scripts/install.ps1
+COPY --from=backend-builder /app/rendered-installers/install.ps1.sig /opt/pulse/scripts/install.ps1.sig
+COPY --from=backend-builder /app/rendered-installers/install.ps1.sshsig /opt/pulse/scripts/install.ps1.sshsig
RUN chmod 755 /opt/pulse/scripts/*.sh /opt/pulse/scripts/*.ps1
# Copy all binaries for download endpoint
@@ -206,19 +249,8 @@ RUN if [ "$TARGETARCH" = "arm64" ]; then \
fi
-# Unified agent binaries (all platforms and architectures)
-COPY --from=backend-builder /app/pulse-agent-linux-amd64 /opt/pulse/bin/
-COPY --from=backend-builder /app/pulse-agent-linux-arm64 /opt/pulse/bin/
-COPY --from=backend-builder /app/pulse-agent-linux-armv7 /opt/pulse/bin/
-COPY --from=backend-builder /app/pulse-agent-linux-armv6 /opt/pulse/bin/
-COPY --from=backend-builder /app/pulse-agent-linux-386 /opt/pulse/bin/
-COPY --from=backend-builder /app/pulse-agent-darwin-amd64 /opt/pulse/bin/
-COPY --from=backend-builder /app/pulse-agent-darwin-arm64 /opt/pulse/bin/
-COPY --from=backend-builder /app/pulse-agent-windows-amd64.exe /opt/pulse/bin/
-COPY --from=backend-builder /app/pulse-agent-windows-arm64.exe /opt/pulse/bin/
-COPY --from=backend-builder /app/pulse-agent-windows-386.exe /opt/pulse/bin/
-COPY --from=backend-builder /app/pulse-agent-freebsd-amd64 /opt/pulse/bin/
-COPY --from=backend-builder /app/pulse-agent-freebsd-arm64 /opt/pulse/bin/
+# Unified agent binaries (all platforms and architectures) plus detached signatures
+COPY --from=backend-builder /app/pulse-agent-* /opt/pulse/bin/
# Create symlinks for Windows without .exe extension
RUN ln -s pulse-agent-windows-amd64.exe /opt/pulse/bin/pulse-agent-windows-amd64 && \
ln -s pulse-agent-windows-arm64.exe /opt/pulse/bin/pulse-agent-windows-arm64 && \
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 022f577837..227ac8b861 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -190,7 +190,7 @@ an add-only capacity posture.
catches up, rather than as a fresh enrolment competing for another
monitored-system slot.
4. Keep shared agent-side TLS identity fail-closed across `cmd/pulse-agent/main.go`, `internal/hostagent/`, `internal/agentupdate/`, and adjacent remote-config transport. Self-signed deployments may use a canonical pinned Pulse server certificate fingerprint, but lifecycle transport must route that pin through reporting, enrollment, command websocket, remote-config, and self-update clients instead of widening `PULSE_INSECURE_SKIP_VERIFY` into a blanket MITM carve-out.
-5. Keep release-grade updater trust fail-closed across `internal/agentupdate/`, `internal/dockeragent/`, and the shared `internal/api/unified_agent.go` download helpers. When release builds embed trusted update signing keys, published agent binaries and installer assets must carry detached `.sig` sidecars and the updater/runtime path must require `X-Signature-Ed25519` in addition to `X-Checksum-Sha256` instead of silently downgrading to checksum-only trust.
+5. Keep release-grade updater trust fail-closed across `internal/agentupdate/`, `internal/dockeragent/`, and the shared `internal/api/unified_agent.go` download helpers. When release builds embed trusted update signing keys, published agent binaries and installer assets must carry detached `.sig` plus `.sshsig` sidecars; updater/runtime paths must require `X-Signature-Ed25519` in addition to `X-Checksum-Sha256`, and installer-owned download flows must require the matching base64-encoded `X-Signature-SSHSIG`, instead of silently downgrading to checksum-only trust.
6. Keep shared `internal/api/` helper edits isolated from agent lifecycle semantics: Patrol-specific status transport or alert-trigger wiring changes in shared handlers must not bleed into auto-register, installer, or fleet-control behavior unless this contract moves in the same slice.
The same isolation rule applies to AI settings payload work in `internal/api/ai_handlers.go`: provider auth fields, masked-secret echoes, and provider-test model selection remain AI/runtime plus API-contract ownership and must not be reinterpreted as lifecycle setup or registration semantics just because they share backend helper layers.
The same shared-helper rule now covers SSO outbound discovery and metadata fetches plus credential-file loads in `internal/api/sso_outbound.go`, `internal/api/saml_service.go`, and `internal/api/oidc_service.go`: lifecycle-adjacent setup or auth work may depend on that shared trust boundary, but it must not fork a second HTTP client, redirect policy, or file-read rule inside lifecycle-local flows.
@@ -1596,9 +1596,11 @@ Release-grade updater continuity must also stay fail-closed on signed assets.
When release builds embed trusted update signing keys through
`internal/updatesignature`, `internal/agentupdate/` and
`internal/dockeragent/` must require both `X-Checksum-Sha256` and
-`X-Signature-Ed25519`, and `internal/api/unified_agent.go` must only serve
-published release installers and agent binaries from local or proxied assets
-that carry the matching detached signature sidecar.
+`X-Signature-Ed25519`, while installer-owned download flows must also require
+the matching base64-encoded `X-Signature-SSHSIG`, and
+`internal/api/unified_agent.go` must only serve published release installers
+and agent binaries from local or proxied assets that carry the matching
+detached signature sidecars.
That same unified-agent runtime boundary also owns vendor-aware host identity.
When gopsutil reports generic Linux platform fields on NAS appliances,
`internal/hostagent/` must prefer canonical platform files such as Synology DSM
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 63785f1883..2180ef1883 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -172,7 +172,7 @@ the canonical monitored-system blocked payload.
6. Route dedicated unified-resource timeline and facet-bundle reads through `frontend-modern/src/api/resources.ts`, `internal/api/resources.go`, and `internal/api/contract_test.go` together so the backend facet contract and the frontend client stay aligned on one timeline-first surface, while capability and relationship detail stays backend-owned for AI correlation and change detection
7. Route unified-resource list ordering through `internal/api/resources.go`, `internal/api/contract_test.go`, and the owned unified-resource registry helpers together; list payloads must stay deterministic for equal-name resources by carrying one canonical `name -> type -> id` tie-break across cold seed, REST pagination, and websocket-backed refreshes instead of inheriting map order or page-local re-sorts
That same shared API contract also owns the external resource `type`, canonical display name, and cluster identity published through `/api/resources` and `/api/state`; the websocket/state hydrate path must not emit legacy aliases or raw store labels once the unified resource contract has normalized them.
-8. Route unified-agent installer and binary download headers through `internal/api/unified_agent.go` and `internal/api/contract_test.go` together; published release downloads must keep the canonical `X-Checksum-Sha256` plus `X-Signature-Ed25519` contract whether the asset is served locally or proxied from the matching GitHub release, instead of leaving callers to infer trust from source location alone.
+8. Route unified-agent installer and binary download headers through `internal/api/unified_agent.go` and `internal/api/contract_test.go` together; published release downloads must keep the canonical `X-Checksum-Sha256` plus `X-Signature-Ed25519` contract for updater clients and the base64-encoded `X-Signature-SSHSIG` contract for installer clients whether the asset is served locally or proxied from the matching GitHub release, instead of leaving callers to infer trust from source location alone.
9. Route canonical AI intelligence summary and resource-intelligence reads through `frontend-modern/src/api/ai.ts`, `frontend-modern/src/stores/aiIntelligence.ts`, `frontend-modern/src/stores/aiIntelligenceSummaryModel.ts`, `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`, `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx`, the Patrol-owned section files under `frontend-modern/src/features/patrol/`, `frontend-modern/src/pages/AIIntelligence.tsx`, `internal/api/ai_handlers.go`, and `internal/api/contract_test.go` together so the summary card, store normalization owner, runtime hook, feature shell, section owners, route shell, and backend payload stay aligned on one governed surface, including the canonical recent-changes slice
while keeping the learning counters backend-only coverage, so the summary page keeps Patrol health and findings primary and renders timeline, correlation, and policy-posture data as secondary investigation context rather than as a separate headline product metric
and the Patrol findings empty-state behavior, so `0 active findings` only renders as a healthy frontend conclusion when the same governed AI summary contract still reports healthy overall health; degraded or not-fully-verified health predictions must flow through to the Patrol findings surface instead of being replaced by page-local "looks healthy" copy
@@ -2056,9 +2056,10 @@ matches `serverVersion` and must fail closed for dev or unreleased builds
rather than serving branch-tip installer logic.
That same response contract now also owns signed release-asset headers:
published agent-binary and installer downloads served through
-`internal/api/unified_agent.go` must surface both `X-Checksum-Sha256` and
-`X-Signature-Ed25519`, and release-tagged local assets must not bypass that
-header contract just because the binary or script is present on disk.
+`internal/api/unified_agent.go` must surface `X-Checksum-Sha256`,
+`X-Signature-Ed25519`, and the base64-encoded detached `X-Signature-SSHSIG`,
+and release-tagged local assets must not bypass that header contract just
+because the binary or script is present on disk.
That same transport rule is now explicit about prerelease classes too: only
stable tags and explicit RC prerelease tags without build metadata qualify as
published install-script release assets. Working-line dev prereleases such as
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 81db379543..633ad720f5 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -984,9 +984,12 @@ coverage: update transport changes must continue to carry the direct
API-contract proof path.
That same governed release-promotion boundary now also owns detached agent and
installer signatures. `scripts/build-release.sh`,
-`scripts/release_update_key.go`, `scripts/release_ldflags.sh`, and
-`.github/workflows/create-release.yml` must derive the embedded update trust
-root from the governed release signing key, emit `.sig` sidecars for shipped
-agent binaries and installer assets, and upload those signatures with the
-matching release packet so published RC/stable downloads can keep the updater
-trust chain fail-closed instead of downgrading to checksum-only trust.
+`scripts/release_update_key.go`, `scripts/render_installers.go`,
+`scripts/release_ldflags.sh`, `Dockerfile`, `.github/workflows/create-release.yml`,
+and `.github/workflows/publish-docker.yml` must derive the embedded update
+trust root and installer SSH trust root from the governed release signing key,
+render release installers with that pinned SSH verifier, emit both `.sig` and
+`.sshsig` sidecars for shipped agent binaries and installer assets, and upload
+those signatures with the matching release packet so published RC/stable
+downloads can keep the updater and installer trust chain fail-closed instead
+of downgrading to checksum-only trust.
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 1f762c6c2b..dc159bb3e3 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -74,6 +74,13 @@ querying, and the operator-facing storage health presentation layer.
provider-backed recovery: storage and recovery must treat `truenas_disabled`
as an explicit platform opt-out, not as the baseline onboarding state for a
supported platform.
+ That same adjacent API boundary also owns signed release-asset download
+ continuity when shared helpers serve installer or unified-agent assets:
+ storage- and recovery-adjacent callers may reuse the shared
+ `internal/api/unified_agent.go` path, but they must not fork a second
+ checksum or detached-signature vocabulary away from the canonical
+ `X-Checksum-Sha256`, `X-Signature-Ed25519`, and base64-encoded
+ `X-Signature-SSHSIG` contract.
That same adjacent API boundary also owns pre-auth local recovery
containment. Storage- and recovery-adjacent quick setup or break-glass
routes may exist before auth is configured, but they must stay
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 20b137a39a..ae20b477cb 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -7728,6 +7728,9 @@ func TestContract_DownloadUnifiedAgentReleaseAssetIncludesSignatureHeader(t *tes
if err := os.WriteFile(binPath+".sig", []byte("signed-agent"), 0o644); err != nil {
t.Fatalf("write signature: %v", err)
}
+ if err := os.WriteFile(binPath+".sshsig", []byte("signed-agent-ssh"), 0o644); err != nil {
+ t.Fatalf("write ssh signature: %v", err)
+ }
req := httptest.NewRequest(http.MethodGet, "/api/install/agent?arch=linux-amd64", nil)
w := httptest.NewRecorder()
@@ -7736,6 +7739,9 @@ func TestContract_DownloadUnifiedAgentReleaseAssetIncludesSignatureHeader(t *tes
if got := w.Header().Get(signatureHeaderName); got != "signed-agent" {
t.Fatalf("agent download signature header = %q, want %q", got, "signed-agent")
}
+ if got := w.Header().Get(sshSignatureHeaderName); got != encodedTestSSHSignature("signed-agent-ssh") {
+ t.Fatalf("agent download SSH signature header = %q, want %q", got, encodedTestSSHSignature("signed-agent-ssh"))
+ }
}
func TestContract_DownloadInstallScriptReleaseAssetIncludesSignatureHeader(t *testing.T) {
@@ -7749,6 +7755,9 @@ func TestContract_DownloadInstallScriptReleaseAssetIncludesSignatureHeader(t *te
if err := os.WriteFile(scriptPath+".sig", []byte("signed-install-script"), 0o644); err != nil {
t.Fatalf("write install signature: %v", err)
}
+ if err := os.WriteFile(scriptPath+".sshsig", []byte("signed-install-script-ssh"), 0o644); err != nil {
+ t.Fatalf("write install SSH signature: %v", err)
+ }
req := httptest.NewRequest(http.MethodGet, "/install.sh", nil)
w := httptest.NewRecorder()
@@ -7757,6 +7766,9 @@ func TestContract_DownloadInstallScriptReleaseAssetIncludesSignatureHeader(t *te
if got := w.Header().Get(signatureHeaderName); got != "signed-install-script" {
t.Fatalf("install script signature header = %q, want %q", got, "signed-install-script")
}
+ if got := w.Header().Get(sshSignatureHeaderName); got != encodedTestSSHSignature("signed-install-script-ssh") {
+ t.Fatalf("install script SSH signature header = %q, want %q", got, encodedTestSSHSignature("signed-install-script-ssh"))
+ }
}
func TestContract_SystemSettingsResponseJSONSnapshot(t *testing.T) {
diff --git a/internal/api/unified_agent.go b/internal/api/unified_agent.go
index f50bf9eefd..64065e1810 100644
--- a/internal/api/unified_agent.go
+++ b/internal/api/unified_agent.go
@@ -7,8 +7,10 @@ import (
"compress/gzip"
"context"
"crypto/sha256"
+ "encoding/base64"
"encoding/hex"
"encoding/json"
+ "errors"
"fmt"
"io"
"net/http"
@@ -27,6 +29,7 @@ const (
defaultInstallScriptReleaseRepo = "rcourtman/Pulse"
checksumHeaderName = "X-Checksum-Sha256"
signatureHeaderName = "X-Signature-Ed25519"
+ sshSignatureHeaderName = "X-Signature-SSHSIG"
)
func installScriptReleaseRepo() string {
@@ -80,8 +83,9 @@ func handleDownloadInstallScriptCommon(w http.ResponseWriter, req *http.Request,
}
signature, sigErr := readReleaseAssetSignature(scriptPath)
- if sigErr != nil && isPublishedReleaseAssetVersion(serverVersion) {
- log.Warn().Err(sigErr).Str("path", scriptPath).Msg("Signed install script unavailable locally, proxying from GitHub releases")
+ sshSignature, sshSigErr := readReleaseAssetSSHSignature(scriptPath)
+ if (sigErr != nil || sshSigErr != nil) && isPublishedReleaseAssetVersion(serverVersion) {
+ log.Warn().Err(errors.Join(sigErr, sshSigErr)).Str("path", scriptPath).Msg("Signed install script unavailable locally, proxying from GitHub releases")
fallbackProxy(w, req, scriptName)
return
}
@@ -91,6 +95,9 @@ func handleDownloadInstallScriptCommon(w http.ResponseWriter, req *http.Request,
if signature != "" {
w.Header().Set(signatureHeaderName, signature)
}
+ if sshSignature != "" {
+ w.Header().Set(sshSignatureHeaderName, sshSignature)
+ }
http.ServeFile(w, req, scriptPath)
}
@@ -201,9 +208,10 @@ func (r *Router) handleDownloadUnifiedAgent(w http.ResponseWriter, req *http.Req
defer file.Close()
signature, sigErr := readReleaseAssetSignature(candidate)
- if sigErr != nil && isPublishedReleaseAssetVersion(r.serverVersion) {
- log.Warn().Err(sigErr).Str("path", candidate).Msg("Skipping unsigned local unified agent binary")
- invalidCandidates = append(invalidCandidates, fmt.Sprintf("%s (%v)", candidate, sigErr))
+ sshSignature, sshSigErr := readReleaseAssetSSHSignature(candidate)
+ if (sigErr != nil || sshSigErr != nil) && isPublishedReleaseAssetVersion(r.serverVersion) {
+ log.Warn().Err(errors.Join(sigErr, sshSigErr)).Str("path", candidate).Msg("Skipping unsigned local unified agent binary")
+ invalidCandidates = append(invalidCandidates, fmt.Sprintf("%s (%v)", candidate, errors.Join(sigErr, sshSigErr)))
continue
}
@@ -211,6 +219,9 @@ func (r *Router) handleDownloadUnifiedAgent(w http.ResponseWriter, req *http.Req
if signature != "" {
w.Header().Set(signatureHeaderName, signature)
}
+ if sshSignature != "" {
+ w.Header().Set(sshSignatureHeaderName, sshSignature)
+ }
http.ServeContent(w, req, filepath.Base(candidate), info.ModTime(), file)
return
}
@@ -276,6 +287,7 @@ func (r *Router) proxyAgentBinaryFromGitHub(w http.ResponseWriter, req *http.Req
}
githubURL := githubReleaseDownloadURL(binaryName)
signatureURL := githubReleaseDownloadURL(binaryName + ".sig")
+ sshSignatureURL := githubReleaseDownloadURL(binaryName + ".sshsig")
log.Info().Str("arch", normalized).Str("url", githubURL).Msg("Local agent binary not found, proxying from GitHub releases")
@@ -307,7 +319,13 @@ func (r *Router) proxyAgentBinaryFromGitHub(w http.ResponseWriter, req *http.Req
http.Error(w, "Failed to fetch agent binary signature", http.StatusServiceUnavailable)
return
}
- serveProxiedAgentBinaryWithSignature(w, content, checksum, strings.TrimSpace(string(signature)), "github-proxy")
+ sshSignature, sshSigErr := fetchReleaseAssetContent(req.Context(), client, sshSignatureURL, 64*1024)
+ if sshSigErr != nil {
+ log.Error().Err(sshSigErr).Str("url", sshSignatureURL).Msg("Failed to fetch agent binary SSH signature from GitHub")
+ http.Error(w, "Failed to fetch agent binary SSH signature", http.StatusServiceUnavailable)
+ return
+ }
+ serveProxiedAgentBinaryWithSignatures(w, content, checksum, strings.TrimSpace(string(signature)), encodeSSHSignatureForHeader(sshSignature), "github-proxy")
return
}
@@ -329,7 +347,13 @@ func (r *Router) proxyAgentBinaryFromGitHub(w http.ResponseWriter, req *http.Req
http.Error(w, "Failed to fetch agent binary signature", http.StatusServiceUnavailable)
return
}
- serveProxiedAgentBinaryWithSignature(w, archiveContent, checksum, strings.TrimSpace(string(signature)), "github-proxy-archive")
+ sshSignature, sshSigErr := fetchReleaseAssetContent(req.Context(), client, sshSignatureURL, 64*1024)
+ if sshSigErr != nil {
+ log.Error().Err(sshSigErr).Str("url", sshSignatureURL).Msg("Failed to fetch agent binary SSH signature from GitHub")
+ http.Error(w, "Failed to fetch agent binary SSH signature", http.StatusServiceUnavailable)
+ return
+ }
+ serveProxiedAgentBinaryWithSignatures(w, archiveContent, checksum, strings.TrimSpace(string(signature)), encodeSSHSignatureForHeader(sshSignature), "github-proxy-archive")
}
const maxAgentBinarySize = 100 * 1024 * 1024
@@ -348,14 +372,17 @@ func readBinaryWithChecksum(body io.Reader) ([]byte, string, error) {
}
func serveProxiedAgentBinary(w http.ResponseWriter, content []byte, checksum, servedFrom string) {
- serveProxiedAgentBinaryWithSignature(w, content, checksum, "", servedFrom)
+ serveProxiedAgentBinaryWithSignatures(w, content, checksum, "", "", servedFrom)
}
-func serveProxiedAgentBinaryWithSignature(w http.ResponseWriter, content []byte, checksum, signature, servedFrom string) {
+func serveProxiedAgentBinaryWithSignatures(w http.ResponseWriter, content []byte, checksum, signature, sshSignature, servedFrom string) {
w.Header().Set(checksumHeaderName, checksum)
if strings.TrimSpace(signature) != "" {
w.Header().Set(signatureHeaderName, strings.TrimSpace(signature))
}
+ if strings.TrimSpace(sshSignature) != "" {
+ w.Header().Set(sshSignatureHeaderName, strings.TrimSpace(sshSignature))
+ }
w.Header().Set("X-Served-From", servedFrom)
w.Header().Set("Content-Type", "application/octet-stream")
w.Write(content)
@@ -466,6 +493,22 @@ func readReleaseAssetSignature(path string) (string, error) {
return signature, nil
}
+func readReleaseAssetSSHSignature(path string) (string, error) {
+ signaturePath := path + ".sshsig"
+ data, err := os.ReadFile(signaturePath)
+ if err != nil {
+ return "", fmt.Errorf("read release ssh signature %s: %w", signaturePath, err)
+ }
+ if len(bytes.TrimSpace(data)) == 0 {
+ return "", fmt.Errorf("release ssh signature %s is empty", signaturePath)
+ }
+ return encodeSSHSignatureForHeader(data), nil
+}
+
+func encodeSSHSignatureForHeader(data []byte) string {
+ return base64.StdEncoding.EncodeToString(data)
+}
+
func fetchReleaseAssetContent(ctx context.Context, client *http.Client, url string, limit int64) ([]byte, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
if err != nil {
@@ -616,6 +659,12 @@ func (r *Router) proxyInstallScriptFromGitHub(w http.ResponseWriter, req *http.R
http.Error(w, "Failed to fetch install script signature", http.StatusServiceUnavailable)
return
}
+ sshSignatureContent, sshSigErr := fetchReleaseAssetContent(req.Context(), client, githubURL+".sshsig", 64*1024)
+ if sshSigErr != nil {
+ log.Error().Err(sshSigErr).Str("url", githubURL+".sshsig").Msg("Failed to fetch install script SSH signature from GitHub")
+ http.Error(w, "Failed to fetch install script SSH signature", http.StatusServiceUnavailable)
+ return
+ }
// Read the script content
content, err := io.ReadAll(resp.Body)
@@ -635,6 +684,7 @@ func (r *Router) proxyInstallScriptFromGitHub(w http.ResponseWriter, req *http.R
w.Header().Set("Content-Disposition", "inline; filename=\""+scriptName+"\"")
w.Header().Set("X-Served-From", "github-fallback")
w.Header().Set(signatureHeaderName, strings.TrimSpace(string(signatureContent)))
+ w.Header().Set(sshSignatureHeaderName, encodeSSHSignatureForHeader(sshSignatureContent))
if req.Method == http.MethodHead {
w.WriteHeader(http.StatusOK)
return
diff --git a/internal/api/unified_agent_more_test.go b/internal/api/unified_agent_more_test.go
index 5873acc3dc..1856b44e78 100644
--- a/internal/api/unified_agent_more_test.go
+++ b/internal/api/unified_agent_more_test.go
@@ -112,6 +112,7 @@ func TestDownloadUnifiedInstallScript_ProxyFallback(t *testing.T) {
router.installScriptClient = newTestInstallScriptClientSequence(t, []expectedHTTPExchange{
{Method: http.MethodGet, URL: expectedURL, Status: http.StatusOK, Body: payload},
{Method: http.MethodGet, URL: expectedURL + ".sig", Status: http.StatusOK, Body: "signed-install-script"},
+ {Method: http.MethodGet, URL: expectedURL + ".sshsig", Status: http.StatusOK, Body: "signed-install-script-ssh"},
})
req := httptest.NewRequest(http.MethodGet, "/install.sh", nil)
@@ -131,6 +132,9 @@ func TestDownloadUnifiedInstallScript_ProxyFallback(t *testing.T) {
if got := w.Header().Get(signatureHeaderName); got != "signed-install-script" {
t.Fatalf("unexpected signature header: %q", got)
}
+ if got := w.Header().Get(sshSignatureHeaderName); got != encodedTestSSHSignature("signed-install-script-ssh") {
+ t.Fatalf("unexpected SSH signature header: %q", got)
+ }
if !strings.Contains(w.Header().Get("Content-Disposition"), "install.sh") {
t.Fatalf("missing Content-Disposition filename")
}
@@ -149,6 +153,7 @@ func TestDownloadUnifiedInstallScript_ProxyFallbackUsesConfiguredRepo(t *testing
router.installScriptClient = newTestInstallScriptClientSequence(t, []expectedHTTPExchange{
{Method: http.MethodGet, URL: expectedURL, Status: http.StatusOK, Body: payload},
{Method: http.MethodGet, URL: expectedURL + ".sig", Status: http.StatusOK, Body: "signed-install-script"},
+ {Method: http.MethodGet, URL: expectedURL + ".sshsig", Status: http.StatusOK, Body: "signed-install-script-ssh"},
})
req := httptest.NewRequest(http.MethodGet, "/install.sh", nil)
@@ -169,6 +174,7 @@ func TestDownloadUnifiedInstallScriptPS_ProxyFallback(t *testing.T) {
router.installScriptClient = newTestInstallScriptClientSequence(t, []expectedHTTPExchange{
{Method: http.MethodGet, URL: expectedURL, Status: http.StatusOK, Body: payload},
{Method: http.MethodGet, URL: expectedURL + ".sig", Status: http.StatusOK, Body: "signed-install-script"},
+ {Method: http.MethodGet, URL: expectedURL + ".sshsig", Status: http.StatusOK, Body: "signed-install-script-ssh"},
})
req := httptest.NewRequest(http.MethodGet, "/install.ps1", nil)
@@ -266,6 +272,7 @@ func TestDownloadUnifiedInstallScript_ProxyFallbackPreservesHEAD(t *testing.T) {
router.installScriptClient = newTestInstallScriptClientSequence(t, []expectedHTTPExchange{
{Method: http.MethodHead, URL: expectedURL, Status: http.StatusOK, Body: ""},
{Method: http.MethodGet, URL: expectedURL + ".sig", Status: http.StatusOK, Body: "signed-install-script"},
+ {Method: http.MethodGet, URL: expectedURL + ".sshsig", Status: http.StatusOK, Body: "signed-install-script-ssh"},
})
req := httptest.NewRequest(http.MethodHead, "/install.sh", nil)
@@ -282,6 +289,9 @@ func TestDownloadUnifiedInstallScript_ProxyFallbackPreservesHEAD(t *testing.T) {
if got := w.Header().Get(signatureHeaderName); got != "signed-install-script" {
t.Fatalf("unexpected signature header: %q", got)
}
+ if got := w.Header().Get(sshSignatureHeaderName); got != encodedTestSSHSignature("signed-install-script-ssh") {
+ t.Fatalf("unexpected SSH signature header: %q", got)
+ }
}
func TestDownloadUnifiedAgent_MethodNotAllowed(t *testing.T) {
diff --git a/internal/api/unified_agent_test.go b/internal/api/unified_agent_test.go
index e4aee42b4f..b69dacaaa4 100644
--- a/internal/api/unified_agent_test.go
+++ b/internal/api/unified_agent_test.go
@@ -44,6 +44,10 @@ func staleTestUnifiedAgentBinary(suffix string) []byte {
return []byte("ELF stale binary " + legacyUnifiedAgentReportPath + " " + suffix)
}
+func encodedTestSSHSignature(payload string) string {
+ return encodeSSHSignatureForHeader([]byte(payload))
+}
+
func TestDownloadInstallScript_Local(t *testing.T) {
router, tempDir := setupUnifiedAgentRouter(t)
@@ -147,6 +151,8 @@ func TestDownloadUnifiedAgent_LocalReleaseBinaryIncludesSignatureHeader(t *testi
require.NoError(t, err)
err = os.WriteFile(binPath+".sig", []byte("signed-local-agent"), 0644)
require.NoError(t, err)
+ err = os.WriteFile(binPath+".sshsig", []byte("signed-local-agent-ssh"), 0644)
+ require.NoError(t, err)
req := httptest.NewRequest(http.MethodGet, "/api/install/agent?arch=linux-amd64", nil)
w := httptest.NewRecorder()
@@ -155,6 +161,7 @@ func TestDownloadUnifiedAgent_LocalReleaseBinaryIncludesSignatureHeader(t *testi
require.Equal(t, http.StatusOK, w.Code)
assert.Equal(t, "signed-local-agent", w.Header().Get(signatureHeaderName))
+ assert.Equal(t, encodedTestSSHSignature("signed-local-agent-ssh"), w.Header().Get(sshSignatureHeaderName))
}
func TestDownloadUnifiedAgent_SkipsStaleLocalBinaryAndProxies(t *testing.T) {
@@ -168,6 +175,7 @@ func TestDownloadUnifiedAgent_SkipsStaleLocalBinaryAndProxies(t *testing.T) {
router.installScriptClient = newTestInstallScriptClientSequence(t, []expectedHTTPExchange{
{Method: http.MethodGet, URL: expectedURL, Status: http.StatusOK, Body: binaryContent},
{Method: http.MethodGet, URL: expectedURL + ".sig", Status: http.StatusOK, Body: "signed-agent"},
+ {Method: http.MethodGet, URL: expectedURL + ".sshsig", Status: http.StatusOK, Body: "signed-agent-ssh"},
})
req := httptest.NewRequest(http.MethodGet, "/api/install/agent?arch=linux-amd64", nil)
@@ -179,6 +187,7 @@ func TestDownloadUnifiedAgent_SkipsStaleLocalBinaryAndProxies(t *testing.T) {
assert.Equal(t, binaryContent, w.Body.String())
assert.Equal(t, "github-proxy", w.Header().Get("X-Served-From"))
assert.Equal(t, "signed-agent", w.Header().Get(signatureHeaderName))
+ assert.Equal(t, encodedTestSSHSignature("signed-agent-ssh"), w.Header().Get(sshSignatureHeaderName))
}
func TestDownloadUnifiedAgent_DevModeRejectsStaleLocalBinary(t *testing.T) {
@@ -209,6 +218,7 @@ func TestDownloadUnifiedAgent_ProxyFromGitHub(t *testing.T) {
router.installScriptClient = newTestInstallScriptClientSequence(t, []expectedHTTPExchange{
{Method: http.MethodGet, URL: expectedURL, Status: http.StatusOK, Body: binaryContent},
{Method: http.MethodGet, URL: expectedURL + ".sig", Status: http.StatusOK, Body: "signed-agent"},
+ {Method: http.MethodGet, URL: expectedURL + ".sshsig", Status: http.StatusOK, Body: "signed-agent-ssh"},
})
req := httptest.NewRequest(http.MethodGet, "/api/install/agent?arch=linux-amd64", nil)
@@ -226,6 +236,7 @@ func TestDownloadUnifiedAgent_ProxyFromGitHub(t *testing.T) {
expectedChecksum := hex.EncodeToString(hash[:])
assert.Equal(t, expectedChecksum, w.Header().Get("X-Checksum-Sha256"))
assert.Equal(t, "signed-agent", w.Header().Get(signatureHeaderName))
+ assert.Equal(t, encodedTestSSHSignature("signed-agent-ssh"), w.Header().Get(sshSignatureHeaderName))
}
func TestDownloadUnifiedAgent_ProxyFromGitHub_UsesConfiguredRepo(t *testing.T) {
@@ -238,6 +249,7 @@ func TestDownloadUnifiedAgent_ProxyFromGitHub_UsesConfiguredRepo(t *testing.T) {
router.installScriptClient = newTestInstallScriptClientSequence(t, []expectedHTTPExchange{
{Method: http.MethodGet, URL: expectedURL, Status: http.StatusOK, Body: binaryContent},
{Method: http.MethodGet, URL: expectedURL + ".sig", Status: http.StatusOK, Body: "signed-agent"},
+ {Method: http.MethodGet, URL: expectedURL + ".sshsig", Status: http.StatusOK, Body: "signed-agent-ssh"},
})
req := httptest.NewRequest(http.MethodGet, "/api/install/agent?arch=linux-amd64", nil)
@@ -257,6 +269,7 @@ func TestDownloadUnifiedAgent_ProxyFromGitHub_Windows(t *testing.T) {
router.installScriptClient = newTestInstallScriptClientSequence(t, []expectedHTTPExchange{
{Method: http.MethodGet, URL: expectedURL, Status: http.StatusOK, Body: binaryContent},
{Method: http.MethodGet, URL: expectedURL + ".sig", Status: http.StatusOK, Body: "signed-agent"},
+ {Method: http.MethodGet, URL: expectedURL + ".sshsig", Status: http.StatusOK, Body: "signed-agent-ssh"},
})
req := httptest.NewRequest(http.MethodGet, "/api/install/agent?arch=windows-amd64", nil)
@@ -268,6 +281,7 @@ func TestDownloadUnifiedAgent_ProxyFromGitHub_Windows(t *testing.T) {
assert.Equal(t, binaryContent, w.Body.String())
assert.NotEmpty(t, w.Header().Get("X-Checksum-Sha256"))
assert.Equal(t, "signed-agent", w.Header().Get(signatureHeaderName))
+ assert.Equal(t, encodedTestSSHSignature("signed-agent-ssh"), w.Header().Get(sshSignatureHeaderName))
}
func TestDownloadUnifiedAgent_ProxyFromGitHub_ArchiveFallback_Darwin(t *testing.T) {
@@ -277,6 +291,7 @@ func TestDownloadUnifiedAgent_ProxyFromGitHub_ArchiveFallback_Darwin(t *testing.
archivePayload := buildTestTarGz(t, "pulse-agent-darwin-arm64", binaryContent)
binaryURL := "https://github.com/rcourtman/Pulse/releases/latest/download/pulse-agent-darwin-arm64"
signatureURL := binaryURL + ".sig"
+ sshSignatureURL := binaryURL + ".sshsig"
latestURL := "https://api.github.com/repos/rcourtman/Pulse/releases/latest"
archiveURL := "https://github.com/rcourtman/Pulse/releases/download/v9.9.9/pulse-agent-v9.9.9-darwin-arm64.tar.gz"
@@ -311,6 +326,13 @@ func TestDownloadUnifiedAgent_ProxyFromGitHub_ArchiveFallback_Darwin(t *testing.
Header: make(http.Header),
Body: io.NopCloser(strings.NewReader("signed-agent")),
}, nil
+ case sshSignatureURL:
+ return &http.Response{
+ StatusCode: http.StatusOK,
+ Status: "200 OK",
+ Header: make(http.Header),
+ Body: io.NopCloser(strings.NewReader("signed-agent-ssh")),
+ }, nil
default:
t.Fatalf("unexpected URL: %s", req.URL.String())
return nil, nil
@@ -331,6 +353,7 @@ func TestDownloadUnifiedAgent_ProxyFromGitHub_ArchiveFallback_Darwin(t *testing.
expectedChecksum := hex.EncodeToString(hash[:])
assert.Equal(t, expectedChecksum, w.Header().Get("X-Checksum-Sha256"))
assert.Equal(t, "signed-agent", w.Header().Get(signatureHeaderName))
+ assert.Equal(t, encodedTestSSHSignature("signed-agent-ssh"), w.Header().Get(sshSignatureHeaderName))
}
func TestDownloadUnifiedAgent_ProxyFromGitHub_ArchiveFallback_UsesConfiguredRepo(t *testing.T) {
@@ -342,6 +365,7 @@ func TestDownloadUnifiedAgent_ProxyFromGitHub_ArchiveFallback_UsesConfiguredRepo
archivePayload := buildTestTarGz(t, "pulse-agent-darwin-arm64", binaryContent)
binaryURL := "https://github.com/example/pulse-fork/releases/latest/download/pulse-agent-darwin-arm64"
signatureURL := binaryURL + ".sig"
+ sshSignatureURL := binaryURL + ".sshsig"
latestURL := "https://api.github.com/repos/example/pulse-fork/releases/latest"
archiveURL := "https://github.com/example/pulse-fork/releases/download/v9.9.9/pulse-agent-v9.9.9-darwin-arm64.tar.gz"
@@ -376,6 +400,13 @@ func TestDownloadUnifiedAgent_ProxyFromGitHub_ArchiveFallback_UsesConfiguredRepo
Header: make(http.Header),
Body: io.NopCloser(strings.NewReader("signed-agent")),
}, nil
+ case sshSignatureURL:
+ return &http.Response{
+ StatusCode: http.StatusOK,
+ Status: "200 OK",
+ Header: make(http.Header),
+ Body: io.NopCloser(strings.NewReader("signed-agent-ssh")),
+ }, nil
default:
t.Fatalf("unexpected URL: %s", req.URL.String())
return nil, nil
@@ -392,6 +423,7 @@ func TestDownloadUnifiedAgent_ProxyFromGitHub_ArchiveFallback_UsesConfiguredRepo
assert.Equal(t, "github-proxy-archive", w.Header().Get("X-Served-From"))
assert.Equal(t, string(binaryContent), w.Body.String())
assert.Equal(t, "signed-agent", w.Header().Get(signatureHeaderName))
+ assert.Equal(t, encodedTestSSHSignature("signed-agent-ssh"), w.Header().Get(sshSignatureHeaderName))
}
func TestDownloadUnifiedAgent_ProxyFromGitHub_NotFound(t *testing.T) {
diff --git a/internal/updatesignature/signature.go b/internal/updatesignature/signature.go
index 47f4f697be..323fe2c13e 100644
--- a/internal/updatesignature/signature.go
+++ b/internal/updatesignature/signature.go
@@ -9,6 +9,8 @@ import (
"fmt"
"os"
"strings"
+
+ "golang.org/x/crypto/ssh"
)
// EmbeddedTrustedPublicKeys is injected into release builds via ldflags.
@@ -55,6 +57,36 @@ func PublicKeyString(privateKey ed25519.PrivateKey) (string, error) {
return base64.StdEncoding.EncodeToString(publicKey), nil
}
+// AuthorizedPublicKeyString returns the OpenSSH authorized_keys line for the
+// Ed25519 public key derived from the signing key.
+func AuthorizedPublicKeyString(privateKey ed25519.PrivateKey, comment string) (string, error) {
+ if len(privateKey) != ed25519.PrivateKeySize {
+ return "", errors.New("invalid signing key")
+ }
+ publicKey, err := ssh.NewPublicKey(privateKey.Public())
+ if err != nil {
+ return "", fmt.Errorf("derive ssh public key: %w", err)
+ }
+ authorizedKey := strings.TrimSpace(string(ssh.MarshalAuthorizedKey(publicKey)))
+ if strings.TrimSpace(comment) == "" {
+ return authorizedKey, nil
+ }
+ return authorizedKey + " " + strings.TrimSpace(comment), nil
+}
+
+// OpenSSHPrivateKeyPEM returns the signing key encoded in the OpenSSH private
+// key PEM format so release tooling can use ssh-keygen -Y sign.
+func OpenSSHPrivateKeyPEM(privateKey ed25519.PrivateKey, comment string) (string, error) {
+ if len(privateKey) != ed25519.PrivateKeySize {
+ return "", errors.New("invalid signing key")
+ }
+ block, err := ssh.MarshalPrivateKey(privateKey, strings.TrimSpace(comment))
+ if err != nil {
+ return "", fmt.Errorf("marshal openssh private key: %w", err)
+ }
+ return string(pem.EncodeToMemory(block)), nil
+}
+
// SignBytes signs a blob and returns a base64-encoded Ed25519 signature.
func SignBytes(data []byte, privateKey ed25519.PrivateKey) (string, error) {
if len(privateKey) != ed25519.PrivateKeySize {
diff --git a/internal/updatesignature/signature_test.go b/internal/updatesignature/signature_test.go
index 46ac9228d9..bbac89d3f4 100644
--- a/internal/updatesignature/signature_test.go
+++ b/internal/updatesignature/signature_test.go
@@ -9,6 +9,7 @@ import (
"encoding/pem"
"os"
"path/filepath"
+ "strings"
"testing"
)
@@ -83,6 +84,39 @@ func TestPublicKeyString(t *testing.T) {
}
}
+func TestAuthorizedPublicKeyString(t *testing.T) {
+ _, privateKey, err := ed25519.GenerateKey(rand.Reader)
+ if err != nil {
+ t.Fatalf("generate key: %v", err)
+ }
+
+ authorizedKey, err := AuthorizedPublicKeyString(privateKey, "pulse-installer")
+ if err != nil {
+ t.Fatalf("authorized public key string: %v", err)
+ }
+ if !strings.HasPrefix(authorizedKey, "ssh-ed25519 ") {
+ t.Fatalf("authorized public key missing ssh-ed25519 prefix: %q", authorizedKey)
+ }
+ if !strings.HasSuffix(authorizedKey, " pulse-installer") {
+ t.Fatalf("authorized public key missing comment: %q", authorizedKey)
+ }
+}
+
+func TestOpenSSHPrivateKeyPEM(t *testing.T) {
+ _, privateKey, err := ed25519.GenerateKey(rand.Reader)
+ if err != nil {
+ t.Fatalf("generate key: %v", err)
+ }
+
+ pemData, err := OpenSSHPrivateKeyPEM(privateKey, "pulse-installer")
+ if err != nil {
+ t.Fatalf("openssh private key pem: %v", err)
+ }
+ if !strings.Contains(pemData, "BEGIN OPENSSH PRIVATE KEY") {
+ t.Fatalf("openssh private key pem missing header: %q", pemData)
+ }
+}
+
func TestTrustedPublicKeysRejectsInvalidInput(t *testing.T) {
original := EmbeddedTrustedPublicKeys
t.Cleanup(func() { EmbeddedTrustedPublicKeys = original })
diff --git a/scripts/build-release.sh b/scripts/build-release.sh
index 988e44491d..4a71e15b11 100755
--- a/scripts/build-release.sh
+++ b/scripts/build-release.sh
@@ -29,6 +29,9 @@ export CGO_ENABLED=0
VERSION=${1:-$(cat VERSION)}
BUILD_DIR="build"
RELEASE_DIR="release"
+RENDERED_INSTALLERS_DIR="${BUILD_DIR}/rendered-installers"
+INSTALLER_SSH_SIGNER_IDENTITY="pulse-installer"
+INSTALLER_SSH_SIGNER_NAMESPACE="pulse-install"
echo "Building Pulse v${VERSION}..."
@@ -72,6 +75,8 @@ fi
# Require update signing for release-grade agent and installer verification.
# Explicitly opt out with PULSE_ALLOW_MISSING_UPDATE_SIGNING_KEY=true for local-only debugging.
update_ldflags_args=()
+update_ssh_public_key=""
+update_ssh_private_key_file=""
if [[ -z "${PULSE_UPDATE_SIGNING_KEY:-}" ]]; then
if [[ "${PULSE_ALLOW_MISSING_UPDATE_SIGNING_KEY:-false}" == "true" ]]; then
echo "Warning: PULSE_UPDATE_SIGNING_KEY not set; continuing because PULSE_ALLOW_MISSING_UPDATE_SIGNING_KEY=true."
@@ -86,14 +91,42 @@ else
echo "Error: failed to derive update signing public key." >&2
exit 1
fi
+ if ! command -v ssh-keygen >/dev/null 2>&1; then
+ echo "Error: ssh-keygen is required to sign installer release assets." >&2
+ exit 1
+ fi
+ update_ssh_public_key=$(go run ./scripts/release_update_key.go public-key-ssh --private-key "${PULSE_UPDATE_SIGNING_KEY}" --comment "${INSTALLER_SSH_SIGNER_IDENTITY}")
+ if [[ -z "${update_ssh_public_key}" ]]; then
+ echo "Error: failed to derive installer SSH signing public key." >&2
+ exit 1
+ fi
+ update_ssh_private_key_file=$(mktemp)
+ trap 'rm -f "${update_ssh_private_key_file}"' EXIT
+ go run ./scripts/release_update_key.go openssh-private-key --private-key "${PULSE_UPDATE_SIGNING_KEY}" --comment "${INSTALLER_SSH_SIGNER_IDENTITY}" > "${update_ssh_private_key_file}"
+ chmod 600 "${update_ssh_private_key_file}"
update_ldflags_args=(--update-public-keys "${update_public_key}")
fi
+render_release_installers() {
+ local output_dir="$1"
+ mkdir -p "${output_dir}"
+ go run ./scripts/render_installers.go \
+ --source-dir ./scripts \
+ --output-dir "${output_dir}" \
+ --installer-ssh-public-key "${update_ssh_public_key}"
+}
+
sign_release_file() {
local file="$1"
if [[ -z "${PULSE_UPDATE_SIGNING_KEY:-}" ]]; then
return 0
fi
+ rm -f "${file}.sig" "${file}.sshsig"
+ ssh-keygen -q -Y sign \
+ -f "${update_ssh_private_key_file}" \
+ -n "${INSTALLER_SSH_SIGNER_NAMESPACE}" \
+ "${file}" >/dev/null
+ mv "${file}.sig" "${file}.sshsig"
go run ./scripts/release_update_key.go sign --private-key "${PULSE_UPDATE_SIGNING_KEY}" --file "${file}" > "${file}.sig"
}
@@ -104,12 +137,13 @@ sign_directory_release_assets() {
fi
while IFS= read -r -d '' file; do
sign_release_file "${file}"
- done < <(find "${dir}" -maxdepth 1 -type f -print0)
+ done < <(find "${dir}" -maxdepth 1 -type f ! -name '*.sig' ! -name '*.sshsig' -print0)
}
# Clean previous builds
rm -rf $BUILD_DIR $RELEASE_DIR
mkdir -p $BUILD_DIR $RELEASE_DIR
+render_release_installers "${RENDERED_INSTALLERS_DIR}"
# Build frontend
echo "Building frontend..."
@@ -222,8 +256,8 @@ for build_name in "${build_order[@]}"; do
# Copy scripts and VERSION metadata
cp "scripts/install-container-agent.sh" "$staging_dir/scripts/install-container-agent.sh"
cp "scripts/install-docker.sh" "$staging_dir/scripts/install-docker.sh"
- cp "scripts/install.sh" "$staging_dir/scripts/install.sh"
- [ -f "scripts/install.ps1" ] && cp "scripts/install.ps1" "$staging_dir/scripts/install.ps1"
+ cp "${RENDERED_INSTALLERS_DIR}/install.sh" "$staging_dir/scripts/install.sh"
+ [ -f "${RENDERED_INSTALLERS_DIR}/install.ps1" ] && cp "${RENDERED_INSTALLERS_DIR}/install.ps1" "$staging_dir/scripts/install.ps1"
chmod 755 "$staging_dir/scripts/"*.sh
chmod 755 "$staging_dir/scripts/"*.ps1 2>/dev/null || true
echo "$VERSION" > "$staging_dir/VERSION"
@@ -255,8 +289,8 @@ done
cp "scripts/install-container-agent.sh" "$universal_dir/scripts/install-container-agent.sh"
cp "scripts/install-docker.sh" "$universal_dir/scripts/install-docker.sh"
-cp "scripts/install.sh" "$universal_dir/scripts/install.sh"
-[ -f "scripts/install.ps1" ] && cp "scripts/install.ps1" "$universal_dir/scripts/install.ps1"
+cp "${RENDERED_INSTALLERS_DIR}/install.sh" "$universal_dir/scripts/install.sh"
+[ -f "${RENDERED_INSTALLERS_DIR}/install.ps1" ] && cp "${RENDERED_INSTALLERS_DIR}/install.ps1" "$universal_dir/scripts/install.ps1"
chmod 755 "$universal_dir/scripts/"*.sh
chmod 755 "$universal_dir/scripts/"*.ps1 2>/dev/null || true
@@ -388,8 +422,8 @@ fi
# curl -fsSL https://github.com/rcourtman/Pulse/releases/latest/download/install.sh | bash
# instead of pulling from main branch (which may have newer, incompatible changes)
echo "Copying install scripts to release directory..."
-cp scripts/install.sh "$RELEASE_DIR/install.sh"
-[ -f "scripts/install.ps1" ] && cp "scripts/install.ps1" "$RELEASE_DIR/install.ps1"
+cp "${RENDERED_INSTALLERS_DIR}/install.sh" "$RELEASE_DIR/install.sh"
+[ -f "${RENDERED_INSTALLERS_DIR}/install.ps1" ] && cp "${RENDERED_INSTALLERS_DIR}/install.ps1" "$RELEASE_DIR/install.ps1"
cp scripts/install-docker.sh "$RELEASE_DIR/"
cp scripts/pulse-auto-update.sh "$RELEASE_DIR/"
diff --git a/scripts/install.ps1 b/scripts/install.ps1
index 2f44641427..4752b2a78a 100644
--- a/scripts/install.ps1
+++ b/scripts/install.ps1
@@ -31,6 +31,10 @@ $StateDir = "$env:ProgramData\Pulse"
$ConnectionStatePath = "$StateDir\connection.env"
$LogFile = "$env:ProgramData\Pulse\pulse-agent.log"
$DownloadTimeoutSec = 300
+$PinnedInstallerSshPublicKey = "__PULSE_INSTALLER_SSH_PUBLIC_KEY__"
+$InstallerSignatureNamespace = "pulse-install"
+$InstallerSignatureIdentity = "pulse-installer"
+$InstallerSignatureHeaderName = "X-Signature-SSHSIG"
function Parse-Bool {
param(
@@ -234,6 +238,70 @@ function Get-FileChecksum {
}
}
+function Test-HasPinnedInstallerSignatureKey {
+ return (-not [string]::IsNullOrWhiteSpace($PinnedInstallerSshPublicKey)) -and ($PinnedInstallerSshPublicKey -ne "__PULSE_INSTALLER_SSH_PUBLIC_KEY__")
+}
+
+function Get-SshKeygenPath {
+ $command = Get-Command ssh-keygen.exe -ErrorAction SilentlyContinue
+ if ($null -eq $command) {
+ $command = Get-Command ssh-keygen -ErrorAction SilentlyContinue
+ }
+ if ($null -eq $command) {
+ throw "ssh-keygen is required to verify signed Pulse downloads."
+ }
+ return $command.Source
+}
+
+function Invoke-InstallerSignatureVerification {
+ param(
+ [string]$FilePath,
+ [string]$SignatureHeader
+ )
+
+ if (-not (Test-HasPinnedInstallerSignatureKey)) {
+ return
+ }
+ if ([string]::IsNullOrWhiteSpace($SignatureHeader)) {
+ throw "Server did not provide SSH signature metadata; refusing signed install."
+ }
+
+ $allowedSignersPath = [System.IO.Path]::GetTempFileName()
+ $signaturePath = [System.IO.Path]::GetTempFileName()
+ $stdoutPath = [System.IO.Path]::GetTempFileName()
+ $stderrPath = [System.IO.Path]::GetTempFileName()
+ $script:TempFiles += @($allowedSignersPath, $signaturePath, $stdoutPath, $stderrPath)
+
+ [System.IO.File]::WriteAllText($allowedSignersPath, "$InstallerSignatureIdentity $PinnedInstallerSshPublicKey`n")
+ try {
+ [System.IO.File]::WriteAllBytes($signaturePath, [Convert]::FromBase64String($SignatureHeader.Trim()))
+ } catch {
+ throw "Server provided an invalid SSH signature payload."
+ }
+
+ $sshKeygen = Get-SshKeygenPath
+ $commandLine = "`"$sshKeygen`" -Y verify -f `"$allowedSignersPath`" -I `"$InstallerSignatureIdentity`" -n `"$InstallerSignatureNamespace`" -s `"$signaturePath`" < `"$FilePath`""
+ $process = Start-Process -FilePath "cmd.exe" `
+ -ArgumentList "/d", "/s", "/c", $commandLine `
+ -NoNewWindow `
+ -Wait `
+ -PassThru `
+ -RedirectStandardOutput $stdoutPath `
+ -RedirectStandardError $stderrPath
+ if ($process.ExitCode -ne 0) {
+ $stderr = ""
+ if (Test-Path $stderrPath) {
+ $stderr = (Get-Content $stderrPath -Raw -ErrorAction SilentlyContinue).Trim()
+ }
+ if ([string]::IsNullOrWhiteSpace($stderr)) {
+ throw "Cryptographic signature verification failed for the downloaded agent binary."
+ }
+ throw "Cryptographic signature verification failed for the downloaded agent binary. $stderr"
+ }
+
+ Write-Host "Cryptographic signature verified." -ForegroundColor Green
+}
+
function Invoke-WithOptionalInsecureTls {
param(
[bool]$AllowInsecure,
@@ -485,6 +553,8 @@ if (-not (Test-Path $InstallDir)) {
$TempPath = [System.IO.Path]::GetTempFileName() + ".exe"
$script:TempFiles += $TempPath
$DestPath = "$InstallDir\$BinaryName"
+$serverChecksum = $null
+$serverSshSignature = $null
try {
# Configure TLS 1.2 minimum
@@ -507,6 +577,7 @@ try {
# Get checksum from server response headers if available
$serverChecksum = $webClient.ResponseHeaders["X-Checksum-Sha256"]
+ $serverSshSignature = $webClient.ResponseHeaders[$InstallerSignatureHeaderName]
}
} catch {
@@ -552,6 +623,26 @@ if (-not [string]::IsNullOrWhiteSpace($serverChecksum)) {
Write-Host "Warning: Server did not provide checksum header" -ForegroundColor Yellow
}
+if (Test-HasPinnedInstallerSignatureKey) {
+ if ([string]::IsNullOrWhiteSpace($serverChecksum)) {
+ Cleanup
+ Show-Error "Server did not provide checksum header; refusing signed install."
+ Exit 1
+ }
+ if ([string]::IsNullOrWhiteSpace($serverSshSignature)) {
+ Cleanup
+ Show-Error "Server did not provide SSH signature header; refusing signed install."
+ Exit 1
+ }
+ try {
+ Invoke-InstallerSignatureVerification -FilePath $TempPath -SignatureHeader $serverSshSignature
+ } catch {
+ Cleanup
+ Show-Error "$_"
+ Exit 1
+ }
+}
+
# --- Install Binary ---
Write-Host "Installing binary..." -ForegroundColor Cyan
diff --git a/scripts/install.sh b/scripts/install.sh
index b7bcd7d7d1..f1a54a36a9 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -87,6 +87,9 @@ NON_INTERACTIVE="false"
TOKEN_FILE_PATH="" # Path to file containing the token
OUTPUT_FORMAT="text" # "text" (default) or "json"
PREFLIGHT_ONLY="false"
+INSTALL_SIGNATURE_NAMESPACE="pulse-install"
+INSTALL_SIGNATURE_IDENTITY="pulse-installer"
+PINNED_INSTALLER_SSH_PUBLIC_KEY="__PULSE_INSTALLER_SSH_PUBLIC_KEY__"
# Track if flags were explicitly set (to override auto-detection)
DOCKER_EXPLICIT="false"
@@ -168,6 +171,7 @@ EXIT_SERVICE_START_FAILED=13
EXIT_PREFLIGHT_FAILED=14
EXIT_ALREADY_INSTALLED=15 # Not a failure — used with --preflight-only
EXIT_MISSING_ARGS=16
+EXIT_SIGNATURE_FAILED=17
json_event() {
# Usage: json_event <phase> <code> <message> [exitCode]
@@ -190,6 +194,63 @@ redact_token() {
echo "$msg"
}
+has_pinned_installer_signature_key() {
+ [[ -n "$PINNED_INSTALLER_SSH_PUBLIC_KEY" && "$PINNED_INSTALLER_SSH_PUBLIC_KEY" != "__PULSE_INSTALLER_SSH_PUBLIC_KEY__" ]]
+}
+
+decode_base64_to_file() {
+ local encoded="$1"
+ local output="$2"
+
+ if command -v base64 >/dev/null 2>&1; then
+ if printf '%s' "$encoded" | base64 --decode > "$output" 2>/dev/null; then
+ return 0
+ fi
+ if printf '%s' "$encoded" | base64 -d > "$output" 2>/dev/null; then
+ return 0
+ fi
+ if printf '%s' "$encoded" | base64 -D > "$output" 2>/dev/null; then
+ return 0
+ fi
+ fi
+
+ fail "Base64 decoder is required to verify signed Pulse downloads." "$EXIT_SIGNATURE_FAILED"
+}
+
+verify_download_signature() {
+ local target_path="$1"
+ local signature_header="$2"
+
+ if ! has_pinned_installer_signature_key; then
+ return 0
+ fi
+ if [[ -z "$signature_header" ]]; then
+ fail "Server did not provide SSH signature metadata; refusing signed install." "$EXIT_SIGNATURE_FAILED"
+ fi
+ if ! command -v ssh-keygen >/dev/null 2>&1; then
+ fail "ssh-keygen is required to verify signed Pulse downloads." "$EXIT_SIGNATURE_FAILED"
+ fi
+
+ local allowed_signers signature_file
+ allowed_signers=$(mktemp)
+ signature_file=$(mktemp)
+ TMP_FILES+=("$allowed_signers" "$signature_file")
+
+ printf '%s %s\n' "$INSTALL_SIGNATURE_IDENTITY" "$PINNED_INSTALLER_SSH_PUBLIC_KEY" > "$allowed_signers"
+ decode_base64_to_file "$signature_header" "$signature_file"
+
+ if ! ssh-keygen -Y verify \
+ -f "$allowed_signers" \
+ -I "$INSTALL_SIGNATURE_IDENTITY" \
+ -n "$INSTALL_SIGNATURE_NAMESPACE" \
+ -s "$signature_file" < "$target_path" >/dev/null 2>&1; then
+ fail "Cryptographic signature verification failed for the downloaded agent binary." "$EXIT_SIGNATURE_FAILED"
+ fi
+
+ json_event "download" "signature_ok" "Binary signature verified"
+ log_info "Binary signature verified"
+}
+
show_help() {
cat <<EOF
Pulse Unified Agent Installer
@@ -1465,7 +1526,7 @@ elif [[ "$OS" == "darwin" ]]; then
fi
fi
-# Checksum verification (when header is available)
+# Release metadata verification
CHECKSUM_URL="${PULSE_URL}/download/${BINARY_NAME}?arch=${ARCH_PARAM}"
TMP_HEADERS=$(mktemp)
TMP_FILES+=("$TMP_HEADERS")
@@ -1474,8 +1535,24 @@ if [[ "$INSECURE" == "true" ]]; then HEADER_CURL_ARGS+=(-k); fi
if [[ -n "$CURL_CA_BUNDLE" ]]; then HEADER_CURL_ARGS+=(--cacert "$CURL_CA_BUNDLE"); fi
EXPECTED_SHA=""
+SSH_SIGNATURE_HEADER=""
+METADATA_FETCHED=false
if curl "${HEADER_CURL_ARGS[@]}" "$CHECKSUM_URL" 2>/dev/null; then
+ METADATA_FETCHED=true
EXPECTED_SHA=$(grep -i '^X-Checksum-Sha256:' "$TMP_HEADERS" 2>/dev/null | tr -d '\r' | awk '{print $2}' || true)
+ SSH_SIGNATURE_HEADER=$(grep -i '^X-Signature-SSHSIG:' "$TMP_HEADERS" 2>/dev/null | tr -d '\r' | sed 's/^[^:]*:[[:space:]]*//' || true)
+fi
+
+if has_pinned_installer_signature_key; then
+ if [[ "$METADATA_FETCHED" != "true" ]]; then
+ fail "Failed to fetch signed download metadata from the Pulse server." "$EXIT_SIGNATURE_FAILED"
+ fi
+ if [[ -z "$EXPECTED_SHA" ]]; then
+ fail "Server did not provide checksum header; refusing signed install." "$EXIT_CHECKSUM_FAILED"
+ fi
+ if [[ -z "$SSH_SIGNATURE_HEADER" ]]; then
+ fail "Server did not provide SSH signature header; refusing signed install." "$EXIT_SIGNATURE_FAILED"
+ fi
fi
if [[ -n "$EXPECTED_SHA" ]]; then
@@ -1487,6 +1564,8 @@ if [[ -n "$EXPECTED_SHA" ]]; then
log_info "Binary checksum verified"
fi
+verify_download_signature "$TMP_BIN" "$SSH_SIGNATURE_HEADER"
+
chmod +x "$TMP_BIN"
# --- Upgrade Detection ---
diff --git a/scripts/installtests/build_release_assets_test.go b/scripts/installtests/build_release_assets_test.go
index 5956c63669..90bd6ce88a 100644
--- a/scripts/installtests/build_release_assets_test.go
+++ b/scripts/installtests/build_release_assets_test.go
@@ -15,8 +15,10 @@ func TestBuildReleaseUsesV6InstallScripts(t *testing.T) {
script := string(content)
required := []string{
- `cp scripts/install.sh "$RELEASE_DIR/install.sh"`,
- `[ -f "scripts/install.ps1" ] && cp "scripts/install.ps1" "$RELEASE_DIR/install.ps1"`,
+ `RENDERED_INSTALLERS_DIR="${BUILD_DIR}/rendered-installers"`,
+ `go run ./scripts/render_installers.go \`,
+ `cp "${RENDERED_INSTALLERS_DIR}/install.sh" "$RELEASE_DIR/install.sh"`,
+ `[ -f "${RENDERED_INSTALLERS_DIR}/install.ps1" ] && cp "${RENDERED_INSTALLERS_DIR}/install.ps1" "$RELEASE_DIR/install.ps1"`,
`cp "$BUILD_DIR/pulse-agent-linux-amd64" "$RELEASE_DIR/"`,
`cp "$BUILD_DIR/pulse-agent-linux-arm64" "$RELEASE_DIR/"`,
`cp "$BUILD_DIR/pulse-agent-linux-armv7" "$RELEASE_DIR/"`,
@@ -38,6 +40,9 @@ func TestBuildReleaseUsesV6InstallScripts(t *testing.T) {
`server_ldflags="$(./scripts/release_ldflags.sh server --version "v${VERSION}" --build-time "${build_time}" --git-commit "${git_commit}" "${license_ldflags_args[@]}" "${update_ldflags_args[@]}")"`,
`PULSE_UPDATE_SIGNING_KEY`,
`go run ./scripts/release_update_key.go public-key --private-key "${PULSE_UPDATE_SIGNING_KEY}"`,
+ `go run ./scripts/release_update_key.go public-key-ssh --private-key "${PULSE_UPDATE_SIGNING_KEY}"`,
+ `go run ./scripts/release_update_key.go openssh-private-key --private-key "${PULSE_UPDATE_SIGNING_KEY}"`,
+ `ssh-keygen -q -Y sign`,
`sign_release_file "${artifact}"`,
}
for _, needle := range requiredScriptWiring {
@@ -69,6 +74,7 @@ func TestCreateReleaseUploadsPowerShellInstaller(t *testing.T) {
`if [ -f release/install.ps1 ]; then`,
`gh release upload "${TAG}" release/install.ps1 --clobber`,
`gh release upload "${TAG}" release/*.sig --clobber`,
+ `gh release upload "${TAG}" release/*.sshsig --clobber`,
`uses: actions/attest@v4`,
`subject-path: release/*`,
`gh api "repos/${{ github.repository }}/releases?per_page=100" --paginate`,
@@ -97,10 +103,18 @@ func TestDockerAndDemoBuildsUseCanonicalReleaseLdflags(t *testing.T) {
dockerfile := string(dockerfileBytes)
dockerRequired := []string{
`COPY scripts/release_ldflags.sh ./scripts/release_ldflags.sh`,
+ `COPY scripts/release_update_key.go ./scripts/release_update_key.go`,
+ `COPY scripts/render_installers.go ./scripts/render_installers.go`,
`--mount=type=secret,id=pulse_license_public_key,required=false`,
+ `--mount=type=secret,id=pulse_update_signing_key,required=false`,
`LICENSE_PUBLIC_KEY="$(tr -d '\r\n' < /run/secrets/pulse_license_public_key)"`,
+ `UPDATE_PUBLIC_KEYS="$(go run ./scripts/release_update_key.go public-key --private-key "${UPDATE_SIGNING_KEY}")"`,
`./scripts/release_ldflags.sh server --version "${VERSION}" --build-time "${BUILD_TIME}" --git-commit "${GIT_COMMIT}"`,
`./scripts/release_ldflags.sh agent --version "${VERSION}"`,
+ `go run ./scripts/render_installers.go --source-dir ./scripts --output-dir /app/rendered-installers`,
+ `ssh-keygen -q -Y sign -f "${OPENSSH_SIGNING_KEY}" -n pulse-install`,
+ `COPY --from=backend-builder /app/rendered-installers/install.sh /opt/pulse/scripts/install.sh`,
+ `COPY --from=backend-builder /app/pulse-agent-* /opt/pulse/bin/`,
}
for _, needle := range dockerRequired {
if !strings.Contains(dockerfile, needle) {
@@ -138,8 +152,10 @@ func TestReleaseWorkflowsUseSecretSafeAttestedImageBuilds(t *testing.T) {
`sbom: true`,
`secrets: |`,
`pulse_license_public_key=${{ secrets.PULSE_LICENSE_PUBLIC_KEY }}`,
+ `pulse_update_signing_key=${{ secrets.PULSE_UPDATE_SIGNING_KEY }}`,
`DOCKER_BUILDKIT: 1`,
`--secret id=pulse_license_public_key,env=PULSE_LICENSE_PUBLIC_KEY`,
+ `--secret id=pulse_update_signing_key,env=PULSE_UPDATE_SIGNING_KEY`,
`id-token: write`,
`attestations: write`,
`uses: actions/attest@v4`,
@@ -163,6 +179,7 @@ func TestReleaseWorkflowsUseSecretSafeAttestedImageBuilds(t *testing.T) {
`sbom: true`,
`secrets: |`,
`pulse_license_public_key=${{ secrets.PULSE_LICENSE_PUBLIC_KEY }}`,
+ `pulse_update_signing_key=${{ secrets.PULSE_UPDATE_SIGNING_KEY }}`,
`subject-name: docker.io/rcourtman/pulse`,
`subject-name: ghcr.io/${{ github.repository_owner }}/pulse`,
`subject-name: docker.io/rcourtman/pulse-agent`,
diff --git a/scripts/installtests/install_ps1_test.go b/scripts/installtests/install_ps1_test.go
index e93059032c..9ee00f4285 100644
--- a/scripts/installtests/install_ps1_test.go
+++ b/scripts/installtests/install_ps1_test.go
@@ -239,3 +239,28 @@ func TestInstallPS1ClearsPersistedStateAfterUninstall(t *testing.T) {
}
}
}
+
+func TestInstallPS1RequiresPinnedSignatureVerificationForReleaseDownloads(t *testing.T) {
+ content, err := os.ReadFile(repoFile("scripts", "install.ps1"))
+ if err != nil {
+ t.Fatalf("read install.ps1: %v", err)
+ }
+
+ script := string(content)
+ required := []string{
+ `$PinnedInstallerSshPublicKey = "__PULSE_INSTALLER_SSH_PUBLIC_KEY__"`,
+ `function Test-HasPinnedInstallerSignatureKey {`,
+ `function Invoke-InstallerSignatureVerification {`,
+ `Get-Command ssh-keygen.exe -ErrorAction SilentlyContinue`,
+ `$serverSshSignature = $webClient.ResponseHeaders[$InstallerSignatureHeaderName]`,
+ `Show-Error "Server did not provide checksum header; refusing signed install."`,
+ `Show-Error "Server did not provide SSH signature header; refusing signed install."`,
+ `Invoke-InstallerSignatureVerification -FilePath $TempPath -SignatureHeader $serverSshSignature`,
+ `-Y verify -f`,
+ }
+ for _, needle := range required {
+ if !strings.Contains(script, needle) {
+ t.Fatalf("install.ps1 missing signed-download verification contract: %s", needle)
+ }
+ }
+}
diff --git a/scripts/installtests/install_sh_test.go b/scripts/installtests/install_sh_test.go
index fcc71f0874..983dc66bcb 100644
--- a/scripts/installtests/install_sh_test.go
+++ b/scripts/installtests/install_sh_test.go
@@ -1255,6 +1255,30 @@ exit 1
}
}
+func TestInstallSHRequiresPinnedSignatureVerificationForReleaseDownloads(t *testing.T) {
+ content, err := os.ReadFile(repoFile("scripts", "install.sh"))
+ if err != nil {
+ t.Fatalf("read install.sh: %v", err)
+ }
+
+ script := string(content)
+ required := []string{
+ `PINNED_INSTALLER_SSH_PUBLIC_KEY="__PULSE_INSTALLER_SSH_PUBLIC_KEY__"`,
+ `has_pinned_installer_signature_key() {`,
+ `grep -i '^X-Signature-SSHSIG:' "$TMP_HEADERS"`,
+ `if [[ "$METADATA_FETCHED" != "true" ]]; then`,
+ `Server did not provide checksum header; refusing signed install.`,
+ `Server did not provide SSH signature header; refusing signed install.`,
+ `ssh-keygen -Y verify`,
+ `Binary signature verified`,
+ }
+ for _, needle := range required {
+ if !strings.Contains(script, needle) {
+ t.Fatalf("install.sh missing signed-download verification contract: %s", needle)
+ }
+ }
+}
+
func TestBuildContainerInstallCommandPreservesForcedVersion(t *testing.T) {
script := `
FORCE_VERSION="v1.2.3"
diff --git a/scripts/release_control/release_promotion_policy_test.py b/scripts/release_control/release_promotion_policy_test.py
index 2648d86768..808d3d6549 100644
--- a/scripts/release_control/release_promotion_policy_test.py
+++ b/scripts/release_control/release_promotion_policy_test.py
@@ -268,6 +268,7 @@ class ReleasePromotionPolicyTest(unittest.TestCase):
self.assertIn('-F target_commitish="${HEAD_SHA}"', content)
self.assertIn("PULSE_UPDATE_SIGNING_KEY: ${{ secrets.PULSE_UPDATE_SIGNING_KEY }}", content)
self.assertIn('gh release upload "${TAG}" release/*.sig --clobber', content)
+ self.assertIn('gh release upload "${TAG}" release/*.sshsig --clobber', content)
self.assertIn("provenance: mode=max", content)
self.assertIn("sbom: true", content)
self.assertIn("id-token: write", content)
@@ -275,7 +276,9 @@ class ReleasePromotionPolicyTest(unittest.TestCase):
self.assertIn("uses: actions/attest@v4", content)
self.assertIn("subject-path: release/*", content)
self.assertIn("pulse_license_public_key=${{ secrets.PULSE_LICENSE_PUBLIC_KEY }}", content)
+ self.assertIn("pulse_update_signing_key=${{ secrets.PULSE_UPDATE_SIGNING_KEY }}", content)
self.assertIn("--secret id=pulse_license_public_key,env=PULSE_LICENSE_PUBLIC_KEY", content)
+ self.assertIn("--secret id=pulse_update_signing_key,env=PULSE_UPDATE_SIGNING_KEY", content)
self.assertNotIn("provenance: false", content)
self.assertIn("Derived rollback command:", helper)
self.assertIn("./scripts/install.sh --version", helper)
diff --git a/scripts/release_update_key.go b/scripts/release_update_key.go
index 1d92c38b26..9080e7f5ac 100644
--- a/scripts/release_update_key.go
+++ b/scripts/release_update_key.go
@@ -11,6 +11,8 @@ import (
func usage() {
fmt.Fprintln(os.Stderr, "usage:")
fmt.Fprintln(os.Stderr, " release_update_key.go public-key --private-key <base64-ed25519-key-or-seed>")
+ fmt.Fprintln(os.Stderr, " release_update_key.go public-key-ssh --private-key <base64-ed25519-key-or-seed> [--comment <comment>]")
+ fmt.Fprintln(os.Stderr, " release_update_key.go openssh-private-key --private-key <base64-ed25519-key-or-seed> [--comment <comment>]")
fmt.Fprintln(os.Stderr, " release_update_key.go sign --private-key <base64-ed25519-key-or-seed> --file <path>")
os.Exit(1)
}
@@ -35,6 +37,36 @@ func main() {
fail(err)
}
fmt.Println(encoded)
+ case "public-key-ssh":
+ publicKeyCmd := flag.NewFlagSet("public-key-ssh", flag.ExitOnError)
+ privateKey := publicKeyCmd.String("private-key", "", "base64-encoded Ed25519 private key or seed")
+ comment := publicKeyCmd.String("comment", "", "optional SSH key comment")
+ _ = publicKeyCmd.Parse(os.Args[2:])
+
+ key, err := updatesignature.DecodePrivateKey(*privateKey)
+ if err != nil {
+ fail(err)
+ }
+ encoded, err := updatesignature.AuthorizedPublicKeyString(key, *comment)
+ if err != nil {
+ fail(err)
+ }
+ fmt.Println(encoded)
+ case "openssh-private-key":
+ privateKeyCmd := flag.NewFlagSet("openssh-private-key", flag.ExitOnError)
+ privateKey := privateKeyCmd.String("private-key", "", "base64-encoded Ed25519 private key or seed")
+ comment := privateKeyCmd.String("comment", "", "optional SSH key comment")
+ _ = privateKeyCmd.Parse(os.Args[2:])
+
+ key, err := updatesignature.DecodePrivateKey(*privateKey)
+ if err != nil {
+ fail(err)
+ }
+ encoded, err := updatesignature.OpenSSHPrivateKeyPEM(key, *comment)
+ if err != nil {
+ fail(err)
+ }
+ fmt.Print(encoded)
case "sign":
signCmd := flag.NewFlagSet("sign", flag.ExitOnError)
privateKey := signCmd.String("private-key", "", "base64-encoded Ed25519 private key or seed")
diff --git a/scripts/render_installers.go b/scripts/render_installers.go
new file mode 100644
index 0000000000..2663684388
--- /dev/null
+++ b/scripts/render_installers.go
@@ -0,0 +1,52 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "os"
+ "path/filepath"
+ "strings"
+)
+
+const installerSSHPublicKeyPlaceholder = "__PULSE_INSTALLER_SSH_PUBLIC_KEY__"
+
+func main() {
+ sourceDir := flag.String("source-dir", "", "directory containing install.sh and install.ps1")
+ outputDir := flag.String("output-dir", "", "directory to write rendered installers into")
+ installerSSHPublicKey := flag.String("installer-ssh-public-key", "", "OpenSSH public key to pin into rendered installers")
+ flag.Parse()
+
+ if strings.TrimSpace(*sourceDir) == "" || strings.TrimSpace(*outputDir) == "" {
+ fail("source-dir and output-dir are required")
+ }
+
+ if err := os.MkdirAll(*outputDir, 0o755); err != nil {
+ fail(fmt.Sprintf("create output dir: %v", err))
+ }
+
+ for _, name := range []string{"install.sh", "install.ps1"} {
+ if err := renderInstaller(*sourceDir, *outputDir, name, strings.TrimSpace(*installerSSHPublicKey)); err != nil {
+ fail(err.Error())
+ }
+ }
+}
+
+func renderInstaller(sourceDir, outputDir, name, installerSSHPublicKey string) error {
+ sourcePath := filepath.Join(sourceDir, name)
+ content, err := os.ReadFile(sourcePath)
+ if err != nil {
+ return fmt.Errorf("read %s: %w", name, err)
+ }
+
+ rendered := strings.ReplaceAll(string(content), installerSSHPublicKeyPlaceholder, installerSSHPublicKey)
+ outputPath := filepath.Join(outputDir, name)
+ if err := os.WriteFile(outputPath, []byte(rendered), 0o755); err != nil {
+ return fmt.Errorf("write %s: %w", name, err)
+ }
+ return nil
+}
+
+func fail(message string) {
+ fmt.Fprintln(os.Stderr, message)
+ os.Exit(1)
+}