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
Windows: create credential-bearing system files SYSTEM/Administrators only
Claude974dd34e7d93
diff --git a/cli/beacon/internal/endpoint/collector/collector.go b/cli/beacon/internal/endpoint/collector/collector.goindex d00897ba..64df0db6 100644--- a/cli/beacon/internal/endpoint/collector/collector.go+++ b/cli/beacon/internal/endpoint/collector/collector.go@@ -13,6 +13,7 @@ import ("github.com/asymptote-labs/agent-beacon/cli/beacon/internal/brewpath"endpointconfig "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/config"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/sysacl")const (@@ -118,17 +119,19 @@ func WriteConfig(cfg endpointconfig.Config) error {if err := os.MkdirAll(filepath.Dir(cfg.Collector.SpoolPath), 0755); err != nil {return err}- perm := os.FileMode(0644)if endpointconfig.HasSecretDestinations(cfg) {- perm = 0600- }- if err := os.WriteFile(cfg.Collector.ConfigPath, []byte(ConfigYAML(cfg)), perm); err != nil {- return err- }- if endpointconfig.HasSecretDestinations(cfg) {- return os.Chmod(cfg.Collector.ConfigPath, perm)+ // The collector config renders the destinations' tokens and headers. On a system install+ // it is created SYSTEM and Administrators only (the 0600 mode means nothing on Windows,+ // and the tree's DACL lets every user read below it); per-user configs keep the mode.+ if !cfg.UserMode {+ return sysacl.WriteSecretFile(cfg.Collector.ConfigPath, []byte(ConfigYAML(cfg)))+ }+ if err := os.WriteFile(cfg.Collector.ConfigPath, []byte(ConfigYAML(cfg)), 0600); err != nil {+ return err+ }+ return os.Chmod(cfg.Collector.ConfigPath, 0600)}- return nil+ return os.WriteFile(cfg.Collector.ConfigPath, []byte(ConfigYAML(cfg)), 0644)}// IngestExtension is the collector extension that serves the local ingest socket in the restricteddiff --git a/cli/beacon/internal/endpoint/config/config.go b/cli/beacon/internal/endpoint/config/config.goindex d3c9d1e3..0956b9ff 100644--- a/cli/beacon/internal/endpoint/config/config.go+++ b/cli/beacon/internal/endpoint/config/config.go@@ -10,6 +10,7 @@ import ("strings""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/atomicfile"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/sysacl")const (@@ -258,7 +259,18 @@ func saveOTLPForwardSecrets(cfg Config) error {if err != nil {return err}- return atomicfile.Write(path, data, 0600)+ return writeSecretFile(cfg.UserMode, path, data)+}++// writeSecretFile writes a file holding a credential. A system install's files sit in the+// machine-wide tree, whose Windows DACL lets every user read what is below it and ignores the+// mode, so they are created with SYSTEM and Administrators only (sysacl.WriteSecretFile); per-user+// files are in the person's own profile and keep the mode.+func writeSecretFile(userMode bool, path string, data []byte) error {+ if userMode {+ return atomicfile.Write(path, data, 0600)+ }+ return sysacl.WriteSecretFile(path, data)}type SplunkHEC struct {@@ -472,11 +484,13 @@ func Save(cfg Config) (string, error) {if err := saveOTLPForwardSecrets(cfg); err != nil {return "", err}- perm := os.FileMode(0644)if hasSecretConfigFields(cfg) {- perm = 0600+ if err := writeSecretFile(cfg.UserMode, path, data); err != nil {+ return "", err+ }+ return path, nil}- if err := atomicfile.Write(path, data, perm); err != nil {+ if err := atomicfile.Write(path, data, 0644); err != nil {return "", err}return path, nildiff --git a/cli/beacon/internal/endpoint/sysacl/secret.go b/cli/beacon/internal/endpoint/sysacl/secret.gonew file mode 100644index 00000000..770179ed--- /dev/null+++ b/cli/beacon/internal/endpoint/sysacl/secret.go@@ -0,0 +1,9 @@+package sysacl++// SecretFileDACL is the protected DACL on a machine-wide file that holds a credential -- a HEC+// token in config.json, the rendered collector config, the OTLP forward's headers: SYSTEM and+// Administrators, nobody else. The tree's DACL lets every user read files below it, and the 0600+// mode Beacon asks for means nothing on Windows.+func SecretFileDACL() []ACE {+ return RestrictedLockDACL()+}diff --git a/cli/beacon/internal/endpoint/sysacl/secret_other.go b/cli/beacon/internal/endpoint/sysacl/secret_other.gonew file mode 100644index 00000000..c9b03a27--- /dev/null+++ b/cli/beacon/internal/endpoint/sysacl/secret_other.go@@ -0,0 +1,10 @@+//go:build !windows++package sysacl++import "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/atomicfile"++// WriteSecretFile replaces path with data as a 0600 file. POSIX carries the guarantee in the mode.+func WriteSecretFile(path string, data []byte) error {+ return atomicfile.Write(path, data, 0600)+}diff --git a/cli/beacon/internal/endpoint/sysacl/secret_windows.go b/cli/beacon/internal/endpoint/sysacl/secret_windows.gonew file mode 100644index 00000000..80265cbf--- /dev/null+++ b/cli/beacon/internal/endpoint/sysacl/secret_windows.go@@ -0,0 +1,60 @@+//go:build windows++package sysacl++import (+ "fmt"+ "os"+ "path/filepath"+ "runtime"+ "unsafe"++ "golang.org/x/sys/windows"+)++// WriteSecretFile replaces path with data, as a file only SYSTEM and Administrators can open.+//+// The temp file is created with SecretFileDACL and Administrators ownership by CreateFile itself, so+// there is no moment in which it carries what the directory passes on, and the rename keeps that+// descriptor. Like atomicfile.Write, a reader never sees a half-written file.+func WriteSecretFile(path string, data []byte) error {+ sd, err := windows.SecurityDescriptorFromString(SDDL(sidAdministrators, true, SecretFileDACL()))+ if err != nil {+ return fmt.Errorf("build the security descriptor: %w", err)+ }+ sa := &windows.SecurityAttributes{SecurityDescriptor: sd}+ sa.Length = uint32(unsafe.Sizeof(*sa))+ var tmp string+ var h windows.Handle+ for attempt := 0; ; attempt++ {+ tmp = filepath.Join(filepath.Dir(path), fmt.Sprintf(".%s.%d.%d.tmp", filepath.Base(path), os.Getpid(), attempt))+ p, err := windows.UTF16PtrFromString(tmp)+ if err != nil {+ return err+ }+ h, err = windows.CreateFile(p, windows.GENERIC_WRITE, 0, sa, windows.CREATE_NEW, windows.FILE_ATTRIBUTE_NORMAL, 0)+ if err == nil {+ break+ }+ if err != windows.ERROR_FILE_EXISTS || attempt >= 16 {+ runtime.KeepAlive(sd)+ return &os.PathError{Op: "create", Path: tmp, Err: err}+ }+ }+ runtime.KeepAlive(sd)+ f := os.NewFile(uintptr(h), tmp)+ if _, err := f.Write(data); err != nil {+ f.Close()+ os.Remove(tmp)+ return err+ }+ if err := f.Close(); err != nil {+ os.Remove(tmp)+ return err+ }+ if err := os.Rename(tmp, path); err != nil {+ os.Remove(tmp)+ return err+ }+ return nil+}diff --git a/cli/beacon/internal/endpoint/sysacl/secret_windows_test.go b/cli/beacon/internal/endpoint/sysacl/secret_windows_test.gonew file mode 100644index 00000000..1913797e--- /dev/null+++ b/cli/beacon/internal/endpoint/sysacl/secret_windows_test.go@@ -0,0 +1,47 @@+//go:build windows++package sysacl++import (+ "os"+ "path/filepath"+ "reflect"+ "testing"+)++// A credential file in the machine-wide tree is SYSTEM and Administrators only, whatever the tree+// passes on, and replacing it keeps that: the new file never carries the tree's Users grant.+func TestWriteSecretFileIsSystemAndAdministratorsOnly(t *testing.T) {+ requireElevated(t)+ root := filepath.Join(t.TempDir(), "Beacon")+ if err := SecureSystemTree(root); err != nil {+ t.Fatal(err)+ }+ path := filepath.Join(root, "otlp-forward-headers.json")+ for _, body := range []string{`{"headers":{"authorization":"one"}}`, `{"headers":{"authorization":"two"}}`} {+ if err := WriteSecretFile(path, []byte(body)); err != nil {+ t.Fatalf("WriteSecretFile: %v", err)+ }+ obj := mustRead(t, path)+ if !obj.Protected || !reflect.DeepEqual(obj.DACL, SecretFileDACL()) {+ t.Fatalf("secret file carries %+v (protected %v), want only %+v", obj.DACL, obj.Protected, SecretFileDACL())+ }+ if obj.Owner != sidAdministrators {+ t.Fatalf("secret file owned by %s, want Administrators", obj.Owner)+ }+ if got, err := os.ReadFile(path); err != nil || string(got) != body {+ t.Fatalf("content = %q, %v", got, err)+ }+ }+ // A later pass over the tree keeps the stricter ACL rather than resetting it to the tree's.+ if err := SecureSystemTree(root); err != nil {+ t.Fatal(err)+ }+ if obj := mustRead(t, path); !reflect.DeepEqual(obj.DACL, SecretFileDACL()) {+ t.Fatalf("SecureSystemTree reset the secret file to %+v", obj.DACL)+ }+ entries, _ := os.ReadDir(root)+ if len(entries) != 1 {+ t.Fatalf("temp files left behind: %v", entries)+ }+}diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdxindex 03beffbb..6c0c530e 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.## Unreleased+- **Windows system installs keep destination credentials from other users** · On Windows the 0600 mode Beacon asked for has no effect, and `%ProgramData%\Beacon` lets every user read the files below it, so any local account could read a Splunk or Falcon HEC token in `config.json` and `otelcol.yaml`, and the OTLP forward's headers. Those files are now created with access for SYSTEM and Administrators only, at creation, so there is no moment they are readable. A `config.json` with no credential in it stays readable, as before, so other accounts still find the system log through it.- **Forward OTLP to a second backend** · Macs that already sent Claude Code or Codex OpenTelemetry to another backend lost that export when Beacon pointed the runtimes at its collector. `beacon endpoint install|repair --otlp-forward-endpoint <endpoint>` (with `--otlp-forward-protocol grpc|http/protobuf` and repeatable `--otlp-forward-header name=value`) now has the collector send that OTLP on to the endpoint as well, through pipelines of its own. The forward carries only Claude Code and Codex by default (`--otlp-forward-harness` changes the list), so browser-extension chats and other runtimes stay local. Secrets are redacted, raw API bodies are dropped, and the queue is bounded, so a down backend never holds up Beacon's own capture. Header values are kept in a root-only `otlp-forward-headers.json` beside `config.json`. Repair and package upgrades keep it; `--no-otlp-forward` removes it. See [Kandji with an existing OTLP backend](/guides/kandji-otlp-forward-mdm).- **Inherited per-signal OTLP settings no longer divert Claude telemetry** · An `OTEL_EXPORTER_OTLP_{LOGS,METRICS,TRACES}_ENDPOINT`, protocol or headers setting in the environment or Claude's settings sent Claude's telemetry past Beacon's collector, in `beacon ci` and with `beacon endpoint`, which still reported telemetry as enabled. Beacon now overrides them, and `beacon endpoint status` flags one that points elsewhere.- **`beacon git` links symlinks a session creates** · When a session's directory ran through a symlink, such as `/tmp` on macOS, a link the session created was resolved to its target: `ln -s ../shared/config.json cfg.json` linked nothing, and `ln -s a.txt alias.txt` was credited as `a.txt`. The link itself is now recorded.