Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

release: sign Linux packages and checksums.txt when a key is configured

Claude1e63f52d05e4
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index d9455819..f14de189 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -2,7 +2,8 @@ name: Release
# Full hands-off release on a pushed v* tag:
# 1. goreleaser — builds tarballs, publishes the GitHub release + changelog,
-# and updates the Homebrew tap.
+# and updates the Homebrew tap. Signs the .deb/.rpm when the
+# Linux signing key secret exists.
# 2. package — (after goreleaser) builds, signs, notarizes, and staples the
# macOS .pkg for both arches and attaches them plus the
# package update manifest to the same release.
@@ -11,7 +12,8 @@ name: Release
# attaches it. Unsigned for now, so it needs no secrets.
# 4. finalize — (after all three) adds the .pkg, .msi and install.sh to checksums.txt and
# records a GitHub build-provenance attestation for every file
-# checksums.txt lists.
+# checksums.txt lists. Signs checksums.txt when the Linux signing
+# key secret exists.
#
# Triggered only by pushed version tags, so outside contributors (whose fork PRs
# never receive secrets) cannot run it. All release secrets live in the protected
@@ -66,6 +68,21 @@ jobs:
- name: Download Vector for the Linux packages
run: sh packaging/linux/fetch-vector.sh
+ # nfpm signs the .deb and .rpm when BEACON_LINUX_SIGNING_KEY_FILE names a key, so they ship
+ # unsigned, as before, until the BEACON_LINUX_SIGNING_KEY secret exists.
+ - name: Stage the Linux release signing key
+ env:
+ BEACON_LINUX_SIGNING_KEY: ${{ secrets.BEACON_LINUX_SIGNING_KEY }}
+ run: |
+ set -euo pipefail
+ if [ -z "$BEACON_LINUX_SIGNING_KEY" ]; then
+ echo "::notice title=Linux signing skipped::BEACON_LINUX_SIGNING_KEY is not configured, so the .deb and .rpm are unsigned."
+ exit 0
+ fi
+ key="$RUNNER_TEMP/beacon-linux-signing.asc"
+ (umask 077 && printf '%s\n' "$BEACON_LINUX_SIGNING_KEY" > "$key")
+ echo "BEACON_LINUX_SIGNING_KEY_FILE=$key" >> "$GITHUB_ENV"
+
- name: Check GoReleaser config
working-directory: cli/beacon
env:
@@ -80,6 +97,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
+ NFPM_PASSPHRASE: ${{ secrets.BEACON_LINUX_SIGNING_KEY_PASSPHRASE }}
run: goreleaser release --clean --parallelism 1
package:
@@ -418,6 +436,7 @@ jobs:
needs: [goreleaser, package, windows-package]
if: ${{ !cancelled() && needs.goreleaser.result == 'success' }}
runs-on: ubuntu-latest
+ environment: release
permissions:
contents: write
id-token: write
@@ -446,6 +465,30 @@ jobs:
sha256sum --check checksums.txt --ignore-missing
gh release upload "$TAG" checksums.txt --repo "$REPO" --clobber
+ # Here rather than in goreleaser because the step above rewrites checksums.txt. Inert, like the
+ # package signing, until the BEACON_LINUX_SIGNING_KEY secret exists.
+ - name: Sign checksums.txt
+ working-directory: dist/release
+ env:
+ BEACON_LINUX_SIGNING_KEY: ${{ secrets.BEACON_LINUX_SIGNING_KEY }}
+ BEACON_LINUX_SIGNING_KEY_PASSPHRASE: ${{ secrets.BEACON_LINUX_SIGNING_KEY_PASSPHRASE }}
+ run: |
+ set -euo pipefail
+ if [ -z "$BEACON_LINUX_SIGNING_KEY" ]; then
+ echo "::notice title=Linux signing skipped::BEACON_LINUX_SIGNING_KEY is not configured, so checksums.txt is unsigned."
+ exit 0
+ fi
+ export GNUPGHOME="$RUNNER_TEMP/gnupg"
+ mkdir -m 0700 "$GNUPGHOME"
+ printf '%s\n' "$BEACON_LINUX_SIGNING_KEY" | gpg --batch --import
+ fpr="$(gpg --batch --with-colons --list-secret-keys | awk -F: '$1 == "fpr" { print $10; exit }')"
+ printf '%s' "$BEACON_LINUX_SIGNING_KEY_PASSPHRASE" | gpg --batch --pinentry-mode loopback --passphrase-fd 0 \
+ --local-user "$fpr" --output checksums.txt.sig --detach-sign checksums.txt
+ gpg --batch --export "$fpr" > beacon-release-key.gpg
+ gpg --batch --armor --export "$fpr" > beacon-release-key.asc
+ gpgv --keyring "$PWD/beacon-release-key.gpg" checksums.txt.sig checksums.txt
+ gh release upload "$TAG" checksums.txt.sig beacon-release-key.gpg beacon-release-key.asc --repo "$REPO" --clobber
+
- name: Download every file checksums.txt lists
working-directory: dist/release
run: |
diff --git a/CLAUDE.md b/CLAUDE.md
index 076fd85d..4f16ceea 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -270,7 +270,8 @@ A pushed `v*` tag runs the full release end-to-end via
1. `goreleaser` (ubuntu, `environment: release`) builds the collector dists,
publishes the GitHub release + changelog and tarballs, and updates the
- Homebrew tap.
+ Homebrew tap. When the `BEACON_LINUX_SIGNING_KEY` secret exists, nfpm
+ signs the `.deb`/`.rpm` with it; without it they ship unsigned.
2. `package` (macOS, `needs: goreleaser`, `environment: release`) builds the
Apple Silicon `beacon`/`beacon-hooks` package payload plus arch-matched
collector and Vector binaries for `darwin_arm64`, then signs, notarizes,
@@ -286,7 +287,11 @@ A pushed `v*` tag runs the full release end-to-end via
appends the `.pkg`, `.msi` and `install.sh` to `checksums.txt` from the released bytes and
records a GitHub build-provenance attestation (Sigstore, keyless, through the
workflow's OIDC token) for every file `checksums.txt` lists. It needs
- `id-token: write` and `attestations: write` and no `release`-environment secrets.
+ `id-token: write` and `attestations: write`, and runs in the `release`
+ environment only so that, when `BEACON_LINUX_SIGNING_KEY` exists, it can sign
+ the final `checksums.txt` as `checksums.txt.sig` and attach the public key as
+ `beacon-release-key.{asc,gpg}`. Anything else that rewrites `checksums.txt`
+ must come before that step.
Every third-party action in `release.yml` and `release-extension.yml` is pinned to
a full commit SHA with the version in a trailing comment, because these jobs hold
@@ -297,6 +302,19 @@ Required `release`-environment secrets: `HOMEBREW_TAP_TOKEN`,
`DEVELOPER_ID_INSTALLER_CERT_P12`, `DEVELOPER_ID_INSTALLER_CERT_PASSWORD`,
`NOTARY_API_KEY_P8`, `NOTARY_API_KEY_ID`, `NOTARY_API_ISSUER`; plus Variables
`DEVELOPER_ID_APP_IDENTITY`, `DEVELOPER_ID_INSTALLER_IDENTITY`, `APPLE_TEAM_ID`.
+Optional: `BEACON_LINUX_SIGNING_KEY` (ASCII-armored OpenPGP secret key) and
+`BEACON_LINUX_SIGNING_KEY_PASSPHRASE`, which turn on Linux signing.
+
+Linux signing is trusted only through the fingerprints, one per line, in
+`cli/beacon/internal/endpoint/selfupdate/release-key.fingerprint`. The
+self-updater embeds that file and the goreleaser before-hook stamps it into the
+released `install.sh`, so pinning is a change to that file alone. Empty means
+checksum-only, as before. Once set, `install.sh` and `beacon endpoint update
+--apply` on Linux refuse a package unless a `checksums.txt` signed by a pinned
+key lists it. Publish the fingerprint in `docs/platforms/linux.mdx#release-signing`.
+To rotate, add the new fingerprint in a release still signed by the old key,
+then switch the secret and drop the old fingerprint in the next release.
+
Keep one-time Apple-side onboarding steps out of the repo and share them with
the release maintainer directly. Never use `pull_request_target` or build
untrusted PR code in the signing job.
@@ -393,7 +411,8 @@ The release should include the five GoReleaser CLI archives (four `.tar.gz` plus
`BeaconEndpointAgent-<version>-arm64.pkg`, its `.sha256`, `update-manifest.json`,
and `BeaconEndpointAgent-<version>-x64.msi` with its `.sha256`. `checksums.txt` lists
the archives, the Linux packages, the `.pkg`, the `.msi` and `install.sh`, and each of those has a
-build-provenance attestation.
+build-provenance attestation. Once Linux signing is on, the release also carries
+`checksums.txt.sig` and `beacon-release-key.{asc,gpg}`.
The MSI is unsigned, so `pkgutil`/`stapler`/`spctl` have no Windows counterpart to
run. Its `.sha256` is therefore the only integrity check it has, and the release
diff --git a/cli/beacon/.goreleaser.yaml b/cli/beacon/.goreleaser.yaml
index c12fb1ac..7b6b9b21 100644
--- a/cli/beacon/.goreleaser.yaml
+++ b/cli/beacon/.goreleaser.yaml
@@ -23,8 +23,9 @@ before:
# as a release asset users install with `beacon rules pull <asset-url>`.
- bash -c 'mkdir -p release-rules && COPYFILE_DISABLE=1 tar --exclude="._*" --exclude=".DS_Store" -czf release-rules/threat-rules.tar.gz -C ../.. rules'
# GoReleaser v2 rejects release extra_files outside its working directory. Stage the
- # repository-level one-line installer locally before attaching it to the release.
- - bash -c 'mkdir -p release-install && cp ../../packaging/linux/install.sh release-install/install.sh'
+ # repository-level one-line installer locally before attaching it to the release, pinning the
+ # Linux release key the self-updater embeds.
+ - bash -c 'mkdir -p release-install && fprs="$(xargs < internal/endpoint/selfupdate/release-key.fingerprint | tr " " ,)" && sed "s/^release_key_fingerprints=$/release_key_fingerprints=$fprs/" ../../packaging/linux/install.sh > release-install/install.sh && grep -qx "release_key_fingerprints=$fprs" release-install/install.sh'
builds:
- id: beacon
@@ -190,6 +191,9 @@ nfpms:
- systemd
rpm:
group: Applications/System
+ # Signed with the Linux release key when release.yml imports one, and unsigned otherwise.
+ signature:
+ key_file: '{{ envOrDefault "BEACON_LINUX_SIGNING_KEY_FILE" "" }}'
scripts:
# rpm runs the outgoing package's %preun after the incoming package's %post during an
# upgrade, so an older package can stop the service the new one just started -- and nothing
@@ -199,6 +203,8 @@ nfpms:
deb:
fields:
Bugs: https://github.com/asymptote-labs/agent-beacon/issues
+ signature:
+ key_file: '{{ envOrDefault "BEACON_LINUX_SIGNING_KEY_FILE" "" }}'
checksum:
name_template: "checksums.txt"
diff --git a/cli/beacon/internal/endpoint/selfupdate/apply.go b/cli/beacon/internal/endpoint/selfupdate/apply.go
index bfb4d808..fc605094 100644
--- a/cli/beacon/internal/endpoint/selfupdate/apply.go
+++ b/cli/beacon/internal/endpoint/selfupdate/apply.go
@@ -223,10 +223,15 @@ func (a *Applier) installPackage(ctx context.Context, pkg Package, result ApplyR
// SHA-256 verification above still applies on every platform and is not optional. The trust
// root that leaves is HTTPS plus the release checksum -- which is the same trust root the
// user relied on to obtain the package they are updating, so this is parity with the install
- // path rather than a downgrade. Notarization gives macOS assurance above that; adding a
- // comparable Linux story means a signing scheme (GPG-signed metadata or Sigstore) with real
- // key management, and that is a deliberate decision rather than something to bolt on here.
+ // path rather than a downgrade. Once a release key is pinned, Linux also requires the
+ // package in a checksums.txt signed by Beacon's release key.
switch {
+ case runtime.GOOS == "linux" && len(releaseKeyFingerprints) > 0:
+ result.Verification = "sha256+gpg"
+ if err := a.verifyReleaseSignature(ctx, pkg.URL, pkgPath); err != nil {
+ a.emit(false, result, err.Error())
+ return result, fmt.Errorf("verify release signature: %w", err)
+ }
case runtime.GOOS != "darwin":
result.Verification = "sha256"
case a.SkipGatekeeper:
diff --git a/cli/beacon/internal/endpoint/selfupdate/linuxsig.go b/cli/beacon/internal/endpoint/selfupdate/linuxsig.go
new file mode 100644
index 00000000..35457233
--- /dev/null
+++ b/cli/beacon/internal/endpoint/selfupdate/linuxsig.go
@@ -0,0 +1,102 @@
+package selfupdate
+
+import (
+ "context"
+ _ "embed"
+ "fmt"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+)
+
+// pinnedReleaseKeys holds the OpenPGP fingerprints, one per line, of the keys allowed to sign a
+// release's checksums.txt; two only while a key is rotated. It is empty until Beacon has a Linux
+// release key, and while it is, a Linux update is verified against the manifest's SHA-256 only.
+// Once set, a .deb or .rpm is installed only if a checksums.txt signed by one of these keys lists
+// it. The release copy of packaging/linux/install.sh is stamped from the same file, so pinning a
+// key is a change to release-key.fingerprint alone.
+//
+//go:embed release-key.fingerprint
+var pinnedReleaseKeys string
+
+var releaseKeyFingerprints = strings.Fields(pinnedReleaseKeys)
+
+// releaseKeyAsset is the release's public key, exported from the signing key by release.yml. It
+// is fetched from the release like checksums.txt, so it is trusted only for carrying the pinned
+// fingerprint.
+const releaseKeyAsset = "beacon-release-key.gpg"
+
+// verifyReleaseSignature checks that checksums.txt beside the package is signed by a pinned key
+// and lists the package's file name with the downloaded bytes' SHA-256.
+func (a *Applier) verifyReleaseSignature(ctx context.Context, pkgURL, pkgPath string) error {
+ i := strings.LastIndex(pkgURL, "/")
+ if i < 0 {
+ return fmt.Errorf("package URL %q has no file name", pkgURL)
+ }
+ base, name := pkgURL[:i], pkgURL[i+1:]
+ dir, err := os.MkdirTemp(a.stageDir(), "verify-")
+ if err != nil {
+ return err
+ }
+ defer os.RemoveAll(dir)
+ for _, f := range []string{"checksums.txt", "checksums.txt.sig", releaseKeyAsset} {
+ if err := a.download(ctx, base+"/"+f, filepath.Join(dir, f)); err != nil {
+ return fmt.Errorf("download %s: %w", f, err)
+ }
+ }
+ sums := filepath.Join(dir, "checksums.txt")
+ // Status is read from stdout alone, because stderr repeats the key's user ID and the release
+ // supplies the key.
+ var stderr strings.Builder
+ cmd := exec.CommandContext(ctx, "gpgv", "--homedir", dir, "--keyring", filepath.Join(dir, releaseKeyAsset),
+ "--status-fd", "1", filepath.Join(dir, "checksums.txt.sig"), sums)
+ cmd.Stderr = &stderr
+ out, err := cmd.Output()
+ if err != nil {
+ return fmt.Errorf("checksums.txt signature does not verify: %v: %s", err, strings.TrimSpace(stderr.String()))
+ }
+ if !validSigFrom(string(out), releaseKeyFingerprints) {
+ return fmt.Errorf("checksums.txt is not signed by a Beacon release key (%s)", strings.Join(releaseKeyFingerprints, ", "))
+ }
+ want, err := checksumFor(sums, name)
+ if err != nil {
+ return err
+ }
+ return verifySHA256(pkgPath, want)
+}
+
+// validSigFrom reports whether gpgv's status output has a good signature whose primary key is one
+// of fingerprints. VALIDSIG ends with the primary key's fingerprint, so a signing subkey counts.
+func validSigFrom(status string, fingerprints []string) bool {
+ for _, line := range strings.Split(status, "\n") {
+ f := strings.Fields(line)
+ if len(f) < 3 || f[0] != "[GNUPG:]" || f[1] != "VALIDSIG" {
+ continue
+ }
+ for _, fpr := range fingerprints {
+ if strings.EqualFold(f[len(f)-1], fpr) {
+ return true
+ }
+ }
+ }
+ return false
+}
+
+func checksumFor(path, name string) (string, error) {
+ data, err := os.ReadFile(path)
+ if err != nil {
+ return "", err
+ }
+ var found []string
+ for _, line := range strings.Split(string(data), "\n") {
+ f := strings.Fields(line)
+ if len(f) == 2 && strings.TrimPrefix(f[1], "*") == name {
+ found = append(found, f[0])
+ }
+ }
+ if len(found) != 1 {
+ return "", fmt.Errorf("signed checksums.txt has %d entries for %s, want 1", len(found), name)
+ }
+ return found[0], nil
+}
diff --git a/cli/beacon/internal/endpoint/selfupdate/linuxsig_test.go b/cli/beacon/internal/endpoint/selfupdate/linuxsig_test.go
new file mode 100644
index 00000000..ff359c25
--- /dev/null
+++ b/cli/beacon/internal/endpoint/selfupdate/linuxsig_test.go
@@ -0,0 +1,59 @@
+package selfupdate
+
+import (
+ "context"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "strings"
+ "testing"
+)
+
+// testdata/signed-release is a release signed by a throwaway test key with this fingerprint.
+const testReleaseKeyFingerprint = "492264C703AE4B306CF804C9E0F25BE9BE03411C"
+
+func TestVerifyReleaseSignature(t *testing.T) {
+ if runtime.GOOS != "linux" {
+ t.Skip("release signatures are verified on Linux only")
+ }
+ if _, err := exec.LookPath("gpgv"); err != nil {
+ t.Skip("gpgv is not installed")
+ }
+ tampered := false
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ data, err := os.ReadFile(filepath.Join("testdata", "signed-release", filepath.Base(r.URL.Path)))
+ if err != nil {
+ http.NotFound(w, r)
+ return
+ }
+ if tampered && strings.HasSuffix(r.URL.Path, "/checksums.txt") {
+ data = []byte(strings.Replace(string(data), "ffff", "eeee", 1))
+ }
+ w.Write(data)
+ }))
+ defer srv.Close()
+
+ old := releaseKeyFingerprints
+ releaseKeyFingerprints = []string{testReleaseKeyFingerprint}
+ defer func() { releaseKeyFingerprints = old }()
+ verify := func() error {
+ a := NewApplier("1.0.0")
+ a.StageDir = t.TempDir()
+ pkg := filepath.Join(t.TempDir(), "download.deb")
+ if err := os.WriteFile(pkg, []byte("package\n"), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ return a.verifyReleaseSignature(context.Background(), srv.URL+"/v1.0.0/beacon_1.0.0_linux_amd64.deb", pkg)
+ }
+
+ if err := verify(); err != nil {
+ t.Fatalf("validly signed package refused: %v", err)
+ }
+ tampered = true
+ if err := verify(); err == nil {
+ t.Fatal("tampered checksums.txt accepted")
+ }
+}
diff --git a/cli/beacon/internal/endpoint/selfupdate/release-key.fingerprint b/cli/beacon/internal/endpoint/selfupdate/release-key.fingerprint
new file mode 100644
index 00000000..e69de29b
diff --git a/cli/beacon/internal/endpoint/selfupdate/testdata/signed-release/beacon-release-key.gpg b/cli/beacon/internal/endpoint/selfupdate/testdata/signed-release/beacon-release-key.gpg
new file mode 100644
index 00000000..d2cc0b80
Binary files /dev/null and b/cli/beacon/internal/endpoint/selfupdate/testdata/signed-release/beacon-release-key.gpg differ
diff --git a/cli/beacon/internal/endpoint/selfupdate/testdata/signed-release/beacon_1.0.0_linux_amd64.deb b/cli/beacon/internal/endpoint/selfupdate/testdata/signed-release/beacon_1.0.0_linux_amd64.deb
new file mode 100644
index 00000000..ba3bd787
--- /dev/null
+++ b/cli/beacon/internal/endpoint/selfupdate/testdata/signed-release/beacon_1.0.0_linux_amd64.deb
@@ -0,0 +1 @@
+package
diff --git a/cli/beacon/internal/endpoint/selfupdate/testdata/signed-release/checksums.txt b/cli/beacon/internal/endpoint/selfupdate/testdata/signed-release/checksums.txt
new file mode 100644
index 00000000..acfc9193
--- /dev/null
+++ b/cli/beacon/internal/endpoint/selfupdate/testdata/signed-release/checksums.txt
@@ -0,0 +1,2 @@
+4e9416efcf77b84013f263e1f9008c656861298be5aabc82f458e6e47c60d9ff beacon_1.0.0_linux_amd64.deb
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff beacon_1.0.0_linux_amd64.rpm
diff --git a/cli/beacon/internal/endpoint/selfupdate/testdata/signed-release/checksums.txt.sig b/cli/beacon/internal/endpoint/selfupdate/testdata/signed-release/checksums.txt.sig
new file mode 100644
index 00000000..8f7b0ce3
Binary files /dev/null and b/cli/beacon/internal/endpoint/selfupdate/testdata/signed-release/checksums.txt.sig differ
diff --git a/docs/platforms/linux.mdx b/docs/platforms/linux.mdx
index 264e7caf..45556601 100644
--- a/docs/platforms/linux.mdx
+++ b/docs/platforms/linux.mdx
@@ -259,7 +259,25 @@ sudo beacon endpoint update --check
sudo beacon endpoint update --apply
```
-`--apply` downloads the release package for your platform, verifies its SHA-256, installs it with `dpkg` or `rpm`, restarts the collector, and rolls back if the new version fails its health check. Verification is checksum-over-HTTPS from GitHub Releases, the same trust root you used to download the package in the first place. macOS additionally verifies Apple notarization; Linux has no OS-level equivalent, and `beacon endpoint update` reports which verification it performed rather than implying both.
+`--apply` downloads the release package for your platform, verifies its SHA-256, installs it with `dpkg` or `rpm`, restarts the collector, and rolls back if the new version fails its health check. Verification is checksum-over-HTTPS from GitHub Releases, the same trust root you used to download the package in the first place. macOS additionally verifies Apple notarization. On Linux, once a build pins the release key (see [Release signing](#release-signing)), the package must also be listed in a `checksums.txt` signed by that key, which needs `gpgv`. `beacon endpoint update` reports which verification it performed (`sha256`, `sha256+gpg` or `sha256+notarization`) rather than implying more.
+
+## Release signing
+
+Signing is wired into the release but not yet active: Beacon has no Linux release key yet, so current `.deb`, `.rpm` and `checksums.txt` files are unsigned, and the installer and `beacon endpoint update` check checksums only. This section applies once a release publishes the key.
+
+A signed release carries `checksums.txt.sig` (a detached OpenPGP signature over `checksums.txt`) and the public key as `beacon-release-key.asc` and `beacon-release-key.gpg`. The `.rpm` carries an RPM signature and the `.deb` a `_gpgorigin` signature member, both from the same key. Release key fingerprint: _not yet published_.
+
+The installer and the self-updater pin that fingerprint. They take the key from the release but trust it only if its fingerprint matches, and they refuse a package whose `checksums.txt` is unsigned, signed by another key, or does not list the package. To check a download yourself:
+
+```bash title="Verify a signed release"
+FPR="<release key fingerprint>"
+curl -fsSLO "${BASE}/checksums.txt.sig" && curl -fsSLO "${BASE}/beacon-release-key.gpg" && curl -fsSLO "${BASE}/beacon-release-key.asc"
+test "$(gpg --show-keys --with-colons beacon-release-key.asc | awk -F: '$1 == "fpr" { print $10; exit }')" = "$FPR" && \
+ gpgv --keyring "$PWD/beacon-release-key.gpg" checksums.txt.sig checksums.txt
+sudo rpm --import beacon-release-key.asc && rpm -K "${PKG}" # .rpm
+```
+
+Rotation: one release pins both the old and the new fingerprint and is still signed by the old key; the release after it is signed by the new key and drops the old pin. Installed agents therefore trust the new key before they need it. The new fingerprint is published here and in the release notes of the release that first pins it.
Upgrading the package keeps your configuration and your collected log.
diff --git a/packaging/linux/install.sh b/packaging/linux/install.sh
index 0df04a37..4da2858f 100755
--- a/packaging/linux/install.sh
+++ b/packaging/linux/install.sh
@@ -4,7 +4,8 @@
# curl -fsSL https://github.com/asymptote-labs/agent-beacon/releases/latest/download/install.sh | bash
#
# Downloads the .deb or .rpm for this machine's architecture, checks it against
-# the release checksums.txt, and installs it with apt-get or dnf/yum so package
+# the release checksums.txt (and its signature, once a release key is pinned
+# below), and installs it with apt-get or dnf/yum so package
# dependencies resolve. Set BEACON_VERSION (for example 1.3.24 or v1.3.24) to
# install a specific release instead of the latest.
#
@@ -16,6 +17,12 @@ set -euo pipefail
repo="asymptote-labs/agent-beacon"
+# Comma-separated OpenPGP fingerprints of the Beacon release keys. The release copy of
+# this script is stamped from cli/beacon/internal/endpoint/selfupdate/release-key.fingerprint.
+# While it is empty, packages are checked against checksums.txt alone; once set, only
+# against a checksums.txt signed by one of those keys.
+release_key_fingerprints=
+
fail() {
echo "beacon install: $*" >&2
exit 1
@@ -73,6 +80,20 @@ echo "Installing Beacon ${tag} (${arch}, .${format})..."
curl -fsSL "${base}/${package}" -o "${tmp}/${package}"
curl -fsSL "${base}/checksums.txt" -o "${tmp}/checksums.txt"
+if [[ -n "$release_key_fingerprints" ]]; then
+ command -v gpgv >/dev/null 2>&1 || fail "gpgv is needed to verify the release signature; install gpgv or gnupg and rerun."
+ curl -fsSL "${base}/checksums.txt.sig" -o "${tmp}/checksums.txt.sig" || fail "${tag} has no checksums.txt.sig."
+ curl -fsSL "${base}/beacon-release-key.gpg" -o "${tmp}/beacon-release-key.gpg" || fail "${tag} has no beacon-release-key.gpg."
+ mkdir -m 0700 "${tmp}/gnupg"
+ status="$(gpgv --homedir "${tmp}/gnupg" --keyring "${tmp}/beacon-release-key.gpg" --status-fd 1 \
+ "${tmp}/checksums.txt.sig" "${tmp}/checksums.txt" 2>/dev/null)" || fail "checksums.txt signature does not verify."
+ # The key file comes from the release too, so only the pinned fingerprint makes it Beacon's.
+ awk -v fprs="$release_key_fingerprints" 'BEGIN { n = split(toupper(fprs), pinned, ",") }
+ $1 == "[GNUPG:]" && $2 == "VALIDSIG" { for (i = 1; i <= n; i++) if (toupper($NF) == pinned[i]) ok = 1 }
+ END { exit !ok }' <<<"$status" ||
+ fail "checksums.txt is not signed by a Beacon release key (${release_key_fingerprints})."
+fi
+
checksum="$(awk -v name="$package" '$2 == name { print $1 }' "${tmp}/checksums.txt")"
[[ "$checksum" =~ ^[0-9a-fA-F]{64}$ ]] || fail "no unique SHA-256 checksum for ${package} in checksums.txt."
(cd "$tmp" && printf '%s %s\n' "$checksum" "$package" | sha256sum --check --quiet -) || fail "checksum mismatch for ${package}."