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
Restrict the system log on a first Linux package install
Claudef33ee87eed30
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 40ea6935..cb6dbdb6 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -697,6 +697,9 @@ jobs:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v7+ # Fast and needs nothing built: the install script's arguments, against a stub binary.+ - name: Validate the packaging scripts+ run: sh packaging/linux/test-endpoint-scripts.sh- uses: ./.github/actions/setup-gowith:# The exporter is listed because builder.yaml compiles it into thediff --git a/CLAUDE.md b/CLAUDE.mdindex 0a3ad686..5dd0f617 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -28,7 +28,7 @@ Do not recreate or depend on removed `asymptote` mirror trees. Keep new work foc- Beacon is visibility-first endpoint telemetry for local AI agent runtimes, not a hosted policy service or general endpoint protection product.- Preserve the local-only default. The public Beacon build must not require a hosted account, remote policy fetch, hosted dashboard, or external network dependency during normal hook execution, and hooks themselves never touch the network.- `beacon login` is the account-identity channel for interactive users and is required by the interactive `beacon endpoint install` wizard. It uses browser PKCE against beacon.sh and stores the scoped CLI token only in `~/.beacon/auth/session.json` (0600 under a 0700 directory). Signing in alone never starts forwarding. User-mode `beacon endpoint connect` may send that token once to `POST /api/cli/enroll/account` to authorize minting a separate device ingest key, and `beacon mcp token create` may send it to `POST /api/cli/mcp/tokens` (scope `mcp:token:create`, listed on the sign-in page) to mint a personal MCP token that is printed once to stdout and never written to a file, and `beacon share` may send it (scope `traces:write`, also on the sign-in page) to `PUT /v1/traces/{external_id}`, `POST /v1/traces/{external_id}/events/batch` and `GET /v1/traces/{external_id}` on the Beacon API host (`https://api.beacon.sh` for a beacon.sh sign-in, other hosts unchanged, `BEACON_API_URL` overrides) to upload a shared trace the person chose to publish, as a `beacon.trace.v1` summary and its events (`cli/beacon/internal/account/share.go`; a `bcn_api_` API key from `--key` or `BEACON_API_KEY` may stand in for it, precedence `--key`, then a current sign-in carrying the scope, then the environment). These are explicit, user-initiated requests with redirects refused. Hooks, plugins and background jobs never make them, with one exception: the git pre-push hook, only when the person opted in with `beacon git setup --share-sessions` (public needs confirmation), may make the three share requests during a push the person started, within the hook's budget and never failing the push. Never copy the account token into endpoint config, Vector, hook environments, logs, or command output. System/root/package/MDM/CI/piped-stdin/dry-run installs stay noninteractive and account-free.-- System log access (`beacon endpoint install|repair --system --log-access shared|restricted`; docs in `docs/cli/endpoint-install.mdx#restricted-log-access`). Shared, the default, is the system log as it always was: hooks append to `/var/log/beacon-agent/runtime.jsonl` directly, so it is `0666`. Restricted is opt-in and makes the root collector the only writer: its `beacon_ingest` extension (`collector-builder/exporter/beaconjsonexporter/beaconingestextension`, appending through the exporter's own `internal/runtimelog`) serves `/var/run/beacon-agent/ingest.sock`, and the hook adapter and the CLI writer, as any account but root writing the system log, hand finished lines to it through `pkg/asymptoteobserve/localingest` (`Deliverer`). The protocol is one batch per connection (`BEACON-INGEST/1`, a header naming the log, one event per line, one JSON reply saying how far it got); the server refuses a batch for any log but its own, identifies the sender only by kernel peer credentials (`SO_PEERCRED`, `LOCAL_PEERCRED`), overwrites the event's `user` with that uid and its resolved name and always derives `event.id` itself (`StampLine` re-encodes, so a sender cannot split or forge lines or reuse another event's id), and bounds connections overall and per uid, batch size, each account's bytes per second, and its own time per connection (shorter than the client's, so it reports how far it got instead of being resent). The client sends only to a socket that root owns in a directory nobody else can write (group-writable ancestors only for gid 0/1, which macOS's `/private/var/run` needs). `Deliverer.Write` sends through the socket when it answers and otherwise appends directly as before; only a direct append refused for permission (a restricted log whose collector is down) spools the line, to the account's private spool for that log (`~/.beacon/endpoint/spool/<log digest>`, 0600 under 0700), and the next line that gets through either way drains it. Root writers and per-user logs always write directly. The mode is `config.json` `log_access`, carried through repair and package upgrades (`BEACON_LOG_ACCESS` in the install scripts); install creates the `beacon-log` group (`internal/endpoint/loggroup`, getent/groupadd, dscl/dseditgroup) and `writer.RestrictSystemLog` makes the directory `root:beacon-log 02750`, the log and archives `0640` and the lock root-only `0600`, after writing the root-owned `.beacon-log-access` marker beside the log; a shared log is not narrowed in place but copied to fresh root-created files and renamed over, under its lock (bounded wait), because a descriptor opened while it was 0666 survives any chmod. A failed install restores the previous mode in its rollback, and a shared install removes a dead socket. The marker is what tells every root writer (`asymptoteobserve.RuntimeLogModes`) to keep the restricted modes. The OTLP receivers on loopback are not covered: any local process can still send OTLP, unattributed, so never claim more than the hook channel guarantees. Doctor's `runtime_log_access` covers the marker, the socket and pending spool. Unix sockets are local IPC, not a network channel, so the hooks-never-touch-the-network rule holds. On Windows the same mode runs over the named pipe `\\.\pipe\beacon-agent-ingest` (`localingest` `transport_windows.go`, go-winio): the collector creates it as the first instance, and when the name is taken (any account may create one) it reports a recoverable error and retries every few seconds rather than failing, so the rest of the collector stays up; it rejects remote clients and its DACL denies NETWORK and withholds `FILE_CREATE_PIPE_INSTANCE` from ordinary accounts, so it is not a network channel either; a client connects at identification level and sends only to a pipe owned by SYSTEM or Administrators; the server counts a connection against its account from the client process's token before reading and stamps the SID it reads by `ImpersonateNamedPipeClient` after the preamble (they must agree), with `Peer.UID` a string (decimal uid on Unix, SID on Windows) and the name from `LookupAccountSid`, bounded. Privileged writers there are SYSTEM and tokens with Administrators enabled (`CheckTokenMembership`; elevation for another group is not enough). The directory gets `sysacl.RestrictedLogDirDACL` (protected: SYSTEM and Administrators full, `beacon-log` local group read, nothing else; the lock SYSTEM and Administrators only) and everything below it is reset, because every account may bypass traverse checking; `writer.RestrictSystemLog` replaces every file directly in the directory (the log family under the lock; files outside it with another hard link are skipped) with a copy created with its final owner and DACL (`sysacl.CreateRestrictedFile`) and a POSIX-semantics rename, fails naming any file held open without sharing delete and then puts a log that was shared back to shared, and writes the marker last (on Windows it decides nothing for root writers, so a failed or killed run is not mistaken for a finished one). The marker counts there when SYSTEM or Administrators own it and no other account can write it. `loggroup` creates the local group with `net.exe` and looks it up qualified with the computer name. Doctor reads the restricted ACL (`writer.CheckRestrictedSystemLogACL`). `packaging/windows/smoke-restricted-log.ps1` runs in `windows-package-smoke` against the installed MSI with a real ordinary account. Hook and writer tests point `logging.EndpointIngest`/`writer.Ingest` at sockets of their own.+- System log access (`beacon endpoint install|repair --system --log-access shared|restricted`; docs in `docs/cli/endpoint-install.mdx#restricted-log-access`). Shared, the CLI default, is the system log as it always was: hooks append to `/var/log/beacon-agent/runtime.jsonl` directly, so it is `0666`. Restricted is opt-in for the CLI and the macOS/Windows packages, and the default for a first Linux `.deb`/`.rpm` install (`packaging/linux/install-endpoint.sh` passes `--log-access restricted` when no system `config.json` exists yet; an upgrade passes nothing and keeps the mode; that script also reads the `BEACON_*` install settings, never sourcing them, from a root-owned, not group/other-writable `/etc/default/beacon` or `/etc/sysconfig/beacon` for configuration managers that cannot set its environment, environment winning; `packaging/linux/test-endpoint-scripts.sh` checks both). Restricted makes the root collector the only writer: its `beacon_ingest` extension (`collector-builder/exporter/beaconjsonexporter/beaconingestextension`, appending through the exporter's own `internal/runtimelog`) serves `/var/run/beacon-agent/ingest.sock`, and the hook adapter and the CLI writer, as any account but root writing the system log, hand finished lines to it through `pkg/asymptoteobserve/localingest` (`Deliverer`). The protocol is one batch per connection (`BEACON-INGEST/1`, a header naming the log, one event per line, one JSON reply saying how far it got); the server refuses a batch for any log but its own, identifies the sender only by kernel peer credentials (`SO_PEERCRED`, `LOCAL_PEERCRED`), overwrites the event's `user` with that uid and its resolved name and always derives `event.id` itself (`StampLine` re-encodes, so a sender cannot split or forge lines or reuse another event's id), and bounds connections overall and per uid, batch size, each account's bytes per second, and its own time per connection (shorter than the client's, so it reports how far it got instead of being resent). The client sends only to a socket that root owns in a directory nobody else can write (group-writable ancestors only for gid 0/1, which macOS's `/private/var/run` needs). `Deliverer.Write` sends through the socket when it answers and otherwise appends directly as before; only a direct append refused for permission (a restricted log whose collector is down) spools the line, to the account's private spool for that log (`~/.beacon/endpoint/spool/<log digest>`, 0600 under 0700), and the next line that gets through either way drains it. Root writers and per-user logs always write directly. The mode is `config.json` `log_access`, carried through repair and package upgrades (`BEACON_LOG_ACCESS` in the install scripts); install creates the `beacon-log` group (`internal/endpoint/loggroup`, getent/groupadd, dscl/dseditgroup) and `writer.RestrictSystemLog` makes the directory `root:beacon-log 02750`, the log and archives `0640` and the lock root-only `0600`, after writing the root-owned `.beacon-log-access` marker beside the log; a shared log is not narrowed in place but copied to fresh root-created files and renamed over, under its lock (bounded wait), because a descriptor opened while it was 0666 survives any chmod. A failed install restores the previous mode in its rollback, and a shared install removes a dead socket. The marker is what tells every root writer (`asymptoteobserve.RuntimeLogModes`) to keep the restricted modes. The OTLP receivers on loopback are not covered: any local process can still send OTLP, unattributed, so never claim more than the hook channel guarantees. Doctor's `runtime_log_access` covers the marker, the socket and pending spool. Unix sockets are local IPC, not a network channel, so the hooks-never-touch-the-network rule holds. On Windows the same mode runs over the named pipe `\\.\pipe\beacon-agent-ingest` (`localingest` `transport_windows.go`, go-winio): the collector creates it as the first instance, and when the name is taken (any account may create one) it reports a recoverable error and retries every few seconds rather than failing, so the rest of the collector stays up; it rejects remote clients and its DACL denies NETWORK and withholds `FILE_CREATE_PIPE_INSTANCE` from ordinary accounts, so it is not a network channel either; a client connects at identification level and sends only to a pipe owned by SYSTEM or Administrators; the server counts a connection against its account from the client process's token before reading and stamps the SID it reads by `ImpersonateNamedPipeClient` after the preamble (they must agree), with `Peer.UID` a string (decimal uid on Unix, SID on Windows) and the name from `LookupAccountSid`, bounded. Privileged writers there are SYSTEM and tokens with Administrators enabled (`CheckTokenMembership`; elevation for another group is not enough). The directory gets `sysacl.RestrictedLogDirDACL` (protected: SYSTEM and Administrators full, `beacon-log` local group read, nothing else; the lock SYSTEM and Administrators only) and everything below it is reset, because every account may bypass traverse checking; `writer.RestrictSystemLog` replaces every file directly in the directory (the log family under the lock; files outside it with another hard link are skipped) with a copy created with its final owner and DACL (`sysacl.CreateRestrictedFile`) and a POSIX-semantics rename, fails naming any file held open without sharing delete and then puts a log that was shared back to shared, and writes the marker last (on Windows it decides nothing for root writers, so a failed or killed run is not mistaken for a finished one). The marker counts there when SYSTEM or Administrators own it and no other account can write it. `loggroup` creates the local group with `net.exe` and looks it up qualified with the computer name. Doctor reads the restricted ACL (`writer.CheckRestrictedSystemLogACL`). `packaging/windows/smoke-restricted-log.ps1` runs in `windows-package-smoke` against the installed MSI with a real ordinary account. Hook and writer tests point `logging.EndpointIngest`/`writer.Ingest` at sockets of their own.- Beacon Cloud forwarding (`cli/beacon/internal/endpoint/asymptote`, `beacon endpoint connect`, `beacon endpoint asymptote`) is Vector-shaped: Beacon writes local JSONL, Vector ships runtime lines only from the connection point forward and reads inventory from the beginning to establish the endpoint's current baseline, plus the one bounded exception of the session backfill (below), and the `bcn_device_*` key stays only in `<BaseDir>/asymptote/vector-secrets.json` via Vector's secret backend. The onboarding wizard preselects Beacon Cloud, and confirming it connects this endpoint in the same command once the local install has succeeded; an endpoint that is already enrolled is never re-enrolled, because enrollment rotates the device key. Standard mode ships locally sanitized retained content; metadata-only uses local Vector transforms to remove prompts, responses, reasoning, tool arguments/results, tool descriptions/definitions, retrieval queries/documents, evaluation explanations, agent descriptions, stop sequences, approval/policy reasons, command output, raw fields, diffs, inventory content, and MCP definitions before buffering/upload. Every text-shaped event field must be classified in `metadata_fields_test.go` (`metadataOnlyRemoved`, each with its own `del()` in `pack/metadata-transforms.toml`, or `metadataOnlyKept`); a new field fails that test until it is, and `BEACON_TEST_VECTOR_BIN` runs the transform on an event with every field set. `vector.toml` is not rendered only at connect: `asymptote.ReconcileForwarder` re-renders it in place for a connected endpoint from the current pack with the enrollment's ingest URL and recorded privacy mode, validates it with the forwarder's own Vector exactly as connect does, atomically replaces it, and restarts the forwarder only when the content changed and the forwarder is running (a stopped one reads the new config when it next starts). It never enrolls, reads or rewrites the secrets file, makes a network request, or touches `vector-data/` (checkpoints stay, so pack changes must keep source ids and fingerprinting stable), and a rejected config is a warning that keeps the old one; it is a no-op when not connected, after an incomplete connect, without an installed unit, or where `ForwarderManager` is unsupported (supervised mode). `lifecycle.Install` runs it last when services are started (so install, repair and the Linux package upgrade), repair's teardown keeps the forwarder (`UninstallOptions.KeepManagedIngest`) instead of disconnecting it, and the macOS postinstall, which installs with `--no-start`, runs the hidden `beacon endpoint asymptote reconcile --system`. Keep the ingest URL `https://`, the wire contract aligned with `beacon-ingest` (`/v1/ingest/{runtime,inventory}` and `/v1/ingest/health`), and do not add another endpoint network channel. The cloud-sandbox shuttle is the bounded exception: only with `BEACON_ORIGIN=cloud`, it can upload new runtime lines to GCS, S3, or the same Beacon ingest contract because no Vector/service manager/browser/persistent disk exists there.- Session backfill (`cli/beacon/cmd/endpoint_backfill.go`; docs in `docs/cli/endpoint-install.mdx#session-backfill` and `docs/cli/endpoint-connect.mdx#session-backfill`): after every successful install (user or system mode), every session-store collector runs once with `CollectOptions.Since` (30 days; `sessionwindow.Recent` keeps those sessions, newest first, and never touches the cursors of the rest) and a shared `writer.Budget` (24 MiB, at most 12 MiB per runtime through `Budget.Sub`; a refused append returns `writer.ErrBudgetSpent`, the collector stops with cursors past only what was written, and a manual sync reads the rest). A new session-store collector takes both fields, reads its store only through `internal/sessionfs` (a test parses every collector package to enforce it), and joins `endpointBackfillRunners` and that test's list. Every connect, first or re-connect, user or system, runs the same sweep before enrollment (skipped when install just ran it) and, before the forwarder starts, `asymptote.StageBackfill` copies the window's `harness.collection_method=poll` lines into `cloud-backfill.jsonl` beside the runtime log, which the `beacon_backfill` Vector source (fingerprinted `device_and_inode`, so each atomically restaged copy is a new file) reads from the beginning into the runtime sink through the same privacy transform. Live hook/OTLP/plugin history before the connection point stays local. Re-connects restage, so a resend of already-shipped lines is expected and rests on the deterministic `event.id`; a privacy-mode change clears the checkpoints and the restage renames the new-mode copy over the old one (kept until then so the copy is always a new inode; deleted instead when nothing restages), and `disconnect` removes it. System mode runs the collectors under `withUserHome` for the active console user (`activeConsoleUser`), with cursors under the system base directory, and reports a skip when nobody is logged in; root is reading a home the console user controls, so the sweep runs under `sessionfs.Confine` (an `os.Root` on that home, files owned by the home's owner only, non-blocking opens that refuse FIFOs/devices, SQLite read from a private snapshot under `<SystemBaseDir>/state/backfill-snapshots`, retried until the database size/change counter and WAL header are unchanged across the copy, and refused past `sessionfs.MaxSnapshotBytes` (512 MiB with its WAL) with the runtime's sync command named in the report), and refused paths read as absent and are listed in the report. User-mode sync and backfill stay unconfined. The wizard's confirm screen names the upload (`WizardOptions.BackfillDays`). Dry-run, `--no-backfill` and `BEACON_BACKFILL=0` skip all of it; the cmd tests run with `BEACON_BACKFILL=0` set in `TestMain`.- `beacon endpoint install` has a full-screen onboarding wizard on interactive user TTYs. It signs in, preselects Beacon Cloud, requires an explicit choice to opt out to Local, and asks Managed users to choose Standard or Metadata-only privacy. Signing in alone still moves no telemetry. Confirming Beacon Cloud does: the confirm screen states that it installs Beacon and starts forwarding, and names what the selected privacy mode sends, so that screen is the consent point. The managed destination is recorded only after enrollment succeeds, so a failed enrollment leaves a working local install, prints `beacon endpoint connect` as the retry, and re-offers the question on the next install. The onboarding record is written only after `lifecycle.Install` returns, because a profile written first left a failed install looking onboarded and silently skipped the wizard on the retry. Explicit `install --connect` is unchanged. The wizard is skipped for system/root/CI/piped-stdin/dry-run or `BEACON_ONBOARDING=0`; those unattended paths must never gain an account or browser dependency. Legacy `BEACON_ONBOARDING_EMAIL`/`USAGE` submissions remain only for fleet compatibility. After the destination, the wizard shows an agent tools screen; every row is preselected (opt-out, space toggles). Beacon Cloud MCP is offered only with Beacon Cloud and runs the `beacon mcp connect` flow (`connectCloudMCP` with `yes`, OAuth, detected harnesses) only after the endpoint is connected (or already was), via `finishCloudSetup`; a failed enrollment skips it and names the retry. The Beacon Agent Skills are offered for either destination and installed user-wide into `~/.agents/skills` and, when Claude Code is set up, `~/.claude/skills` (`cli/beacon/internal/agentskills`, `beacon skills install|uninstall`; a `.beacon-managed` marker decides what Beacon may replace or remove; install and repair refresh only copies Beacon already wrote). Both run after `lifecycle.Install` returns and warn rather than fail. The answers are recorded as `onboarding.cloud_mcp`/`agent_skills`. Implementation lives in `cli/beacon/internal/onboarding`, `cli/beacon/cmd/endpoint_onboarding.go`, `cli/beacon/cmd/endpoint_install.go` and `cli/beacon/cmd/agent_tools.go`; keep `docs/cli/endpoint-onboarding.mdx` and `docs/cli/skills.mdx` in sync.diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdxindex 56f02768..b29a239b 100644--- a/docs/changelog/cli.mdx+++ b/docs/changelog/cli.mdx@@ -11,6 +11,8 @@ Stay up to date with the latest changes to the Agent Beacon CLI.## Unreleased+- **Linux package installs are restricted from the start** · A first install of the `.deb` or `.rpm` now sets up [restricted log access](/security/restricted-log-access) on its own: the `beacon-log` group, a `0640 root:beacon-log` log that only the collector writes, and hooks that send their events over the local socket, recorded under the account that sent them. Before, a fleet install by root (Salt, Ansible, an MDM script) left the log world-writable until someone ran `sudo beacon endpoint repair --system --log-access restricted`. Upgrades keep the mode an endpoint already has, so existing endpoints do not change; `BEACON_LOG_ACCESS=shared` installs a new endpoint shared. Log shippers that do not run as root need to join `beacon-log`.+- **Package install settings from `/etc/default/beacon`** · Configuration managers run `apt` or `dnf` without letting you set the package's environment, so the `BEACON_*` install settings could not reach a Salt or Ansible install. The Linux install script now also reads them from `/etc/default/beacon` or `/etc/sysconfig/beacon` (read, never run; root-owned and not writable by other accounts, or it is ignored with a warning). The environment still wins. See [Settings for configuration-manager installs](/platforms/linux#settings-for-configuration-manager-installs).- **Microsoft Sentinel forwarding with one command, on macOS, Linux and Windows** · `beacon endpoint sentinel forwarder install --system` runs the Vector bundled with Beacon as a system service that sends the runtime log to Microsoft Sentinel through the Logs Ingestion API, with a Microsoft Entra app registration (certificate or client secret). The credential is stored where only root can read it, or SYSTEM and Administrators on Windows, and is never a command-line argument. Vector checks the config before anything changes. Repair and package upgrades keep the forwarder and restart it on the new Vector; uninstall removes the service. Throttling, server errors and `401`/`403` answers are retried without a limit, and a line counts as sent only once Azure has accepted it. `status` and `remove` complete the commands. The pack's Logs Ingestion DCR template no longer needs a Data Collection Endpoint. See [Vector and the Logs Ingestion API](/log-forwarding/microsoft-sentinel#vector-and-the-logs-ingestion-api).- **The Windows MSI carries Vector** · The MSI now installs Vector 0.56.0 as `vector.exe` beside `beacon.exe` in `%ProgramFiles%\Beacon\bin`, as the macOS and Linux packages already carry it, checked against the same pinned checksums. Beacon finds it there. The package only installs it; nothing runs it until a forwarder is set up. Allow it alongside the other three programs if you run AppLocker or WDAC.- **Scheduled session sync** · `beacon endpoint install|repair --session-sync` turns on a job that runs every 15 minutes and reads new records from the agent runtimes' local session stores into the runtime log. It runs the same bounded, confined sweep install already runs once, so session-store data keeps reaching the log, and any forwarder reading it, after install. Off by default; repair and upgrades keep the setting, and `--no-session-sync` removes the job. See [Scheduled session sync](/cli/endpoint-install#scheduled-session-sync).diff --git a/docs/cli/endpoint-install.mdx b/docs/cli/endpoint-install.mdxindex 9d7527f2..e417b874 100644--- a/docs/cli/endpoint-install.mdx+++ b/docs/cli/endpoint-install.mdx@@ -310,7 +310,7 @@ sudo dseditgroup -o edit -a <account> -t user beacon-logThe log format and every event field stay the same, so a SIEM or forwarder that parses the log needs no change. Shippers that run as root, and the Beacon Cloud forwarder, keep working without one.-The mode is recorded in `config.json` as `log_access`, and in a root-owned `.beacon-log-access` marker beside the log. `beacon endpoint repair`, package upgrades, the Jamf `repair-hooks.sh` policy, and a reinstall after `uninstall --keep-logs` keep it. To go back, run `sudo beacon endpoint repair --system --log-access shared`; the log is writable by every account again at once. For package installs, set `BEACON_LOG_ACCESS=restricted` in the environment of the package's install script.+The mode is recorded in `config.json` as `log_access`, and in a root-owned `.beacon-log-access` marker beside the log. `beacon endpoint repair`, package upgrades, the Jamf `repair-hooks.sh` policy, and a reinstall after `uninstall --keep-logs` keep it. To go back, run `sudo beacon endpoint repair --system --log-access shared`; the log is writable by every account again at once. For package installs, set `BEACON_LOG_ACCESS=restricted` in the environment of the package's install script. A first install from the Linux `.deb` or `.rpm` is restricted without it (`BEACON_LOG_ACCESS=shared` opts out), and the Linux install script also reads its settings from `/etc/default/beacon` or `/etc/sysconfig/beacon` for configuration managers that cannot set its environment.What this does and does not change:diff --git a/docs/platforms/linux.mdx b/docs/platforms/linux.mdxindex 24a5b95a..1ffdf59f 100644--- a/docs/platforms/linux.mdx+++ b/docs/platforms/linux.mdx@@ -172,7 +172,7 @@ Vector comes with Beacon. The `.deb` and `.rpm` install it at `/opt/beacon/bin/v| Unpack | `beacon`, `beacon-hooks`, `beacon-otelcol` and `vector` under `/opt/beacon/bin` || System install | Config and collector config under `/etc/beacon/endpoint` || Service | `/etc/systemd/system/beacon-collector.service`, enabled and started |-| Runtime log | `/var/log/beacon-agent/runtime.jsonl` |+| Runtime log | `/var/log/beacon-agent/runtime.jsonl`, in [restricted log access](/security/restricted-log-access) on a first install: `0640 root:beacon-log`, written only by the collector || Agent runtime | Claude Code and Codex CLI settings for the installing user, pointed at `127.0.0.1:4317` |That last row is worth knowing about. A system-mode endpoint runs as root, so the install has to work out whose agent settings to configure, and the collector is useless if nothing exports to it. Beacon uses `SUDO_USER`, which is set for every normal install path, and falls back to asking logind who has an active session. If it cannot identify anyone, it says so instead of failing, and you can configure yourself later:@@ -181,7 +181,36 @@ That last row is worth knowing about. A system-mode endpoint runs as root, so thsudo beacon endpoint user-config repair-installed --system```-Other users on the same machine run the same command for themselves. They all export to the same collector and the same log. That is why `/var/log/beacon-agent/runtime.jsonl` is group- and world-writable: hooks run as the logged-in user and append to it directly. To stop other accounts from modifying or reading it, install with [`--log-access restricted`](/cli/endpoint-install#restricted-log-access): the collector becomes the only writer and hooks send their events to it over a local socket.+Other users on the same machine run the same command for themselves. They all export to the same collector and the same log. A first package install sets the log to [restricted access](/cli/endpoint-install#restricted-log-access): the collector is the only writer, hooks hand their events to it over a local socket and are recorded under the account the kernel says sent them, and only root and the `beacon-log` group can read the log. A package upgrade keeps whatever mode the endpoint already has, so an endpoint installed from an earlier package stays shared until you switch it with `sudo beacon endpoint repair --system --log-access restricted`. To install with the older shared log instead, where every account appends to the file directly, set `BEACON_LOG_ACCESS=shared` (see below).++### Settings for configuration-manager installs++Salt's `pkg.installed`, Ansible's `apt` and `dnf` modules, Puppet and Chef run the package manager for you and give you no way to set the environment of the package's install script. Write the settings to `/etc/default/beacon` (Debian, Ubuntu) or `/etc/sysconfig/beacon` (Fedora, RHEL) before the package is installed, and the install script reads them:++```bash title="/etc/default/beacon"+BEACON_LOG_ACCESS=restricted+BEACON_ENDPOINT_HARNESSES=claude,codex,cursor+BEACON_SESSION_SYNC=1+```++```yaml title="Salt state"+/etc/default/beacon:+ file.managed:+ - user: root+ - group: root+ - mode: "0600"+ - contents: |+ BEACON_LOG_ACCESS=restricted++beacon:+ pkg.installed:+ - sources:+ - beacon: salt://beacon/beacon_<version>_linux_amd64.deb+ - require:+ - file: /etc/default/beacon+```++The file is read, not run: each line is a `KEY=VALUE` (an `export` in front and quotes around the value are allowed), and only the install settings the script documents are taken (`BEACON_LOG_ACCESS`, `BEACON_ENDPOINT_HARNESSES`, `BEACON_OTLP_GRPC_PORT`, `BEACON_OTLP_HTTP_PORT`, `BEACON_SESSION_SYNC`, `BEACON_SERVICE`, `BEACON_NO_START`, `BEACON_COLLECTOR` and the `BEACON_SPLUNK_*` settings). Because the install script runs as root, the file is ignored, with a warning, unless root owns it and no other account can write it. A variable set in the install script's environment wins over the file. The file is read on every install and upgrade, so keep it in step with what you want the endpoint to be; an unset `BEACON_LOG_ACCESS` on an upgrade keeps the mode the endpoint has.## Managing the servicediff --git a/docs/security/restricted-log-access.mdx b/docs/security/restricted-log-access.mdxindex 4a770280..5f4048dc 100644--- a/docs/security/restricted-log-access.mdx+++ b/docs/security/restricted-log-access.mdx@@ -59,7 +59,7 @@ On an endpoint that is already installed, including one installed from the signesudo beacon endpoint repair --system --log-access restricted```-For package installs you can instead set `BEACON_LOG_ACCESS=restricted` in the environment of the package's install script.+For package installs you can instead set `BEACON_LOG_ACCESS=restricted` in the environment of the package's install script. On Linux a first install from the `.deb` or `.rpm` is restricted already, with no setting; an upgrade keeps the mode the endpoint has, and `BEACON_LOG_ACCESS=shared` installs a new endpoint shared instead. A configuration manager that cannot set the install script's environment (Salt, Ansible, Puppet, Chef) can put the setting in `/etc/default/beacon` or `/etc/sysconfig/beacon`; see [Settings for configuration-manager installs](/platforms/linux#settings-for-configuration-manager-installs).Switching replaces the log and its archives with fresh copies, so a file handle another account opened while the log was shared stops reaching it. Existing events are kept.diff --git a/packaging/linux/install-endpoint.sh b/packaging/linux/install-endpoint.shindex c7240aa1..2d8eba53 100755--- a/packaging/linux/install-endpoint.sh+++ b/packaging/linux/install-endpoint.sh@@ -6,6 +6,79 @@# mixed fleet has one contract rather than two.set -eu+# Settings a configuration manager drops before installing the package. Salt's pkg.installed,+# Ansible's apt/dnf modules, Puppet and Chef all run the package manager without letting the caller+# set the environment of the maintainer scripts, so the BEACON_* variables below could not reach a+# centrally deployed install any other way. /etc/default is the Debian convention and+# /etc/sysconfig the RHEL one; the first that exists is read.+#+# The file is read, never sourced: only the variables this script documents are taken, as plain+# KEY=VALUE lines (an optional `export`, matching single or double quotes, comments), so nothing in+# it runs. It is skipped unless root owns it and no one else can write it, because this script runs+# as root from the package manager. A variable already set in the environment wins over the file.+BEACON_DEFAULTS_FILE="${BEACON_DEFAULTS_FILE:-}"+if [ -z "$BEACON_DEFAULTS_FILE" ]; then+ for candidate in /etc/default/beacon /etc/sysconfig/beacon; do+ if [ -f "$candidate" ]; then+ BEACON_DEFAULTS_FILE="$candidate"+ break+ fi+ done+fi++beacon_defaults_trusted() {+ # Owner uid and permission bits, from GNU stat (every Linux userland Beacon packages for) or+ # BusyBox, which accepts the same format.+ meta="$(stat -c '%u %a' "$1" 2>/dev/null)" || return 1+ owner="${meta%% *}"+ mode="${meta##* }"+ # BEACON_DEFAULTS_OWNER lets the packaging tests run as an ordinary account.+ [ "$owner" = "${BEACON_DEFAULTS_OWNER:-0}" ] || return 1+ # The last two octal digits are group and other: neither may include write (2, 3, 6, 7).+ case "$mode" in+ *[2367]?|*[2367]) return 1 ;;+ esac+ return 0+}++if [ -n "$BEACON_DEFAULTS_FILE" ] && [ -f "$BEACON_DEFAULTS_FILE" ]; then+ if beacon_defaults_trusted "$BEACON_DEFAULTS_FILE"; then+ while IFS= read -r line || [ -n "$line" ]; do+ line="${line#"${line%%[![:space:]]*}"}"+ case "$line" in+ ''|'#'*) continue ;;+ export\ *) line="${line#export }"; line="${line#"${line%%[![:space:]]*}"}" ;;+ esac+ case "$line" in+ *=*) ;;+ *) continue ;;+ esac+ key="${line%%=*}"+ value="${line#*=}"+ case "$key" in+ BEACON_ENDPOINT_HARNESSES|BEACON_OTLP_GRPC_PORT|BEACON_OTLP_HTTP_PORT|BEACON_COLLECTOR|\+ BEACON_NO_START|BEACON_SERVICE|BEACON_LOG_ACCESS|BEACON_SESSION_SYNC|\+ BEACON_SPLUNK_HEC_ENDPOINT|BEACON_SPLUNK_HEC_TOKEN|BEACON_SPLUNK_INDEX|BEACON_SPLUNK_SOURCE|\+ BEACON_SPLUNK_SOURCETYPE|BEACON_SPLUNK_INSECURE_SKIP_VERIFY|BEACON_SPLUNK_CA_FILE) ;;+ *) continue ;;+ esac+ # Trailing whitespace, then one pair of matching quotes.+ value="${value%"${value##*[![:space:]]}"}"+ case "$value" in+ \"*\") value="${value#\"}"; value="${value%\"}" ;;+ \'*\') value="${value#\'}"; value="${value%\'}" ;;+ esac+ # $key is one of the names above, so the indirection below cannot evaluate anything else.+ eval "already=\${$key+set}"+ if [ -z "$already" ]; then+ export "$key=$value"+ fi+ done <"$BEACON_DEFAULTS_FILE"+ else+ echo "beacon: ignoring $BEACON_DEFAULTS_FILE: it must be owned by root and writable by no one else" >&2+ fi+fi+if [ -z "${BEACON_BIN:-}" ]; thenif [ -x "/opt/beacon/bin/beacon" ]; thenBEACON_BIN="/opt/beacon/bin/beacon"@@ -30,6 +103,16 @@ BEACON_SPLUNK_CA_FILE="${BEACON_SPLUNK_CA_FILE:-}"# shared or restricted; empty keeps the mode the endpoint already has, so a package upgrade never# changes it.BEACON_LOG_ACCESS="${BEACON_LOG_ACCESS:-}"+# A first install from the package defaults to restricted: a package is installed by root for the+# whole machine, often by a configuration manager across a fleet, and that is the install that+# should make the collector the only writer of the system log without a second step. "First" means+# there is no system config yet; an upgrade, or a reinstall over a kept config, keeps whatever mode+# the endpoint has, so this never narrows (or widens) a running endpoint behind its operator's back.+# BEACON_LOG_ACCESS=shared opts a new install out.+BEACON_SYSTEM_CONFIG="${BEACON_SYSTEM_CONFIG:-/etc/beacon/endpoint/config.json}"+if [ -z "$BEACON_LOG_ACCESS" ] && [ ! -e "$BEACON_SYSTEM_CONFIG" ]; then+ BEACON_LOG_ACCESS=restricted+fi# 1 turns the scheduled session sync on and 0 turns it off; empty keeps what the endpoint already# has, so a package upgrade never changes it.BEACON_SESSION_SYNC="${BEACON_SESSION_SYNC:-}"diff --git a/packaging/linux/smoke-package.sh b/packaging/linux/smoke-package.shindex 87470e4a..be811c23 100755--- a/packaging/linux/smoke-package.sh+++ b/packaging/linux/smoke-package.sh@@ -249,6 +249,37 @@ if failed:print(f"ok: doctor reports no failures across {len(checks)} checks")PY+# A first package install lands in restricted log access with no second step: the collector is the+# only writer, the log is 0640 root:beacon-log, and hooks hand their events to the ingest socket.+# This is what a configuration manager (Salt pkg.installed, Ansible apt) gets, since it cannot pass+# BEACON_LOG_ACCESS through to the postinstall.+LOG=/var/log/beacon-agent/runtime.jsonl+mode="$(docker exec "$CONTAINER" cat /etc/beacon/endpoint/config.json | python3 -c 'import json, sys; print(json.load(sys.stdin).get("log_access", ""))')"+[ "$mode" = restricted ] || { echo "config.json log_access is '$mode' after a first install, want restricted" >&2; exit 1; }+perms="$(docker exec "$CONTAINER" stat -c '%a %U:%G' "$LOG")"+[ "$perms" = "640 root:beacon-log" ] || { echo "$LOG is $perms, want 640 root:beacon-log" >&2; exit 1; }+docker exec "$CONTAINER" test -S /var/run/beacon-agent/ingest.sock || {+ echo "the collector is not serving /var/run/beacon-agent/ingest.sock" >&2; exit 1; }+if docker exec "$CONTAINER" su - "$SMOKE_USER" -c "cat $LOG" >/dev/null 2>&1; then+ echo "$SMOKE_USER can read $LOG; restricted access did not apply" >&2; exit 1+fi+echo "ok: a first package install is restricted (640 root:beacon-log, ingest socket up)"++# The installed hook, run as the user exactly as Claude Code runs it, reaches the log through the+# socket and is recorded under the account the kernel says sent it.+HOOK_CMD="$(docker exec "$CONTAINER" cat "$SETTINGS" | python3 -c '+import json, sys+print(json.load(sys.stdin)["hooks"]["UserPromptSubmit"][0]["hooks"][0]["command"])')"+docker exec "$CONTAINER" su - "$SMOKE_USER" -c "printf '%s' '{\"session_id\":\"smoke-restricted\",\"hook_event_name\":\"UserPromptSubmit\",\"prompt\":\"smoke\",\"cwd\":\"/tmp\"}' | $HOOK_CMD" >/dev/null 2>&1 || {+ echo "the installed prompt hook failed for $SMOKE_USER" >&2; exit 1; }+recorded="$(docker exec "$CONTAINER" sh -c "grep smoke-restricted $LOG" | python3 -c '+import json, sys+users = {json.loads(line).get("user", {}).get("name", "") for line in sys.stdin if line.strip()}+print(",".join(sorted(users)))')"+[ "$recorded" = "$SMOKE_USER" ] || {+ echo "the hook event was recorded as '$recorded', want $SMOKE_USER" >&2; exit 1; }+echo "ok: $SMOKE_USER's hook event reached the restricted log through the socket, as $SMOKE_USER"+# Reinstalling the same package is an upgrade as far as both package managers are concerned, and it# is the exact sequence `beacon endpoint update --apply` performs. It is worth its own assertion# because the old package's pre-removal script runs during an upgrade -- and on rpm it runs *after*@@ -267,6 +298,8 @@ after_upgrade="$(docker exec "$CONTAINER" systemctl is-active beacon-collector.s}docker exec "$CONTAINER" test -f /etc/beacon/endpoint/config.json || {echo "an upgrade must not remove the config" >&2; exit 1; }+mode="$(docker exec "$CONTAINER" cat /etc/beacon/endpoint/config.json | python3 -c 'import json, sys; print(json.load(sys.stdin).get("log_access", ""))')"+[ "$mode" = restricted ] || { echo "an upgrade changed log_access to '$mode'" >&2; exit 1; }echo "ok: upgrade left the service running and the config in place"# Removal must stop the service while the binaries it points at still exist, and must not destroydiff --git a/packaging/linux/test-endpoint-scripts.sh b/packaging/linux/test-endpoint-scripts.shnew file mode 100644index 00000000..e189a98e--- /dev/null+++ b/packaging/linux/test-endpoint-scripts.sh@@ -0,0 +1,135 @@+#!/bin/sh+# Checks packaging/linux/install-endpoint.sh without installing anything: a stub stands in for the+# beacon binary and records the arguments the script would run it with.+#+# sh packaging/linux/test-endpoint-scripts.sh+set -eu++ROOT_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")/../.." && pwd)"+INSTALL_SCRIPT="$ROOT_DIR/packaging/linux/install-endpoint.sh"+TMP_DIR="$(mktemp -d)"+trap 'rm -rf "$TMP_DIR"' EXIT INT TERM++for script in "$ROOT_DIR"/packaging/linux/*.sh "$ROOT_DIR"/packaging/linux/nfpm/*.sh; do+ case "$(head -n 1 "$script")" in+ *bash*) bash -n "$script" ;;+ *) sh -n "$script" ;;+ esac+done++STUB="$TMP_DIR/beacon"+ARGS="$TMP_DIR/args"+cat >"$STUB" <<'STUB'+#!/bin/sh+printf '%s\n' "$@" >"$BEACON_TEST_ARGS"+STUB+chmod 755 "$STUB"++failures=0+fail() {+ echo "FAIL: $*" >&2+ failures=$((failures + 1))+}++# run_install [VAR=value ...] runs the install script in a clean environment pointed at the stub,+# with no system config unless the caller makes one, and no defaults file unless it names one.+run_install() {+ rm -f "$ARGS"+ env -i PATH="$PATH" HOME="$TMP_DIR" BEACON_BIN="$STUB" BEACON_TEST_ARGS="$ARGS" \+ BEACON_COLLECTOR="$TMP_DIR/collector" \+ BEACON_SYSTEM_CONFIG="$TMP_DIR/etc/config.json" \+ BEACON_DEFAULTS_FILE="$TMP_DIR/none" \+ BEACON_DEFAULTS_OWNER="$(id -u)" \+ "$@" sh "$INSTALL_SCRIPT" >"$TMP_DIR/out" 2>&1 || { cat "$TMP_DIR/out" >&2; return 1; }+}++# flag_value FLAG prints the value passed after FLAG, or nothing when it was not passed.+flag_value() {+ awk -v flag="$1" 'found { print; exit } $0 == flag { found = 1 }' "$ARGS"+}++has_flag() {+ grep -qx -- "$1" "$ARGS"+}++expect_log_access() {+ got="$(flag_value --log-access)"+ [ "$got" = "$1" ] || fail "$2: --log-access is '$got', want '$1'"+}++# A first install, with no system config, defaults to restricted.+run_install+expect_log_access restricted "first install"+[ "$(sed -n 1,3p "$ARGS" | tr '\n' ' ')" = "endpoint install --system " ] || fail "first install: not an endpoint install --system: $(tr '\n' ' ' <"$ARGS")"++# An upgrade (a system config exists) passes no mode, so the endpoint keeps the one it has.+mkdir -p "$TMP_DIR/etc"+echo '{}' >"$TMP_DIR/etc/config.json"+run_install+has_flag --log-access && fail "upgrade: passed --log-access $(flag_value --log-access); the existing mode must be kept"+rm -f "$TMP_DIR/etc/config.json"++# The environment opts a first install out, and can ask for restricted on an upgrade.+run_install BEACON_LOG_ACCESS=shared+expect_log_access shared "first install with BEACON_LOG_ACCESS=shared"+echo '{}' >"$TMP_DIR/etc/config.json"+run_install BEACON_LOG_ACCESS=restricted+expect_log_access restricted "upgrade with BEACON_LOG_ACCESS=restricted"+rm -f "$TMP_DIR/etc/config.json"++# A defaults file supplies settings a configuration manager cannot pass through the environment.+DEFAULTS="$TMP_DIR/default-beacon"+cat >"$DEFAULTS" <<'CONF'+# Written by Salt before pkg.installed.+BEACON_LOG_ACCESS=shared+export BEACON_ENDPOINT_HARNESSES="claude,codex,cursor"+ BEACON_SESSION_SYNC='1'+BEACON_OTLP_HTTP_PORT=4319+NOT_A_BEACON_SETTING=1+BEACON_BIN=/tmp/evil+PATH=/tmp/evil+BEACON_SERVICE=$(touch /tmp/beacon-defaults-ran)+not even an assignment+CONF+chmod 600 "$DEFAULTS"+run_install BEACON_DEFAULTS_FILE="$DEFAULTS"+expect_log_access shared "defaults file"+[ "$(flag_value --harness)" = "claude,codex,cursor" ] || fail "defaults file: --harness is '$(flag_value --harness)'"+[ "$(flag_value --otlp-http-port)" = "4319" ] || fail "defaults file: --otlp-http-port is '$(flag_value --otlp-http-port)'"+has_flag --session-sync || fail "defaults file: BEACON_SESSION_SYNC='1' did not pass --session-sync"+# Only documented install settings are taken: the binary still came from the environment, and the+# command substitution was passed as an inert string rather than run.+[ -s "$ARGS" ] || fail "defaults file: BEACON_BIN in the file replaced the binary"+[ "$(flag_value --service)" = '$(touch /tmp/beacon-defaults-ran)' ] || fail "defaults file: --service is '$(flag_value --service)'"+[ -e /tmp/beacon-defaults-ran ] && fail "defaults file: a value was executed"++# The environment wins over the file.+run_install BEACON_DEFAULTS_FILE="$DEFAULTS" BEACON_LOG_ACCESS=restricted+expect_log_access restricted "environment over defaults file"++# Without a mode, a defaults file still gets the first-install default.+printf 'BEACON_SESSION_SYNC=0\n' >"$DEFAULTS"+run_install BEACON_DEFAULTS_FILE="$DEFAULTS"+expect_log_access restricted "defaults file without a mode"+has_flag --no-session-sync || fail "defaults file: BEACON_SESSION_SYNC=0 did not pass --no-session-sync"++# A file anyone else can write is ignored, loudly: the script runs as root.+printf 'BEACON_LOG_ACCESS=shared\n' >"$DEFAULTS"+for mode in 620 602 660 666 622; do+ chmod "$mode" "$DEFAULTS"+ run_install BEACON_DEFAULTS_FILE="$DEFAULTS"+ expect_log_access restricted "defaults file mode $mode"+ grep -q "ignoring $DEFAULTS" "$TMP_DIR/out" || fail "defaults file mode $mode: no warning"+done+chmod 644 "$DEFAULTS"+run_install BEACON_DEFAULTS_FILE="$DEFAULTS"+expect_log_access shared "defaults file mode 644"+# ...and so is one owned by another account.+run_install BEACON_DEFAULTS_FILE="$DEFAULTS" BEACON_DEFAULTS_OWNER=12345+expect_log_access restricted "defaults file owned by someone else"++if [ "$failures" -ne 0 ]; then+ echo "$failures check(s) failed" >&2+ exit 1+fi+echo "linux endpoint script checks passed"