Skip to content

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

security: pin self-update to Beacon's signing team and to https (#811)

Justin D'Souzabcdb44b9f24a
diff --git a/cli/beacon/internal/endpoint/edition/edition.go b/cli/beacon/internal/endpoint/edition/edition.go
index 22cf16c2..ef302101 100644
--- a/cli/beacon/internal/endpoint/edition/edition.go
+++ b/cli/beacon/internal/endpoint/edition/edition.go
@@ -32,9 +32,6 @@ const (
Enterprise = "enterprise"
// DownloadPath is the platform route that answers with a package for a device key.
DownloadPath = "/api/cli/enforcement/download"
- // AppleTeamID is the Apple Developer team that signs every Beacon package. Pinned here
- // rather than taken from the platform's answer.
- AppleTeamID = "3A98D35XJR"
requestTimeout = 30 * time.Second
maxAnswer = 64 << 10
@@ -133,7 +130,6 @@ func Install(ctx context.Context, rel Release, currentVersion, logPath string) (
URL: rel.URL,
SHA256: rel.SHA256,
Version: rel.Version,
- TeamID: AppleTeamID,
Edition: Enterprise,
})
}
diff --git a/cli/beacon/internal/endpoint/selfupdate/apply.go b/cli/beacon/internal/endpoint/selfupdate/apply.go
index ede44b1c..bfb4d808 100644
--- a/cli/beacon/internal/endpoint/selfupdate/apply.go
+++ b/cli/beacon/internal/endpoint/selfupdate/apply.go
@@ -11,6 +11,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "regexp"
"runtime"
"strings"
"time"
@@ -152,7 +153,7 @@ func (a *Applier) Apply(ctx context.Context) (ApplyResult, error) {
a.emit(false, result, fmt.Sprintf("no update artifact this host can install (looked for %s)", key))
return result, fmt.Errorf("no update artifact this host can install (looked for %s)", key)
}
- pkg := Package{URL: artifact.URL, SHA256: artifact.SHA256, Version: manifest.Version, TeamID: manifest.TeamID}
+ pkg := Package{URL: artifact.URL, SHA256: artifact.SHA256, Version: manifest.Version}
return a.installPackage(ctx, pkg, result, fmt.Sprintf("updated %s -> %s", a.CurrentVersion, manifest.Version))
}
@@ -162,9 +163,6 @@ type Package struct {
URL string
SHA256 string
Version string
- // TeamID is the Apple team that must have signed the package. Empty skips only the team
- // match; the signature and Gatekeeper checks still run.
- TeamID string
// Edition, when set, must be the edition the installed `beacon version` reports.
Edition string
}
@@ -184,9 +182,6 @@ func (a *Applier) InstallPackage(ctx context.Context, pkg Package) (ApplyResult,
if !updatecheck.CanCheckVersion(pkg.Version) {
return result, fmt.Errorf("package version %q is not a release version", pkg.Version)
}
- if !a.AllowInsecureTest && !strings.HasPrefix(pkg.URL, "https://") {
- return result, fmt.Errorf("refusing to download a package over %q: https is required", pkg.URL)
- }
message := "installed " + pkg.Version
if pkg.Edition != "" {
message += ", " + pkg.Edition + " edition"
@@ -241,7 +236,7 @@ func (a *Applier) installPackage(ctx context.Context, pkg Package, result ApplyR
result.Verification = "sha256 (notarization check skipped)"
default:
result.Verification = "sha256+notarization"
- if err := a.verifyGatekeeper(ctx, pkgPath, pkg.TeamID); err != nil {
+ if err := a.verifyGatekeeper(ctx, pkgPath); err != nil {
a.emit(false, result, err.Error())
return result, fmt.Errorf("verify signature/notarization: %w", err)
}
@@ -381,6 +376,10 @@ func (a *Applier) download(ctx context.Context, url, dest string) error {
if client == nil {
client = &http.Client{Timeout: 10 * time.Minute}
}
+ if err := updatecheck.RequireSecureURL(url); err != nil {
+ return err
+ }
+ client = updatecheck.SecureRedirects(client)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
if err != nil {
return err
@@ -426,18 +425,24 @@ func verifySHA256(path, want string) error {
return nil
}
-// verifyGatekeeper confirms the .pkg is Developer ID Installer-signed and
-// accepted by Gatekeeper before it is run. stapler validation is best-effort:
-// endpoint machines commonly have only Command Line Tools installed, where the
+// AppleTeamID is the Apple Developer team that signs every Beacon package. It is compiled in, not
+// taken from the update manifest or a platform answer: neither is signed, so a team named there
+// would let whoever can rewrite it pick the signer of a package the updater installs as root.
+const AppleTeamID = "3A98D35XJR"
+
+// verifyGatekeeper confirms the .pkg is signed by Beacon's Developer ID Installer certificate and
+// accepted by Gatekeeper before it is run. Notarization alone only says some Developer ID signed
+// it, so the installer signer's team must be AppleTeamID exactly. stapler validation is
+// best-effort: endpoint machines commonly have only Command Line Tools installed, where the
// stapler shim exists but refuses to run without full Xcode.
-func (a *Applier) verifyGatekeeper(ctx context.Context, pkgPath, teamID string) error {
+func (a *Applier) verifyGatekeeper(ctx context.Context, pkgPath string) error {
run := a.runner()
out, err := run(ctx, "pkgutil", "--check-signature", pkgPath)
if err != nil {
return fmt.Errorf("pkgutil --check-signature: %s: %w", strings.TrimSpace(out), err)
}
- if teamID != "" && !strings.Contains(out, teamID) {
- return fmt.Errorf("package signature does not match expected team id %s", teamID)
+ if signer := installerSignerTeamID(out); signer != AppleTeamID {
+ return fmt.Errorf("package is signed by team %q, want %s", signer, AppleTeamID)
}
if out, err := run(ctx, "stapler", "validate", pkgPath); err != nil {
if !staplerUnavailable(out, err) {
@@ -450,6 +455,17 @@ func (a *Applier) verifyGatekeeper(ctx context.Context, pkgPath, teamID string)
return nil
}
+var installerSignerPattern = regexp.MustCompile(`Developer ID Installer: [^\n]*\(([A-Z0-9]+)\)`)
+
+// installerSignerTeamID is the team id in the leaf "Developer ID Installer: Name (TEAMID)" line of
+// pkgutil --check-signature output, or "" when there is none.
+func installerSignerTeamID(out string) string {
+ if m := installerSignerPattern.FindStringSubmatch(out); m != nil {
+ return m[1]
+ }
+ return ""
+}
+
func staplerUnavailable(out string, err error) bool {
msg := strings.ToLower(strings.TrimSpace(out + " " + err.Error()))
return strings.Contains(msg, "requires xcode") ||
diff --git a/cli/beacon/internal/endpoint/selfupdate/apply_test.go b/cli/beacon/internal/endpoint/selfupdate/apply_test.go
index 0d27f121..12822403 100644
--- a/cli/beacon/internal/endpoint/selfupdate/apply_test.go
+++ b/cli/beacon/internal/endpoint/selfupdate/apply_test.go
@@ -346,7 +346,7 @@ func TestVerifyGatekeeperSkipsUnavailableStapler(t *testing.T) {
calls = append(calls, name)
switch name {
case "pkgutil":
- return "Developer ID Installer: Example (TEAMID)", nil
+ return "Developer ID Installer: Example (" + AppleTeamID + ")", nil
case "stapler":
return "xcode-select: error: tool 'stapler' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance", fmt.Errorf("exit status 1")
case "spctl":
@@ -356,7 +356,7 @@ func TestVerifyGatekeeperSkipsUnavailableStapler(t *testing.T) {
}
}
- if err := a.verifyGatekeeper(context.Background(), filepath.Join(t.TempDir(), "Beacon.pkg"), "TEAMID"); err != nil {
+ if err := a.verifyGatekeeper(context.Background(), filepath.Join(t.TempDir(), "Beacon.pkg")); err != nil {
t.Fatalf("verifyGatekeeper should skip unavailable stapler, got %v", err)
}
if strings.Join(calls, ",") != "pkgutil,stapler,spctl" {
@@ -369,7 +369,7 @@ func TestVerifyGatekeeperFailsStaplerValidationFailure(t *testing.T) {
a.run = func(ctx context.Context, name string, args ...string) (string, error) {
switch name {
case "pkgutil":
- return "Developer ID Installer: Example (TEAMID)", nil
+ return "Developer ID Installer: Example (" + AppleTeamID + ")", nil
case "stapler":
return "The validate action worked! The staple and validate action failed!", fmt.Errorf("exit status 65")
default:
@@ -377,7 +377,7 @@ func TestVerifyGatekeeperFailsStaplerValidationFailure(t *testing.T) {
}
}
- err := a.verifyGatekeeper(context.Background(), filepath.Join(t.TempDir(), "Beacon.pkg"), "TEAMID")
+ err := a.verifyGatekeeper(context.Background(), filepath.Join(t.TempDir(), "Beacon.pkg"))
if err == nil || !strings.Contains(err.Error(), "stapler validate") {
t.Fatalf("verifyGatekeeper error = %v, want stapler validation failure", err)
}
@@ -405,7 +405,7 @@ func TestApplyRestartsCollectorBeforeHealthCheck(t *testing.T) {
a.run = func(ctx context.Context, name string, args ...string) (string, error) {
switch filepath.Base(name) {
case "pkgutil":
- return "Developer ID Installer: Example (TEAMID)", nil
+ return "Developer ID Installer: Example (" + AppleTeamID + ")", nil
case "stapler", "spctl", "installer", "dpkg", "rpm":
return "", nil
case "beacon":
@@ -787,7 +787,7 @@ func TestApplyRollbackRestoresScriptForwarders(t *testing.T) {
a.run = func(ctx context.Context, name string, args ...string) (string, error) {
switch filepath.Base(name) {
case "pkgutil":
- return "Developer ID Installer: Example (TEAMID)", nil
+ return "Developer ID Installer: Example (" + AppleTeamID + ")", nil
case "installer", "dpkg", "rpm":
return "postinstall failed", fmt.Errorf("exit status 1")
default:
diff --git a/cli/beacon/internal/endpoint/selfupdate/install_package_test.go b/cli/beacon/internal/endpoint/selfupdate/install_package_test.go
index 9bf76599..975af776 100644
--- a/cli/beacon/internal/endpoint/selfupdate/install_package_test.go
+++ b/cli/beacon/internal/endpoint/selfupdate/install_package_test.go
@@ -142,8 +142,8 @@ func TestInstallPackageRefusesBeforeDownloading(t *testing.T) {
want string
}{
"plain http": {
- pkg: Package{URL: srv.URL + "/artifact.tar.gz", SHA256: sha, Version: "1.3.41"},
- want: "https is required",
+ pkg: Package{URL: "http://updates.example.com/artifact.tar.gz", SHA256: sha, Version: "1.3.41"},
+ want: "non-https",
},
"not a release version": {
insecure: true,
@@ -166,7 +166,7 @@ func TestInstallPackageRefusesBeforeDownloading(t *testing.T) {
}
}
-func TestInstallPackageChecksTheTeamItWasGiven(t *testing.T) {
+func TestInstallPackageRequiresBeaconsSigningTeam(t *testing.T) {
if runtime.GOOS != "darwin" {
t.Skip("Gatekeeper verification is macOS-only")
}
@@ -190,9 +190,9 @@ func TestInstallPackageChecksTheTeamItWasGiven(t *testing.T) {
return "", fmt.Errorf("%s must not run", name)
}
_, err := a.InstallPackage(context.Background(), Package{
- URL: srv.URL + "/artifact.pkg", SHA256: sha, Version: "1.3.41", TeamID: "3A98D35XJR",
+ URL: srv.URL + "/artifact.pkg", SHA256: sha, Version: "1.3.41",
})
- if err == nil || !strings.Contains(err.Error(), "expected team id 3A98D35XJR") {
+ if err == nil || !strings.Contains(err.Error(), "want "+AppleTeamID) {
t.Fatalf("err = %v", err)
}
if strings.Join(calls, ",") != "pkgutil" {
diff --git a/cli/beacon/internal/endpoint/selfupdate/trust_test.go b/cli/beacon/internal/endpoint/selfupdate/trust_test.go
new file mode 100644
index 00000000..a5456c51
--- /dev/null
+++ b/cli/beacon/internal/endpoint/selfupdate/trust_test.go
@@ -0,0 +1,70 @@
+package selfupdate
+
+import (
+ "context"
+ "net/http"
+ "net/http/httptest"
+ "path/filepath"
+ "strings"
+ "testing"
+
+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/updatecheck"
+)
+
+func signedBy(team string) runnerFunc {
+ return func(ctx context.Context, name string, args ...string) (string, error) {
+ if name == "pkgutil" {
+ return "Status: signed by a developer certificate issued by Apple for distribution\nCertificate Chain:\n 1. Developer ID Installer: Example (" + team + ")\n 2. Developer ID Certification Authority\n 3. Apple Root CA", nil
+ }
+ return "", nil
+ }
+}
+
+// The installer signer must be Beacon's team exactly. Notarization alone only says some Developer
+// ID signed the package, and the team the unsigned manifest names cannot widen that.
+func TestVerifyGatekeeperRequiresBeaconsTeamExactly(t *testing.T) {
+ a := NewApplier("0.0.1")
+ pkg := filepath.Join(t.TempDir(), "Beacon.pkg")
+ for _, signer := range []string{"OTHERTEAM1", AppleTeamID + "X", "X" + AppleTeamID, ""} {
+ a.run = signedBy(signer)
+ if err := a.verifyGatekeeper(context.Background(), pkg); err == nil {
+ t.Fatalf("package signed by %q accepted", signer)
+ }
+ }
+ a.run = signedBy(AppleTeamID)
+ if err := a.verifyGatekeeper(context.Background(), pkg); err != nil {
+ t.Fatalf("package signed by Beacon's team refused: %v", err)
+ }
+}
+
+func TestDownloadRefusesInsecureURLs(t *testing.T) {
+ a := NewApplier("0.0.1")
+ dest := filepath.Join(t.TempDir(), "pkg")
+ if err := a.download(context.Background(), "http://updates.example.com/beacon.pkg", dest); err == nil {
+ t.Fatal("download accepted a plain http URL")
+ }
+ plain := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ http.Redirect(w, r, "http://updates.example.com/beacon.pkg", http.StatusFound)
+ }))
+ defer plain.Close()
+ if err := a.download(context.Background(), plain.URL, dest); err == nil || !strings.Contains(err.Error(), "non-https") {
+ t.Fatalf("download followed a redirect onto plain http: %v", err)
+ }
+}
+
+func TestRequireSecureURL(t *testing.T) {
+ for raw, ok := range map[string]bool{
+ "https://github.com/x": true,
+ "http://127.0.0.1:8080/": true,
+ "http://localhost/x": true,
+ "http://[::1]/x": true,
+ "http://example.com/x": false,
+ "ftp://example.com/x": false,
+ "https:///x": false,
+ "file:///etc/passwd": false,
+ } {
+ if err := updatecheck.RequireSecureURL(raw); (err == nil) != ok {
+ t.Errorf("RequireSecureURL(%q) = %v, want ok=%v", raw, err, ok)
+ }
+ }
+}
diff --git a/cli/beacon/internal/updatecheck/manifest.go b/cli/beacon/internal/updatecheck/manifest.go
index 8d0e4534..0ce53bd5 100644
--- a/cli/beacon/internal/updatecheck/manifest.go
+++ b/cli/beacon/internal/updatecheck/manifest.go
@@ -5,7 +5,9 @@ import (
"encoding/json"
"fmt"
"io"
+ "net"
"net/http"
+ "net/url"
"os"
"runtime"
"strings"
@@ -32,11 +34,13 @@ type Artifact struct {
// UpdateManifest is the small JSON document published as a release asset that
// tells an installed agent what the latest version is and where to fetch it.
+// The release still writes a team_id for updaters older than the compiled-in
+// pin (selfupdate.AppleTeamID); this one ignores it, since the manifest is not
+// signed.
type UpdateManifest struct {
Schema int `json:"schema"`
Version string `json:"version"`
MinSupportedVersion string `json:"min_supported_version,omitempty"`
- TeamID string `json:"team_id,omitempty"`
PkgIdentifier string `json:"pkg_identifier,omitempty"`
Artifacts map[string]Artifact `json:"artifacts"`
}
@@ -102,6 +106,10 @@ func (s ManifestSource) Fetch(ctx context.Context) (UpdateManifest, error) {
client = http.DefaultClient
}
+ if err := RequireSecureURL(endpoint); err != nil {
+ return UpdateManifest{}, fmt.Errorf("update manifest: %w", err)
+ }
+ client = SecureRedirects(client)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
if err != nil {
return UpdateManifest{}, err
@@ -168,3 +176,49 @@ func EvaluateManifest(current string, m UpdateManifest) (ManifestResult, error)
}
return result, nil
}
+
+// RequireSecureURL refuses a URL an update could be fetched from unless it is https, or plain http
+// to a loopback host (a local mirror or a test server). The manifest and the package it names drive
+// a root install, so neither may come over a connection anyone on the path can rewrite.
+func RequireSecureURL(raw string) error {
+ u, err := url.Parse(strings.TrimSpace(raw))
+ if err != nil {
+ return err
+ }
+ switch strings.ToLower(u.Scheme) {
+ case "https":
+ if u.Host == "" {
+ return fmt.Errorf("%q has no host", raw)
+ }
+ return nil
+ case "http":
+ host := u.Hostname()
+ if host == "localhost" {
+ return nil
+ }
+ if ip := net.ParseIP(host); ip != nil && ip.IsLoopback() {
+ return nil
+ }
+ }
+ return fmt.Errorf("refusing non-https update URL %q", raw)
+}
+
+// SecureRedirects returns a copy of client that follows a redirect only to a URL RequireSecureURL
+// accepts, so an https request cannot be redirected onto plain http.
+func SecureRedirects(client *http.Client) *http.Client {
+ copied := *client
+ next := client.CheckRedirect
+ copied.CheckRedirect = func(req *http.Request, via []*http.Request) error {
+ if err := RequireSecureURL(req.URL.String()); err != nil {
+ return err
+ }
+ if next != nil {
+ return next(req, via)
+ }
+ if len(via) >= 10 {
+ return fmt.Errorf("stopped after 10 redirects")
+ }
+ return nil
+ }
+ return &copied
+}
diff --git a/cli/beacon/internal/updatecheck/manifest_test.go b/cli/beacon/internal/updatecheck/manifest_test.go
index 937e6822..bdf9f8bb 100644
--- a/cli/beacon/internal/updatecheck/manifest_test.go
+++ b/cli/beacon/internal/updatecheck/manifest_test.go
@@ -27,7 +27,7 @@ func TestParseManifest(t *testing.T) {
if m.Version != "0.0.69" {
t.Fatalf("version = %q", m.Version)
}
- if m.TeamID != "TEAMID" || m.PkgIdentifier != "ai.asymptote.beacon.endpoint" {
+ if m.PkgIdentifier != "ai.asymptote.beacon.endpoint" {
t.Fatalf("metadata not parsed: %+v", m)
}
a, ok := m.ArtifactFor("darwin_arm64")
diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdx
index 6246bfba..aa5d4d7e 100644
--- a/docs/changelog/cli.mdx
+++ b/docs/changelog/cli.mdx
@@ -11,6 +11,7 @@ Stay up to date with the latest changes to the Agent Beacon CLI.
## October 2026
+- **Self-update installs only Beacon-signed packages, over https** · The macOS self-updater took the Apple team a package must be signed by from `update-manifest.json`, which is unsigned, matched it as a substring of the signature output, and skipped the check when the manifest named no team. Whoever could rewrite the manifest could have any notarized package installed as root. The team is now built into `beacon` (Asymptote Labs, `3A98D35XJR`) and must match the package's installer signer exactly, for self-update and the enterprise edition install alike. The manifest and the package must also be fetched over `https`, plain `http` only to a loopback mirror and never through a redirect, so a `managed.json` that names an `http://` update URL on another host stops updating until it is changed to `https`.
- **The scheduled inventory job follows every moved runtime directory** · The job starts without your shell's environment, so a per-user install or repair records the variables that move a runtime's user directory into it. It recorded `CODEX_HOME`, `HERMES_HOME`, `CLINE_DIR`, `GEMINI_CLI_HOME` and `CLAUDE_CONFIG_DIR`, and now also `KIRO_HOME`, `KIMI_CODE_HOME`, `DSH_HOME`, `OH_PERSISTENCE_DIR`, `OPENCLAW_STATE_DIR`, `XDG_CONFIG_HOME` (Muse, and VS Code on Linux), `PI_CODING_AGENT_DIR`, `OMO_CODING_AGENT_DIR`, `SENPI_CODING_AGENT_DIR`, `PRIME_AGENT_CODING_AGENT_DIR`, and Oh My Pi's `PI_CONFIG_DIR`, `OMP_PROFILE` and `PI_PROFILE`. With one of these set only in your shell, the job used to inventory the default directory while the runtime read the moved one. See [Inventory heartbeats](/cli/endpoint-inventory#inventory-heartbeats).
- **Pi extension follows `PI_CODING_AGENT_DIR`** · `beacon endpoint hooks install --harness pi`, `beacon endpoint discover` and inventory now use `$PI_CODING_AGENT_DIR/extensions/beacon.ts` when `PI_CODING_AGENT_DIR` is set, as Pi does, including a leading `~`. They previously always used `~/.pi/agent`, so with the variable set the extension went where Pi never loads it while discovery reported Pi as enabled, and live capture silently recorded nothing. Session status and sync already followed the variable; all of them now resolve the directory the same way.
diff --git a/docs/cli/upgrade.mdx b/docs/cli/upgrade.mdx
index cd95acdb..2a66087c 100644
--- a/docs/cli/upgrade.mdx
+++ b/docs/cli/upgrade.mdx
@@ -44,6 +44,10 @@ Behind the scenes, `beacon endpoint update` reads `update-manifest.json`, select
the package artifact for the local architecture, downloads it into the endpoint
update staging directory, verifies the manifest checksum, Developer ID Installer
signature, and Gatekeeper install assessment, then runs Apple's `installer`. The
+package's installer signature must come from Asymptote Labs' Apple team
+(`3A98D35XJR`), which is built into `beacon` rather than read from the unsigned
+manifest, and both the manifest and the package must be fetched over `https`
+(plain `http` only to a loopback mirror, and never through a redirect). The
package postinstall restarts the local collector, restores configured Vector
forwarders, re-renders a connected endpoint's Beacon Cloud forwarder config from
the new version's pack (see [Keeping the forwarder config current](/cli/endpoint-connect#keeping-the-forwarder-config-current)),