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
fix(privacy): redact and cap run, vcs and model/repository/branch strings (#1226)
kyle-elliott-asymptote87ae4fdd638d
diff --git a/collector-builder/exporter/beaconjsonexporter/exporter_test.go b/collector-builder/exporter/beaconjsonexporter/exporter_test.goindex 85d6bbe1..291a204e 100644--- a/collector-builder/exporter/beaconjsonexporter/exporter_test.go+++ b/collector-builder/exporter/beaconjsonexporter/exporter_test.go@@ -110,6 +110,33 @@ func TestNewExporterAcceptsDeprecatedContentRetention(t *testing.T) {}}+// The run block and the top-level model, repository and branch come from resource attributes and+// the CI environment, where a pull request names its own branch. They are redacted and capped like+// every other attribute string: a credential in one does not reach the line, and a branch name past+// the event size limit no longer makes the whole event unwritable.+func TestJSONLWriterSanitizesRunAndMetadata(t *testing.T) {+ path := filepath.Join(t.TempDir(), "runtime.jsonl")+ writer := jsonlWriter{path: path, maxEventBytes: defaultMaxEventBytes, rotateBytes: defaultRotateBytes, rotateArchives: defaultRotateArchives, redactSecrets: true}++ event := newBeaconEvent("tool.invoked", "tool", "info", "test", time.Now())+ event.Model = "token=model-secret"+ event.Repository = "https://example.com/repo?token=repository-secret"+ event.Branch = strings.Repeat("b", defaultMaxEventBytes+1)+ event.Run = &beaconevent.RunInfo{Branch: "feature/AKIAABCDEFGHIJKLMNOP", PR: "token=pr-secret"}+ if err := writer.append(event); err != nil {+ t.Fatalf("append: %v", err)+ }+ data, err := os.ReadFile(path)+ if err != nil {+ t.Fatal(err)+ }+ for _, secret := range []string{"model-secret", "repository-secret", "AKIAABCDEFGHIJKLMNOP", "pr-secret"} {+ if strings.Contains(string(data), secret) {+ t.Fatalf("%q reached the log: %s", secret, data)+ }+ }+}+func TestIntAttrRejectsOutOfRangeString(t *testing.T) {attrs := map[string]interface{}{"value": "9223372036854775808"}if got, ok := intAttr(attrs, "value"); ok {diff --git a/collector-builder/exporter/beaconjsonexporter/writer.go b/collector-builder/exporter/beaconjsonexporter/writer.goindex 97ca60e4..feb43883 100644--- a/collector-builder/exporter/beaconjsonexporter/writer.go+++ b/collector-builder/exporter/beaconjsonexporter/writer.go@@ -127,6 +127,12 @@ func (w jsonlWriter) sanitize(event beaconEvent) beaconEvent {if event.Prompt != nil {event.Prompt.Text = w.cleanString(event.Prompt.Text, asymptoteobserve.DefaultStringLimit)}+ // Mirrors SanitizeEvent: the run block and the top-level model, repository and branch come from+ // OTLP resource attributes and the CI environment, where a pull request names its own branch.+ event.Run = asymptoteobserve.SanitizeRun(event.Run, w.privacyOptions())+ event.Model = w.cleanString(event.Model, asymptoteobserve.DefaultRawStringLimit)+ event.Repository = w.cleanString(event.Repository, asymptoteobserve.DefaultRawStringLimit)+ event.Branch = w.cleanString(event.Branch, asymptoteobserve.DefaultRawStringLimit)if event.MCP != nil {event.MCP = asymptoteobserve.SanitizeMCP(event.MCP, w.privacyOptions())}diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdxindex 5430f7bb..2c8e9d5c 100644--- a/docs/changelog/cli.mdx+++ b/docs/changelog/cli.mdx@@ -13,6 +13,8 @@ Stay up to date with the latest changes to the Agent Beacon CLI.Changes on `main` since v1.3.58. They ship in the next release.+- **Run and repository metadata is redacted and capped** · The `run` block (CI provider, workflow, branch, pull-request ref, actor), the `vcs` block, and the top-level `model`, `repository` and `branch` were written as they arrived, so a credential in a branch name or remote URL reached the log, and a branch name larger than the event size limit made the whole event unwritable. They now get the same secret redaction and 2 KB limit as every other attribute string, in both the collector's writer and the CLI's.+- **Renamed-binary approval bypass catches rm copies under any name** · `approval-bypass-via-renamed-binary` (v3) no longer requires a temp-dir copy of `rm` to be named like `rm`: after a denied dangerous command, running any executable from `/tmp/`, `/var/tmp/`, or `$(mktemp ...)` at command position with an rm-style recursive+force flag (`-rf`, `-v -rf`, a trailing `-rf`) correlates. Temp paths passed as arguments to other tools (`cp /tmp/build -rf`, `tar -C /tmp/stage -rf`, `find /tmp/build -printf`) do not.- **A repository cannot turn auto-share on through the hook environment** · The hooks read the auto-share setting from `~/.beacon/endpoint/share.json` in the home of the account they run as, looked up from the account (the passwd entry, or the Windows process token), not from `$HOME` or `USERPROFILE`, so a repository that sets `HOME` for its hooks cannot plant a `share.json` that publishes its sessions. On Linux, an account that is not in `/etc/passwd` (LDAP, SSSD) still falls back to `$HOME`. `beacon share auto` writes the same file, and the restricted-log spool also moved to the account's home. The cloud-sandbox shuttle now uploads on Stop and SessionEnd only with `BEACON_ORIGIN=cloud`, which the cloud agent setups already set; `BEACON_CLOUD_*` without it does nothing.diff --git a/pkg/asymptoteobserve/privacy.go b/pkg/asymptoteobserve/privacy.goindex f2e0f873..c8f0cfea 100644--- a/pkg/asymptoteobserve/privacy.go+++ b/pkg/asymptoteobserve/privacy.go@@ -1469,6 +1469,15 @@ func SanitizeEvent(event Event, maxBytes int) Event {if event.Prompt != nil {event.Prompt.Text = CleanString(event.Prompt.Text, DefaultStringLimit, true)}+ // The run, vcs and top-level model, repository and branch strings come from the environment, a+ // runtime's attributes or the repository's own refs (a pull request names its branch), so they+ // get the raw-attribute limit and secret redaction too.+ metadata := PrivacyOptions{RedactSecrets: true, StringLimit: DefaultRawStringLimit}+ event.Run = SanitizeRun(event.Run, metadata)+ event.VCS = SanitizeVCS(event.VCS, metadata)+ event.Model = CleanString(event.Model, DefaultRawStringLimit, true)+ event.Repository = CleanString(event.Repository, DefaultRawStringLimit, true)+ event.Branch = CleanString(event.Branch, DefaultRawStringLimit, true)if event.MCP != nil {event.MCP = SanitizeMCP(event.MCP, PrivacyOptions{RedactSecrets: true, StringLimit: DefaultRawStringLimit})}diff --git a/pkg/asymptoteobserve/privacy_test.go b/pkg/asymptoteobserve/privacy_test.goindex 1e1c8915..12da6e1c 100644--- a/pkg/asymptoteobserve/privacy_test.go+++ b/pkg/asymptoteobserve/privacy_test.go@@ -78,6 +78,14 @@ func TestSanitizeEventRedactsAndTruncates(t *testing.T) {event.Prompt = &PromptInfo{Text: "token=prompt-secret"}event.GenAI = &GenAIInfo{SystemInstructions: SystemInstructionParts("token=system-instructions-secret")}event.Raw = map[string]interface{}{"nested": map[string]interface{}{"token": "token=raw-secret"}}+ event.Model = "token=model-secret"+ event.Repository = "token=repository-secret"+ event.Branch = strings.Repeat("b", 3000)+ event.Run = &RunInfo{Branch: "feature/AKIAABCDEFGHIJKLMNOP", PR: "token=pr-secret"}+ event.VCS = &VCSInfo{+ Ref: &VCSRefInfo{Head: &VCSRefHeadInfo{Name: "token=vcs-branch-secret"}},+ Repository: &VCSRepositoryInfo{URL: &VCSRepositoryURLInfo{Full: "https://example.com/r?token=vcs-url-secret"}},+ }sanitized := SanitizeEvent(event, 64*1024)data, err := json.Marshal(sanitized)@@ -85,13 +93,16 @@ func TestSanitizeEventRedactsAndTruncates(t *testing.T) {t.Fatalf("marshal sanitized event: %v", err)}text := string(data)- for _, secret := range []string{"message-secret", "command-secret", "policy-secret", "prompt-secret", "system-instructions-secret", "raw-secret"} {+ for _, secret := range []string{+ "message-secret", "command-secret", "policy-secret", "prompt-secret", "system-instructions-secret", "raw-secret",+ "model-secret", "repository-secret", "AKIAABCDEFGHIJKLMNOP", "pr-secret", "vcs-branch-secret", "vcs-url-secret",+ } {if strings.Contains(text, secret) {t.Fatalf("secret %q was not redacted: %s", secret, text)}}- if len(sanitized.Tool.Path) > DefaultRawStringLimit {- t.Fatalf("tool path was not truncated: %d", len(sanitized.Tool.Path))+ if len(sanitized.Tool.Path) > DefaultRawStringLimit || len(sanitized.Branch) > DefaultRawStringLimit {+ t.Fatalf("tool path or branch was not truncated: %d, %d", len(sanitized.Tool.Path), len(sanitized.Branch))}}diff --git a/pkg/asymptoteobserve/sanitize_typed.go b/pkg/asymptoteobserve/sanitize_typed.goindex 5f62ce40..79b38250 100644--- a/pkg/asymptoteobserve/sanitize_typed.go+++ b/pkg/asymptoteobserve/sanitize_typed.go@@ -484,6 +484,63 @@ func SanitizeMCP(in *MCPInfo, opts PrivacyOptions) *MCPInfo {return out}+// SanitizeRun returns a sanitized copy of a run block, every string cleaned with opts. Its values+// come from the CI or cloud environment, and a branch or pull-request ref is named by whoever opens+// the pull request.+func SanitizeRun(in *RunInfo, opts PrivacyOptions) *RunInfo {+ if in == nil {+ return nil+ }+ g := newGenericSanitizer(opts)+ return &RunInfo{+ Provider: g.text(in.Provider),+ RunID: g.text(in.RunID),+ RunAttempt: g.text(in.RunAttempt),+ Workflow: g.text(in.Workflow),+ Job: g.text(in.Job),+ EventName: g.text(in.EventName),+ Commit: g.text(in.Commit),+ Repository: g.text(in.Repository),+ Branch: g.text(in.Branch),+ PR: g.text(in.PR),+ PRNumber: g.text(in.PRNumber),+ Actor: g.text(in.Actor),+ Ephemeral: in.Ephemeral,+ }+}++// SanitizeVCS returns a sanitized copy of a vcs block, every string cleaned with opts. A branch name+// and a remote URL are text the repository's owner, not Beacon, chose.+func SanitizeVCS(in *VCSInfo, opts PrivacyOptions) *VCSInfo {+ if in == nil {+ return nil+ }+ g := newGenericSanitizer(opts)+ out := &VCSInfo{}+ if in.Ref != nil {+ out.Ref = &VCSRefInfo{}+ if h := in.Ref.Head; h != nil {+ out.Ref.Head = &VCSRefHeadInfo{Revision: g.text(h.Revision), Name: g.text(h.Name), Type: g.text(h.Type)}+ }+ }+ if in.Repository != nil {+ out.Repository = &VCSRepositoryInfo{}+ if u := in.Repository.URL; u != nil {+ out.Repository.URL = &VCSRepositoryURLInfo{Full: g.text(u.Full)}+ }+ }+ if a := in.Attribution; a != nil {+ out.Attribution = &VCSAttributionInfo{Method: g.text(a.Method), ChangedFiles: a.ChangedFiles, MatchedFiles: a.MatchedFiles}+ }+ if h := in.Hook; h != nil {+ out.Hook = &VCSHookInfo{+ Name: g.text(h.Name), Phase: g.text(h.Phase), BudgetMS: h.BudgetMS, ElapsedMS: h.ElapsedMS,+ PhaseElapsedMS: h.PhaseElapsedMS, GitSpawns: h.GitSpawns, CutShort: h.CutShort,+ }+ }+ return out+}+func sanitizeSystemContext(in *SystemContextInfo) *SystemContextInfo {g := newGenericSanitizer(PrivacyOptions{RedactSecrets: true, StringLimit: DefaultRawStringLimit})out := &SystemContextInfo{Kind: g.text(in.Kind), Source: g.text(in.Source)}diff --git a/pkg/asymptoteobserve/sanitize_typed_test.go b/pkg/asymptoteobserve/sanitize_typed_test.goindex 9d8200d0..eaf48a57 100644--- a/pkg/asymptoteobserve/sanitize_typed_test.go+++ b/pkg/asymptoteobserve/sanitize_typed_test.go@@ -291,7 +291,7 @@ func TestTypedFieldNamesAreNotSecret(t *testing.T) {walk(f.Type, path+"."+f.Name)}}- for _, v := range []any{MCPInfo{}, SystemContextInfo{}, GenAIInfo{}} {+ for _, v := range []any{MCPInfo{}, SystemContextInfo{}, GenAIInfo{}, RunInfo{}, VCSInfo{}} {walk(reflect.TypeOf(v), reflect.TypeOf(v).Name())}}@@ -330,7 +330,9 @@ func TestTypedConversionKeepsEveryField(t *testing.T) {var mcp MCPInfovar context SystemContextInfovar genAI GenAIInfo- for _, v := range []any{&mcp, &context, &genAI} {+ var run RunInfo+ var vcs VCSInfo+ for _, v := range []any{&mcp, &context, &genAI, &run, &vcs} {fill(reflect.ValueOf(v).Elem())}opts := PrivacyOptions{RedactSecrets: true, StringLimit: DefaultRawStringLimit}@@ -340,6 +342,12 @@ func TestTypedConversionKeepsEveryField(t *testing.T) {if got := sanitizeSystemContext(&context); !reflect.DeepEqual(*got, context) {t.Errorf("system context = %+v, want %+v", *got, context)}+ if got := SanitizeRun(&run, opts); !reflect.DeepEqual(*got, run) {+ t.Errorf("run = %+v, want %+v", *got, run)+ }+ if got := SanitizeVCS(&vcs, opts); !reflect.DeepEqual(*got, vcs) {+ t.Errorf("vcs = %s\nwant %s", mustJSON(t, got), mustJSON(t, vcs))+ }want := genAIwant.SystemInstructionsText = ""tool := *want.Tool