The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
share: honor a system-mode Metadata-only connection the user cannot read
shukieshahd509e4c994ff
diff --git a/cli/beacon/cmd/share_auto.go b/cli/beacon/cmd/share_auto.goindex e302aea6..e2a1aeb8 100644--- a/cli/beacon/cmd/share_auto.go+++ b/cli/beacon/cmd/share_auto.go@@ -5,12 +5,15 @@ import ("errors""fmt""io"+ "io/fs"+ "os""path/filepath""strings""github.com/spf13/cobra""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/asymptote"+ endpointconfig "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/config""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/managedprivacy""github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve""github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve/shareauto"@@ -23,21 +26,61 @@ import (// to Beacon Cloud the setting does nothing but write that event; enable says so.// shareAutoCloud reports whether this endpoint forwards to Beacon Cloud (user or system mode) and-// with which privacy mode. A seam for tests.+// with which privacy mode. Sharing strips content when the mode is Metadata-only, so whenever the+// mode cannot be read it is reported as Metadata-only rather than Standard. A seam for tests.var shareAutoCloud = func() (connected bool, privacyMode string) {for _, userMode := range []bool{true, false} {- if !asymptote.Connected(userMode) {- continue+ if asymptote.Connected(userMode) {+ return true, enrolledPrivacyMode(userMode)}- mode := managedprivacy.Standard- if enrollment, err := asymptote.LoadEnrollment(userMode); err == nil && enrollment.PrivacyMode != "" {- if normalized, err := managedprivacy.Normalize(enrollment.PrivacyMode); err == nil {- mode = normalized- }- }- return true, mode}- return false, ""+ return unreadableCloudConnection(asymptote.EnrollmentPath(false), endpointconfig.SystemConfigPath())+}++// enrolledPrivacyMode is the privacy mode a connected endpoint's enrollment records.+func enrolledPrivacyMode(userMode bool) string {+ enrollment, err := asymptote.LoadEnrollment(userMode)+ if err != nil {+ return managedprivacy.MetadataOnly+ }+ return recordedPrivacyMode(enrollment.PrivacyMode)+}++// recordedPrivacyMode reads a stored privacy mode. None means the record predates the setting,+// when every endpoint forwarded in Standard mode; one Beacon does not know is Metadata-only.+func recordedPrivacyMode(value string) string {+ if strings.TrimSpace(value) == "" {+ return managedprivacy.Standard+ }+ mode, err := managedprivacy.Normalize(value)+ if err != nil {+ return managedprivacy.MetadataOnly+ }+ return mode+}++// unreadableCloudConnection covers a system-mode connection the person running the command cannot+// see. The system enrollment is in a directory only root can read, so `beacon share`, `--follow`+// and the git pre-push hook, which run as the signed-in user, get a permission error where root+// would find it. The managed_ingest block of the system config.json, which everyone can read, then+// says whether the endpoint forwards and in which privacy mode, and a config that cannot be read+// either counts as a Metadata-only connection.+func unreadableCloudConnection(enrollmentPath, configPath string) (bool, string) {+ if _, err := os.Stat(enrollmentPath); !errors.Is(err, fs.ErrPermission) {+ return false, ""+ }+ data, err := os.ReadFile(configPath)+ if err != nil {+ return true, managedprivacy.MetadataOnly+ }+ var cfg endpointconfig.Config+ if err := json.Unmarshal(data, &cfg); err != nil {+ return true, managedprivacy.MetadataOnly+ }+ if cfg.ManagedIngest == nil || !cfg.ManagedIngest.Enabled {+ return false, ""+ }+ return true, recordedPrivacyMode(cfg.ManagedIngest.PrivacyMode)}type shareAutoOptions struct {diff --git a/cli/beacon/cmd/share_auto_test.go b/cli/beacon/cmd/share_auto_test.goindex 8139d1a7..38f1cbee 100644--- a/cli/beacon/cmd/share_auto_test.go+++ b/cli/beacon/cmd/share_auto_test.go@@ -3,6 +3,7 @@ package cmdimport ("bytes""encoding/json"+ "os""path/filepath""strings""testing"@@ -10,6 +11,7 @@ import ("github.com/spf13/pflag""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/managedprivacy"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/testenv""github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve/shareauto")@@ -219,3 +221,66 @@ func TestShareAutoRepositoryOptOutOverridesAProjectEnable(t *testing.T) {t.Fatalf("status = %q (%v)", stdout, err)}}++// A system-mode connection keeps its enrollment in a directory only root can read. A share run as+// the signed-in user must still find a Metadata-only connection there, and must count one it+// cannot read at all as Metadata-only, or it would upload content forwarding withholds.+func TestUnreadableCloudConnectionFailsClosed(t *testing.T) {+ testenv.RequirePOSIXFileModes(t)+ if os.Geteuid() == 0 {+ t.Skip("root reads a 0700 directory, so there is no permission error to test")+ }+ base := t.TempDir()+ stateDir := filepath.Join(base, "asymptote")+ if err := os.Mkdir(stateDir, 0o700); err != nil {+ t.Fatal(err)+ }+ enrollmentPath := filepath.Join(stateDir, "enrollment.json")+ if err := os.WriteFile(enrollmentPath, []byte(`{"privacy_mode":"standard"}`), 0o600); err != nil {+ t.Fatal(err)+ }+ if err := os.Chmod(stateDir, 0); err != nil {+ t.Fatal(err)+ }+ t.Cleanup(func() { _ = os.Chmod(stateDir, 0o700) })++ tests := []struct {+ name string+ config string+ wantConnected bool+ wantMode string+ }{+ {"metadata-only in the config", `{"managed_ingest":{"enabled":true,"privacy_mode":"metadata_only"}}`, true, managedprivacy.MetadataOnly},+ {"standard in the config", `{"managed_ingest":{"enabled":true,"privacy_mode":"standard"}}`, true, managedprivacy.Standard},+ {"connect from before privacy modes", `{"managed_ingest":{"enabled":true}}`, true, managedprivacy.Standard},+ {"unknown mode", `{"managed_ingest":{"enabled":true,"privacy_mode":"redacted"}}`, true, managedprivacy.MetadataOnly},+ {"not connected", `{"user_mode":false}`, false, ""},+ {"config not valid JSON", `{`, true, managedprivacy.MetadataOnly},+ {"no config", "", true, managedprivacy.MetadataOnly},+ }+ for _, tc := range tests {+ t.Run(tc.name, func(t *testing.T) {+ configPath := filepath.Join(t.TempDir(), "config.json")+ if tc.config != "" {+ if err := os.WriteFile(configPath, []byte(tc.config), 0o644); err != nil {+ t.Fatal(err)+ }+ }+ connected, mode := unreadableCloudConnection(enrollmentPath, configPath)+ if connected != tc.wantConnected || mode != tc.wantMode {+ t.Fatalf("unreadableCloudConnection = (%v, %q), want (%v, %q)", connected, mode, tc.wantConnected, tc.wantMode)+ }+ })+ }++ // An enrollment the user can see past is decided by asymptote.Connected, not here, and no+ // system enrollment at all is no connection.+ if err := os.Chmod(stateDir, 0o700); err != nil {+ t.Fatal(err)+ }+ for _, path := range []string{enrollmentPath, filepath.Join(base, "missing", "enrollment.json")} {+ if connected, mode := unreadableCloudConnection(path, filepath.Join(base, "config.json")); connected || mode != "" {+ t.Fatalf("unreadableCloudConnection(%s) = (%v, %q), want no connection", path, connected, mode)+ }+ }+}diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdxindex 38cea81e..efa5a028 100644--- a/docs/changelog/cli.mdx+++ b/docs/changelog/cli.mdx@@ -13,7 +13,7 @@ Stay up to date with the latest changes to the Agent Beacon CLI.- **Setup ends at the dashboard** · Confirming Beacon Cloud in the `beacon endpoint install` wizard used to end on some forty lines of file paths, connect details, an MCP table and per-runtime steps, and nothing pointed to the hosted dashboard. It now ends on four lines: the account, device and privacy mode; the session backfill; the dashboard URL; and where Beacon Cloud MCP was added. Beacon then opens the dashboard in your browser, except with `--no-browser`, over SSH, or on Linux without a display. The sign-in wait screen now also asks you to open the URL in the browser where you are signed in to beacon.sh, and cancelling the wizard says that nothing was installed and how to start again. `beacon endpoint connect` and `beacon mcp connect` print the same output as before. See [Onboarding](/cli/endpoint-onboarding#when-setup-finishes).- **`beacon share` reaches beacon.sh's API** · Sharing sent its requests to `https://beacon.sh/v1/traces`, which the beacon.sh web host does not serve, so every share from a beacon.sh sign-in or key failed with "the trace does not exist on https://beacon.sh (HTTP 404)". A beacon.sh credential now shares through `https://api.beacon.sh`, and `BEACON_API_URL` names another API host. A 404 that is a web page rather than the API's own reply now stops the share with `<url> has no trace API (HTTP 404: endpoint not found)` instead of being read as a trace that does not exist yet. See [Where the requests go](/cli/share#where-the-requests-go).-- **Sharing follows Metadata-only privacy** · On an endpoint that forwards to Beacon Cloud in Metadata-only mode, `beacon share`, `refresh`, `--follow` and the git pre-push hook uploaded the session's prompts, answers, command output and diffs anyway. They now leave out exactly what forwarding leaves out, and take no title from the session, whose title is usually its first prompt; `--title` still sets one. Event ids are unchanged, so re-sharing upserts the same events. See [Metadata-only endpoints](/cli/share#metadata-only-endpoints).+- **Sharing follows Metadata-only privacy** · On an endpoint that forwards to Beacon Cloud in Metadata-only mode, `beacon share`, `refresh`, `--follow` and the git pre-push hook uploaded the session's prompts, answers, command output and diffs anyway. They now leave out exactly what forwarding leaves out, including on a machine connected in system mode, whose enrollment only root can read, and share as Metadata-only when the mode cannot be read at all. They take no title from the session, whose title is usually its first prompt; `--title` still sets one. Event ids are unchanged, so re-sharing upserts the same events. See [Metadata-only endpoints](/cli/share#metadata-only-endpoints).- **Redaction catches Beacon's sign-in token and AWS secret keys beside their key id** · Redaction already removed `bcn_api_`, `bcn_device_`, `bcn_mcp_` and `bcn_enfdev_` keys. It now also removes the `beacon login` token (`bcn_cli_…`), MCP refresh tokens (`bcn_mcprt_…`) and the sign-in's `bcn_code_…`, `bcn_client_…` and `bcn_exchange_…` values, and the 40-character AWS secret key that follows an `AKIA…` or `ASIA…` key id, as in a credentials CSV. Both used to reach the log and Beacon Cloud unredacted. See [What is redacted](/security/retention-redaction#what-is-redacted).- **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 Jamf hook repair script no longer hands the console user root** · `jamf/claude/common/repair-hooks.sh` runs as root. It granted the console user permission to add and delete entries in `/var/log/beacon-agent`, which let them replace the runtime log with a link that the root collector then opened, and it ran `chown -R` on `~/.beacon` as root, which a planted hard link turned into ownership of a root-run binary. The directory grant is gone, and the script now removes every grant that adds or deletes entries there, including ones earlier runs gave a previous console user and the one the Jamf guide's snippet used to add. It creates and fixes up `~/.beacon` as the user, refuses a symlinked directory, and moves aside one the user does not own. The Jamf guide explains how to remove the old grant by hand.diff --git a/docs/cli/share.mdx b/docs/cli/share.mdxindex e1981c44..82581172 100644--- a/docs/cli/share.mdx+++ b/docs/cli/share.mdx@@ -85,7 +85,7 @@ beacon.sh redacts every string again on its side. Redaction catches common crede### Metadata-only endpoints-When this machine forwards to [Beacon Cloud](/cli/endpoint-connect) in Metadata-only privacy mode (user or system mode), `beacon share` leaves out what forwarding leaves out, so a share never sends more than the endpoint's privacy mode allows. The trace keeps the session's shape: event types and order, tool and command names, command lines, file paths, MCP servers and tools, approval and policy decisions, models, token usage and the ids that tie events together. It has no prompt text, answers or reasoning, tool arguments or results, command output, diffs, raw payloads, or approval and policy reasons. The title is not taken from the session either, because most runtimes title a session with its first prompt; pass `--title` to give the trace one. Event ids are the same in both modes, so sharing a session again with `beacon share` after the endpoint switched to Metadata-only upserts the events already on beacon.sh rather than adding copies; `refresh` sends only the newer ones. This applies to `beacon share`, `refresh`, `--follow` and the git pre-push hook. Run `--print` to see the result.+When this machine forwards to [Beacon Cloud](/cli/endpoint-connect) in Metadata-only privacy mode (user or system mode), `beacon share` leaves out what forwarding leaves out, so a share never sends more than the endpoint's privacy mode allows. The trace keeps the session's shape: event types and order, tool and command names, command lines, file paths, MCP servers and tools, approval and policy decisions, models, token usage and the ids that tie events together. It has no prompt text, answers or reasoning, tool arguments or results, command output, diffs, raw payloads, or approval and policy reasons. The title is not taken from the session either, because most runtimes title a session with its first prompt; pass `--title` to give the trace one. Event ids are the same in both modes, so sharing a session again with `beacon share` after the endpoint switched to Metadata-only upserts the events already on beacon.sh rather than adding copies; `refresh` sends only the newer ones. This applies to `beacon share`, `refresh`, `--follow` and the git pre-push hook. On a machine connected in system mode, these commands read the privacy mode from the system `config.json`, because the enrollment record is readable only by root; when neither can be read, they share as Metadata-only. Run `--print` to see the result.`--print` (or `--dry-run`) prints exactly that payload as JSON and sends nothing: the external id the requests go to, `trace` (the body of `PUT /v1/traces/{external_id}`) and `events` (every event the `POST /v1/traces/{external_id}/events/batch` requests would carry, at most 1,000 per request):