diff --git a/.github/workflows/codeql-verification.yml b/.github/workflows/codeql-verification.yml index 1f310e84..6ec7acd0 100644 --- a/.github/workflows/codeql-verification.yml +++ b/.github/workflows/codeql-verification.yml @@ -38,10 +38,12 @@ jobs: set -euo pipefail test -z "$(git status --porcelain)" git merge-base --is-ancestor eb6e43caaa32f8263fc33aa6044ff6d19f17e2f8 HEAD - grep -Fq 'VERSION_OVERRIDE: v0.13.39' .github/workflows/validate.yml + . scripts/version + [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] + grep -Fq "VERSION_OVERRIDE: $VERSION" .github/workflows/validate.yml grep -Fq 'SHA256SUMS' scripts/package grep -Fq 'bash scripts/verify-package "$linux_asset"' .github/workflows/validate.yml - grep -Fq 'bash scripts/verify-package dist/artifacts/node-agent-0.13.39.tar.gz' .github/workflows/security-release-gate.yml + grep -Fq "bash scripts/verify-package dist/artifacts/node-agent-${VERSION#v}.tar.gz" .github/workflows/security-release-gate.yml - name: Install the release Go toolchain uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 @@ -67,8 +69,9 @@ jobs: set -euo pipefail export GOFLAGS=-mod=vendor mkdir -p "$GITHUB_WORKSPACE/bin" + . scripts/version CGO_ENABLED=0 go build -trimpath -tags 'netgo osusergo' \ - -ldflags='-w -s -X main.VERSION=v0.13.39' \ + -ldflags="-w -s -X main.VERSION=$VERSION" \ -o "$GITHUB_WORKSPACE/bin/node-agent" ./ - name: Analyze without publishing temporary alerts diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c2ec706b..8797bf4e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,11 +17,11 @@ jobs: env: GH_TOKEN: ${{ github.token }} PRODUCER_RUN: ${{ inputs.producer_run }} - RELEASE_TAG: v0.13.39 + RELEASE_TAG: v0.13.40 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - ref: v0.13.39 + ref: v0.13.40 fetch-depth: 0 persist-credentials: false - name: Verify immutable tag and successful producer @@ -47,7 +47,7 @@ jobs: gzip -dc dist/security-runtime/images.tar.gz | docker load printf '%s' "$GH_TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin trap 'docker logout ghcr.io >/dev/null 2>&1 || true' EXIT - source_image='pasturestack/node-agent:v0.13.39' + source_image='pasturestack/node-agent:v0.13.40' remote_image="ghcr.io/pasturestack/node-agent:$RELEASE_TAG" if docker manifest inspect "$remote_image" >/dev/null 2>"$RUNNER_TEMP/manifest-error"; then echo "Refusing to replace an existing immutable image tag: $remote_image" >&2; exit 1 diff --git a/.github/workflows/security-release-gate.yml b/.github/workflows/security-release-gate.yml index f54f9e13..3d33c69d 100644 --- a/.github/workflows/security-release-gate.yml +++ b/.github/workflows/security-release-gate.yml @@ -19,9 +19,9 @@ jobs: timeout-minutes: 120 env: DAPPER_IMAGE: pasturestack/node-agent-dapper:${{ github.sha }} - RUNTIME_IMAGE: pasturestack/node-agent:v0.13.39 + RUNTIME_IMAGE: pasturestack/node-agent:v0.13.40 TRIVY_IMAGE: ghcr.io/aquasecurity/trivy:0.76.2@sha256:8f6bb947dbc528902e11f2f5be52f7b519f6a39d5d148f41166f2040499768fb - VERSION_OVERRIDE: v0.13.39 + VERSION_OVERRIDE: v0.13.40 steps: - name: Check out candidate uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -69,26 +69,53 @@ jobs: set -euo pipefail CROSS=1 VERSION_OVERRIDE="$VERSION_OVERRIDE" make DAPPER_IMAGE="$DAPPER_IMAGE" ci CHECK_QUALIFIED_BACKPORTS=1 make DAPPER_IMAGE="$DAPPER_IMAGE" IMAGE_NAME=pasturestack/node-agent \ - TAG=v0.13.39 VERSION_OVERRIDE="$VERSION_OVERRIDE" package-image - test -s dist/artifacts/node-agent-0.13.39.tar.gz - test -s dist/artifacts/node-agent-0.13.39-windows-amd64.zip + TAG=v0.13.40 VERSION_OVERRIDE="$VERSION_OVERRIDE" package-image + test -s dist/artifacts/node-agent-0.13.40.tar.gz + test -s dist/artifacts/node-agent-0.13.40-windows-amd64.zip test "$(cat dist/image)" = "$RUNTIME_IMAGE" docker image inspect "$RUNTIME_IMAGE-backports" --format "{{.Id}}" >/dev/null - gzip -t dist/artifacts/node-agent-0.13.39.tar.gz - bash scripts/verify-package dist/artifacts/node-agent-0.13.39.tar.gz - unzip -t dist/artifacts/node-agent-0.13.39-windows-amd64.zip + gzip -t dist/artifacts/node-agent-0.13.40.tar.gz + bash scripts/verify-package dist/artifacts/node-agent-0.13.40.tar.gz + unzip -t dist/artifacts/node-agent-0.13.40-windows-amd64.zip ( cd dist/artifacts - sha256sum node-agent-0.13.39.tar.gz node-agent-0.13.39-windows-amd64.zip > SHA256SUMS + sha256sum node-agent-0.13.40.tar.gz node-agent-0.13.40-windows-amd64.zip > SHA256SUMS sha256sum -c SHA256SUMS ) - sha256sum dist/artifacts/node-agent-0.13.39.tar.gz \ - dist/artifacts/node-agent-0.13.39-windows-amd64.zip \ + sha256sum dist/artifacts/node-agent-0.13.40.tar.gz \ + dist/artifacts/node-agent-0.13.40-windows-amd64.zip \ bin/node-agent bin/windows/amd64/node-agent.exe > evidence/product-artifacts.sha256 docker image inspect "$RUNTIME_IMAGE" > evidence/runtime-image-inspect.json docker run --rm --entrypoint /usr/bin/node-agent "$RUNTIME_IMAGE" --version \ > evidence/runtime-version.txt - grep -Fxq 'node-agent version v0.13.39' evidence/runtime-version.txt + grep -Fxq 'node-agent version v0.13.40' evidence/runtime-version.txt + + - name: Exercise the published Host API producer contract + shell: bash + run: | + set -euo pipefail + mkdir -p "$RUNNER_TEMP/host-api-contract" + curl --fail --location --retry 3 --proto '=https' --tlsv1.2 \ + https://github.com/PastureStack/host-api/releases/download/v0.38.12/host-api-0.38.12.tar.gz \ + -o "$RUNNER_TEMP/host-api-contract/producer.tar.gz" + printf '%s %s\n' 4761c2a9f79f683e11b72c27ccf8416df3b96391cfd918145ea6085fb556044a \ + "$RUNNER_TEMP/host-api-contract/producer.tar.gz" | sha256sum --check - + tar -xzf "$RUNNER_TEMP/host-api-contract/producer.tar.gz" -C "$RUNNER_TEMP/host-api-contract" \ + 7283936664b1e1783547a8c80117e8db/bin/host-api + producer="$RUNNER_TEMP/host-api-contract/7283936664b1e1783547a8c80117e8db/bin/host-api" + printf '%s %s\n' a9bd3018172a3a988b2202fdb330c47d6744d647403669e1ca74bc5cbbe27e68 "$producer" | sha256sum --check - + chmod 0755 "$producer" + sudo chown root:root "$producer" + required=$(bin/node-agent --host-api-producer-version) + actual=$("$producer" --version) + test "$required" = "$actual" + printf '%s\n' "$required" > evidence/host-api-producer-version.txt + docker run --rm --entrypoint go -v "$PWD:/work" -w /work \ + -v "$RUNNER_TEMP/host-api-contract:/producer:ro" \ + -e PASTURESTACK_TEST_HOST_API_BINARY=/producer/7283936664b1e1783547a8c80117e8db/bin/host-api \ + -e GOFLAGS=-mod=vendor -e GOTOOLCHAIN=local "$DAPPER_IMAGE" \ + test -count=1 -v ./service/hostapilauncher \ + | tee evidence/host-api-producer-contract.txt - name: Verify reproducible Linux binary shell: bash @@ -125,7 +152,7 @@ jobs: trap 'rm -rf "$source_tree" "$product_tree"' EXIT git archive --format=tar HEAD | tar -xf - -C "$source_tree" cp bin/node-agent "$product_tree/node-agent" - unzip -p dist/artifacts/node-agent-0.13.39-windows-amd64.zip pasturestack/node-agent.exe > "$product_tree/node-agent.exe" + unzip -p dist/artifacts/node-agent-0.13.40-windows-amd64.zip pasturestack/node-agent.exe > "$product_tree/node-agent.exe" test -s "$product_tree/node-agent.exe" docker run --rm -v "$cache:/root/.cache/trivy" "$TRIVY_IMAGE" image --download-db-only docker run --rm -v "$source_tree:/scan:ro" -v "$PWD/evidence:/evidence" \ @@ -348,7 +375,7 @@ jobs: docker save "$RUNTIME_IMAGE" | gzip -n > dist/security-runtime/images.tar.gz cp evidence/runtime-security.json evidence/runtime-security.effective.json evidence/runtime.cdx.json dist/security-runtime/ tar -cf dist/security-runtime/ubuntu-backports-evidence.tar -C evidence ubuntu-backports ubuntu-backports-validation.json - cp dist/artifacts/node-agent-0.13.39.tar.gz dist/artifacts/node-agent-0.13.39-windows-amd64.zip dist/security-runtime/ + cp dist/artifacts/node-agent-0.13.40.tar.gz dist/artifacts/node-agent-0.13.40-windows-amd64.zip dist/security-runtime/ printf '%s\n' "$GITHUB_SHA" > dist/security-runtime/source-revision.txt (cd dist/security-runtime && sha256sum -- * > SHA256SUMS) - name: Upload exact runtime release bytes @@ -362,10 +389,10 @@ jobs: - name: Retain exact scanned release packages uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: - name: node-agent-scanned-0.13.39 + name: node-agent-scanned-0.13.40 path: | - dist/artifacts/node-agent-0.13.39.tar.gz - dist/artifacts/node-agent-0.13.39-windows-amd64.zip + dist/artifacts/node-agent-0.13.40.tar.gz + dist/artifacts/node-agent-0.13.40-windows-amd64.zip dist/artifacts/SHA256SUMS if-no-files-found: error retention-days: 30 diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 42c64008..0445a6a4 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -52,7 +52,7 @@ jobs: id: package env: CROSS: "1" - VERSION_OVERRIDE: v0.13.39 + VERSION_OVERRIDE: v0.13.40 VALIDATION_SCOPE: ${{ inputs.validation_scope || 'full' }} run: | set -euo pipefail @@ -75,8 +75,8 @@ jobs: exit 1 ;; esac - linux_asset="dist/artifacts/node-agent-0.13.39.tar.gz" - windows_asset="dist/artifacts/node-agent-0.13.39-windows-amd64.zip" + linux_asset="dist/artifacts/node-agent-0.13.40.tar.gz" + windows_asset="dist/artifacts/node-agent-0.13.40-windows-amd64.zip" test -s "$linux_asset" test -s "$windows_asset" gzip -t "$linux_asset" @@ -92,8 +92,8 @@ jobs: ( cd dist/artifacts sha256sum \ - node-agent-0.13.39.tar.gz \ - node-agent-0.13.39-windows-amd64.zip >SHA256SUMS + node-agent-0.13.40.tar.gz \ + node-agent-0.13.40-windows-amd64.zip >SHA256SUMS sha256sum -c SHA256SUMS ) printf 'NODE_AGENT_VALIDATION_OK source=%s version=%s scope=%s artifacts=linux,windows\n' \ @@ -102,10 +102,10 @@ jobs: - name: Retain reviewed release candidate uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: - name: node-agent-0.13.39 + name: node-agent-0.13.40 path: | - dist/artifacts/node-agent-0.13.39.tar.gz - dist/artifacts/node-agent-0.13.39-windows-amd64.zip + dist/artifacts/node-agent-0.13.40.tar.gz + dist/artifacts/node-agent-0.13.40-windows-amd64.zip dist/artifacts/SHA256SUMS if-no-files-found: error retention-days: 30 diff --git a/README.md b/README.md index 4f2ee1ae..0f30b437 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PastureStack Node Agent -Node Agent **`v0.13.39`** requires Host API **`0.38.11`** on Linux. The [release pipeline](https://github.com/PastureStack/node-agent/actions/workflows/security-release-gate.yml) builds the Linux and Windows packages and OCI image with Go 1.27.4. The native binaries use OpenTelemetry Go 1.47.0, which fixes CVE-2026-128085. +Node Agent **`v0.13.40`** requires Host API **`0.38.12`** on Linux. The [release pipeline](https://github.com/PastureStack/node-agent/actions/workflows/security-release-gate.yml) builds the Linux and Windows packages and OCI image with Go 1.27.4. The native binaries use OpenTelemetry Go 1.47.0, which fixes CVE-2026-128085. The runtime integrates shared Ubuntu 26.04 security backports for already-installed packages while preserving the selected coreutils provider. @@ -28,12 +28,12 @@ From a Docker-capable Linux host: make test make build make package -make package-image IMAGE_NAME=pasturestack/node-agent TAG=v0.13.39 +make package-image IMAGE_NAME=pasturestack/node-agent TAG=v0.13.40 ``` Packaging is local only and does not push an image. See [COMPATIBILITY.md](COMPATIBILITY.md), [SECURITY.md](SECURITY.md), and [ORIGIN.md](ORIGIN.md). -The recipe packages version `0.13.39`. Verify the [published assets](https://github.com/PastureStack/node-agent/releases/tag/v0.13.39) +The recipe packages version `0.13.40`. Verify the [published assets](https://github.com/PastureStack/node-agent/releases/tag/v0.13.40) using their SHA-256 checksums. Published tags and assets remain immutable; later documentation commits do not change their producer identity. The outer bootstrap image version and the Go package version are separate identities. @@ -44,7 +44,7 @@ client 0.5, gopsutil v4.26, mapstructure v2.5, netlink v1.3, and netns v0.0.5. The retired AWS SDK v1, Aliyungo, root Docker module, GOPATH/Godeps, and Trash dependency paths are not part of the build. -`VERSION_OVERRIDE=v0.13.39 make package` produces the Linux asset `node-agent-0.13.39.tar.gz`. The archive carries the legacy SHA-1 and current SHA-256 manifests required by the authenticated configcontent installer. The producer release must pass this repository's normal publication and byte verification before Server can embed that archive and distribute it through the existing configuration channel. Component publication and matching Server acceptance are separate evidence boundaries. +`VERSION_OVERRIDE=v0.13.40 make package` produces the Linux asset `node-agent-0.13.40.tar.gz`. The archive carries the legacy SHA-1 and current SHA-256 manifests required by the authenticated configcontent installer. The producer release must pass this repository's normal publication and byte verification before Server can embed that archive and distribute it through the existing configuration channel. Component publication and matching Server acceptance are separate evidence boundaries. Upgrade existing Linux hosts through that established configcontent/pyagent sequence, installing the compatible Host API package before Node. Keep the @@ -52,7 +52,7 @@ existing platform-home data volume and Host ID; do not register a replacement host or create a replacement state volume. Read the installed Node version with `${PASTURESTACK_HOME:-${CATTLE_HOME:-/var/lib/pasturestack}}/node-agent/node-agent --version`; after installing this Linux version, the expected result is -`node-agent version v0.13.39`. +`node-agent version v0.13.40`. On Linux, Node supervises the separately maintained `host-api` producer at `${PASTURESTACK_HOME:-${CATTLE_HOME:-/var/lib/pasturestack}}/bin/host-api`. Host API `0.38.11` must be installed before the Node package by the existing `pyagent` package sequence. Node verifies its exact version, forwards the current agent/host identity only through process environment, restarts an exited child, and binds its lifetime to Node. Missing or incompatible producers never fall back to the embedded legacy Host API. Stream authorization, target binding, and private durable terminal evidence remain owned by the Host API producer. diff --git a/main.go b/main.go index 989a0d43..d5c0f70c 100755 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "github.com/PastureStack/node-agent/cloudprovider" "github.com/PastureStack/node-agent/events" "github.com/PastureStack/node-agent/register" + "github.com/PastureStack/node-agent/service/hostapilauncher" "github.com/PastureStack/node-agent/utilities/config" "github.com/rancher/log" logserver "github.com/rancher/log/server" @@ -23,6 +24,7 @@ var ( func main() { logserver.StartServerWithDefaults() version := flag.Bool("version", false, "node-agent version") + hostAPIVersion := flag.Bool("host-api-producer-version", false, "required Host API producer version; exits without connecting") rurl := flag.String("url", "", "registration URL") registerService := flag.String("register-service", "", "register node-agent service") unregisterService := flag.Bool("unregister-service", false, "unregister node-agent service") @@ -35,6 +37,10 @@ func main() { fmt.Printf("node-agent version %s\n", VERSION) os.Exit(0) } + if *hostAPIVersion { + fmt.Println(hostapilauncher.RequiredVersion) + return + } if os.Getenv("PASTURESTACK_DEBUG") != "" || os.Getenv("CATTLE_SCRIPT_DEBUG") != "" || os.Getenv("RANCHER_DEBUG") != "" { log.SetLevelString("debug") diff --git a/scripts/version b/scripts/version index 55c687c9..67f03ed5 100755 --- a/scripts/version +++ b/scripts/version @@ -1,8 +1,8 @@ #!/bin/bash -if [ -n "$VERSION_OVERRIDE" ]; then +if [ -n "${VERSION_OVERRIDE:-}" ]; then VERSION="$VERSION_OVERRIDE" return 0 fi -VERSION=v0.13.39 +VERSION=v0.13.40 diff --git a/service/hostapilauncher/process_linux_test.go b/service/hostapilauncher/process_linux_test.go index 23a083fc..64c99692 100644 --- a/service/hostapilauncher/process_linux_test.go +++ b/service/hostapilauncher/process_linux_test.go @@ -19,7 +19,7 @@ func TestProducerIsBoundToLinuxParentDeathAndRejectsUnsafeExecutable(t *testing. } directory := t.TempDir() file := filepath.Join(directory, "host-api") - if err := os.WriteFile(file, []byte("#!/bin/sh\nprintf '0.38.11\\n'\n"), 0755); err != nil { + if err := os.WriteFile(file, []byte("#!/bin/sh\nprintf '%s\\n' '"+RequiredVersion+"'\n"), 0755); err != nil { t.Fatal(err) } if err := validateProducer(context.Background(), file, os.Environ()); err != nil { diff --git a/service/hostapilauncher/supervisor.go b/service/hostapilauncher/supervisor.go index ac839498..aa4a2ee1 100644 --- a/service/hostapilauncher/supervisor.go +++ b/service/hostapilauncher/supervisor.go @@ -17,7 +17,10 @@ import ( "github.com/rancher/log" ) -const RequiredVersion = "0.38.11" +// Keep this exact producer contract in sync with the checksum-pinned package +// exercised by the release gate. A newer installed producer is not permission +// to bypass its separately maintained authorization boundary. +const RequiredVersion = "0.38.12" type Settings struct { Binary string diff --git a/service/hostapilauncher/supervisor_test.go b/service/hostapilauncher/supervisor_test.go index 83a625a2..db78c8ab 100644 --- a/service/hostapilauncher/supervisor_test.go +++ b/service/hostapilauncher/supervisor_test.go @@ -3,18 +3,19 @@ package hostapilauncher import ( "context" "errors" + "os" "reflect" "strings" "testing" ) func TestProducerVersionIsExactAndBounded(t *testing.T) { - for _, version := range []string{"0.38.11", "0.38.11\n"} { + for _, version := range []string{"0.38.12", "0.38.12\n"} { if !validVersion(version) { t.Fatal("current producer rejected") } } - for _, version := range []string{"0.38.4", "0.38.5", "0.38.6", "0.38.7", "0.38.8", "0.38.9", "0.38.10", "0.39.0", "0.038.11", "v0.38.11", "0.38.11-dirty", "0.38.11\r\n", "0.38.11\nextra", "0.38.11\n0.38.10", ""} { + for _, version := range []string{"0.38.4", "0.38.5", "0.38.6", "0.38.7", "0.38.8", "0.38.9", "0.38.10", "0.38.11", "0.39.0", "0.038.12", "v0.38.12", "0.38.12-dirty", "0.38.12\r\n", "0.38.12\nextra", "0.38.12\n0.38.11", ""} { if validVersion(version) { t.Fatal("incompatible producer accepted") } @@ -25,6 +26,19 @@ func TestProducerVersionIsExactAndBounded(t *testing.T) { } } +// The release gate sets this to the SHA-256-verified, published Host API +// executable. This exercises the real cross-repository contract rather than a +// mock that can accidentally repeat the consumer's stale version string. +func TestPublishedHostAPIProducer(t *testing.T) { + binary := os.Getenv("PASTURESTACK_TEST_HOST_API_BINARY") + if binary == "" { + t.Skip("published producer is exercised by the Linux release gate") + } + if err := validateProducer(context.Background(), binary, os.Environ()); err != nil { + t.Fatalf("published Host API is incompatible with Node Agent: %v", err) + } +} + func TestNodeIdentityUsesEnvironmentAndNeverSecretArguments(t *testing.T) { values := map[string]string{"HOST_API_PLATFORM_SECRET_KEY": "agent-secret", "HOST_API_PLATFORM_URL": "http://engine:8080/v2-beta", "PASTURESTACK_HOME": "/var/lib/cattle"} environment := childEnvironment([]string{"PATH=/usr/bin", "HOST_API_CONFIG_FILE=/untrusted/config", "HOST_API_PLATFORM_URL=http://foreign", "PASTURESTACK_HOME=/wrong"}, values)