Repository navigation
fix: allow the 1Password agent only for a terminal login shell - #36
Merged
Merged
Conversation
Generated-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:5540cd94a5c67150;started_at=2026-11-15T17:46:19Z;surface=cli
Generated-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:5540cd94a5c67150;started_at=2026-11-15T17:46:19Z;surface=cli
Generated-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:5540cd94a5c67150;started_at=2026-11-15T17:46:19Z;surface=cli
Generated-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:5540cd94a5c67150;started_at=2026-11-15T17:46:19Z;surface=cli
Generated-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:5540cd94a5c67150;started_at=2026-11-15T17:46:19Z;surface=cli
Generated-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:5540cd94a5c67150;started_at=2026-11-15T17:46:19Z;surface=cli
Generated-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:5540cd94a5c67150;started_at=2026-11-15T17:46:19Z;surface=cli
tbhb-agent
force-pushed
the
ssh-agent-allowlist
branch
from
November 24, 2026 03:56
a888d98 to
78001cd
Compare
Generated-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:5540cd94a5c67150;started_at=2026-11-15T17:46:19Z;surface=cli
tbhb-agent
added a commit
that referenced
this pull request
Nov 24, 2026
Why `tmux switch-client` copies the client's `SSH_AUTH_SOCK` into the target session and fires neither the new-session hook nor the attach hook. A harness-started server keeps the 1Password socket in that session, and later panes inherit it. cr2 reported this on #36. Coordination ruled it security debt, tracker row DF-S1. Behavior change A `client-session-changed` hook runs the same scrub as the attach hook. It removes a 1Password `SSH_AUTH_SOCK`, `CLAUDECODE` and `CODEX_HOME` from the session the client switched to. A forwarded agent socket remains. Decisions The hook reuses the attach hook's command. A new `tmux` server still starts from the scrubbed global environment. Needs human judgment None. Risk Only `.tmux.conf` changes. A new hook can't affect a login shell. Removing the line restores the old behavior. Verification On a throwaway server started with `CLAUDECODE=1`, a terminal client attached to one session with a 1Password `SSH_AUTH_SOCK` and switched to another. Without the hook, the target session held the socket. With the hook, it didn't. Reloading with `source-file` is a separate debt, DF-S2, and remains open. Generated-by: LLM effort=medium;harness=claude-code:2.1.331;model=anthropic:claude-sonnet-5-5;session=sha-256-64:5540cd94a5c67150;started_at=2026-11-15T17:46:19Z;surface=cli
tbhb-agent
added a commit
that referenced
this pull request
Nov 25, 2026
Why Hosts update their chezmoi source only when someone pulls by hand, and nothing reports their distance from `main`. Eight macOS and Linux hosts fell up to 55 commits behind `main` before a manual fast-forward to af84e0e, and fixes such as #36 and #38 reached them late. Behavior change Hourly, a `launchd` agent on macOS or a `systemd` user timer on Linux runs `~/.local/bin/tbhb-dotfiles-drift`. It fetches `origin main` into a private ref and compares the chezmoi source tree with it, using `git` alone. One line per run: drift=0|1 behind=N dirty=N branch=B src_sha=S origin_sha=O A dirty tree, a branch other than `main`, or a commit that differs from the ref exits 1. A failed step prints `drift=1 error=<step>` and exits 2. It never merges, checks out, or applies. Its `git` calls take no optional locks and skip the `fsmonitor` hook. The fetch skips tags, `FETCH_HEAD`, auto maintenance and commit graphs, and its own output goes to stderr. Inherited `git -c` settings, the agent socket, credential helpers, prompts and the user `ssh` config all stay out. Linux logs to the journal as `tbhb-dotfiles-drift`, and macOS to `~/Library/Logs/tbhb-dotfiles-drift.log`. Loading takes one manual apply per host. Decisions - Chose a read-only report over an unattended update after three review rounds found ways an unattended apply could write files it must leave alone. Updating stays a manual apply. - Chose `git` alone over `chezmoi status`, which runs every `modify_` script, even an ignored one. - Chose a fixed one-line output with an exit code, which a log alert can match without parsing. - Chose a private fetch ref over `FETCH_HEAD`, which another fetch in the same tree can overwrite. - Skipped the job for a home path with whitespace, quotes, a backslash, `%` or `$`, in place of escaping it for `systemd` and the shell. The units, the agent file, and the loader render empty there. - Set `SyslogIdentifier` because the host log collector keys journal lines on that field. Needs human judgment - The host log collector misses these lines today. On Linux the journal allowlist in the ops `host_telemetry` role matches only fixed identifiers and system units, and the identifier needs adding there. On macOS no collector exists. Whether the collector can read user journals is unverified. - On Linux the timer runs only while the user manager is alive. Lingering on each host is a separate request. Risk Open tech debt: - The job compares the source only, not live home files. - Nobody has tested live loading or log collection. - The fetch also writes objects and ref logs. - The path guard misses Unicode spaces and backticks. - No test catches an extra `FETCH_HEAD` read. - On `git` before 2.39, the job prints `error=symbolic_ref`. - With no user manager or login session, the loader warns and exits 0, and loading waits for a unit change. To stop the job, unload `dev.tbhb.dotfiles-drift` with `launchctl` or run `systemctl --user disable --now tbhb-dotfiles-drift.timer`. Verification `bazel test //...` passes, except a local `//:reuse_test` miss on ignored files. The test runs the script in a throwaway origin, clone, and home. Wrappers fail it on any writing `git` verb, any chezmoi call but `source-path`, or any run of a `run_onchange_` or `run_always_` script. Cases cover sync, behind, ahead, edits, an untracked `modify_` script, off `main`, a branch aliased to `main`, detached, and a tag named `main`. Others cover a concurrent fetch, noisy fetch output, an unchanged index under an `fsmonitor` hook, inherited `git -c` and `GIT_CONFIG_*` settings, a failing source lookup, fetch or `symbolic-ref`, and `devcontainer` runs of the script and the loader. Rendering checks cover empty output in a `devcontainer` and for odd home paths, escaping in the agent file, and `systemd-analyze verify` where it exists. It fails when a mutation adds a merge, an apply, a `run_always_` call, a `chezmoi status` call, or fetch output on stdout. Removing a scrub, the lock or hook flags, `--no-tags`, `--no-recurse`, a `devcontainer` exit, the odd-path skip, or the agent-file escape also makes it fail. Generated-by: LLM effort=medium;harness=claude-code:2.1.331;model=anthropic:claude-opus-5-5;session=sha-256-64:5540cd94a5c67150;started_at=2026-11-24T22:36:43Z;subagent=sha-256-64:d6a3aa5c8a2fb50c;surface=cli Assisted-by: LLM effort=medium;harness=claude-code:2.1.331;model=anthropic:claude-sonnet-5-5;session=sha-256-64:5540cd94a5c67150;started_at=2026-11-15T17:46:19Z;surface=cli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The ssh guard keys on agent markers (
SSH_CONNECTION,CLAUDECODE,CODEX_HOME). A process without them still reaches the 1Password agent and raises Touch ID on an unwatched screen. Scrubbed environments, hooks, gate wrappers and scheduled jobs all lack the markers.Behavior change
The 1Password agent is now an allowlist. A login shell on a terminal, with none of
SSH_CONNECTION,CLAUDECODEandCODEX_HOME, exportsTBHB_OP_AGENT=1,SSH_AUTH_SOCKandOP_ACCOUNT.~/.ssh/configsetsIdentityAgent noneunless that marker is1, and git signs through a wrapper that drops an inherited 1Password socket under the same rule. Intmux, the server and each new or attached session drop the marker and a 1Password socket, and each pane's login shell sets them again for the operator. A harness-started server loses itsCLAUDECODEandCODEX_HOMEtoo. The operator's panes no longer inherit an agent identity. A headless login shell clears an inherited marker.Decisions
Chose a marker plus the existing agent-variable check over the marker alone, because a harness started from a terminal inherits the marker. Chose not to restrict the
opbinary itself, because the repo has noopplugin or alias setup. The onlyopsetting isOP_ACCOUNT, which now follows the same rule.Needs human judgment
Accepted security debt, ruled by Coordination. Any child of the operator's terminal inherits the marker. A pane that an agent opens with
tmux new-windowon a harness-started server gets a login shell with the marker and the socket. The first command given tonew-sessionkeeps the socket too, sincetmuxspawns it before the hook runs. Aswitch-clientcan copy the socket back into the target session. A scrubbed process on a pseudo-terminal that runszsh -lalso gets the marker.Risk
Tier 2 (agent ssh trust). A terminal shell that sets none of the variables keeps the agent. One that opens without a terminal, such as a login shell run by a launcher, loses it until it runs
export TBHB_OP_AGENT=1. Revert the PR to roll back.Verification
bazelisk test //:ssh_agent_guard_test //:render_test //:cspell_testpasses. The guard test renders the config and runsenv -i ssh -Gfor seven environments and four-Jhop cases. It also runs the signing wrapper against a stubssh-keygenfor five. Against the old config three ssh cases fail. A throwawaytmuxserver started with the marker and a 1Password socket shows neither inshow-environment -gafter sourcing the rendered conf. A server started withCLAUDECODE=1gives a new pane a login shell with the marker and noCLAUDECODE.Opened-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:5540cd94a5c67150;surface=cli
Generated-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:5540cd94a5c67150;started_at=2026-11-15T17:46:19Z;surface=cli