Repository navigation
Keep the job environment off sudo's command line, and the host /tmp out of the view - #1334
Conversation
…ut of the view Two gaps #1333 left in the launch chain. The job's whole environment crossed as `env -i NAME=VALUE …` arguments on the `sudo` command line. `sudo` logs its command line, and any process on the host can read it from `/proc`, so on a self-hosted runner a secret set in job-level `env:` ended up in the system log. The launcher now writes the environment, NUL-separated, to a 0600 file in the private directory; `enter_view.py` reads it without following links, removes it before doing anything that can fail, and `execve`s with it. Standard input would have avoided the file, but `sudo` can relay input through a pty in canonical mode, which mangles it. SRT always allows writes to `/tmp/claude` and binds the host's whenever one exists at launch, resolving the bind through the namespace it was launched from. A world-writable host `/tmp/claude` therefore came back writable under SRT's own private `/tmp`, and a write to it outlived the run. `enter_view.py` now mounts an empty `/tmp` in the view's namespace, so SRT never finds the host's. All of `/tmp` rather than only that path: nothing SRT runs uses the host's `/tmp`, since its sockets follow `TMPDIR`. The hosted test checks both on a real runner: the env file is gone after the launch, a job-only variable reaches the agent but not `sudo`'s journal (whose entry for the launch it also requires, so the absence means something), and a write to `/tmp/claude` from inside never reaches a world-writable host one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
tend-agent
left a comment
There was a problem hiding this comment.
test-sandbox is red on this commit, and the cause is in the diff.
Root now writes a __pycache__ into the action checkout. enter_view.py is the one file the launch runs as root out of ACTION_PATH, and it now imports a sibling module, so CPython drops a root-owned shared/steps/__pycache__/_safe_files.cpython-312.pyc beside it — -E -s suppresses environment variables and user site, not bytecode writing. The unprivileged rm -rf "$private_action" after the Codex launch in proxy/test-setup-sandbox.sh then fails, which is the job's exit 1:
rm: cannot remove '/home/runner/work/_temp/tend-private-runtime.nxFcAx/shared/steps/__pycache__/_safe_files.cpython-312.pyc': Permission denied
Outside CI it leaves root-owned files in the action checkout on every run; on a self-hosted runner, where no VM teardown clears them, the runner user can't either. Adding -B beside the "-E", "-s", pair in launch_sandbox_runtime.py's argv is the fix — I confirmed locally that python3 -E -s writes the directory and python3 -E -s -B doesn't.
The /tmp comment in sandbox_runtime.mjs now asserts what this PR had to go add. The block above denyRead: ["/tmp"] says "nothing reaches the runner's /tmp (a cache action there would save it)" — the /tmp/claude bind is precisely the case where it did, and the property holds from here on because of the new tmpfs in enter_view.py, not because of denyRead. Left standing, it tells the next reader of the view's /tmp mount that the mount is redundant.
A shipped instruction still describes the launch this PR removes. The Secrets bullet in plugins/tend-ci-runner/skills/run-tend/SKILL.md reads "The outer sudo env launch carries the agent's environment in its argv, so process listings still expose dummies and any consumer-supplied value." That text loads into every session in every consumer repo, and it is the stated reason for the restriction around it. printenv and /proc/self/environ still carry the rule; the argv claim no longer does.
The environment handoff itself reads correctly to me — NUL separation keeps = and newlines in values, last-entry-wins matches env, the no-follow read plus the unlink before anything fallible is the right order, and os.execve takes the bytes mapping unchanged. All three fixes above land outside this diff's hunks, so there's nothing to suggest inline; say the word and I'll push them as one commit.
`enter_view.py` runs as root straight from the action checkout, and the previous commit had it import `_safe_files` for a no-follow read. That made a second file root executes, and the import wrote a root-owned `__pycache__` into the checkout, which the runner's own cleanup then could not remove — `test-sandbox` failed on exactly that. The read is now an inline `O_NOFOLLOW` open, and a test holds `enter_view.py` to the standard library, since the failure is otherwise visible only on a real runner. Two texts the review found stale: - `sandbox_runtime.mjs` credited `denyRead: ["/tmp"]` alone for keeping the runner's /tmp out of reach; the `/tmp/claude` bind was the case where it didn't, and the property now also rests on `enter_view.py`'s empty /tmp. - The shipped `run-tend` skill told every session that the `sudo env` launch carries the agent's environment in its argv. It no longer does; the rule against printing a process's environment or command line stands without that sentence. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Version bump, lockfile, and the `## 0.2.12` section the release workflow publishes verbatim as the GitHub Release notes. 17 commits since 0.2.11. The headline is the sandbox layout: the agent runs in the job's own checkout and home through a copy-on-write view, so what a consumer's `setup:` steps prepare reaches the agent without being rebuilt in `sandbox_setup:`, and the job environment crosses into the sandbox in a `0600` file rather than on `sudo`'s command line ([#1333](#1333), [#1334](#1334)). Alongside it: `/tmp` is writable inside the sandbox as scratch private to the run ([#1324](#1324)), CI sessions ignore the bot's claude.ai skills, plugins and connectors ([#1328](#1328)), the SRT launch retries a transient bridge-socket failure ([#1327](#1327)), and a cancelled gating check polls as unverified rather than green ([#1323](#1323)). Each bullet was written from the commit's diff rather than its subject. No real agent session has run through the new view yet (CI's `test-sandbox` lifecycle runs stub `claude`/`codex` binaries), so the release's live check after tagging is the first one that does. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Deploys 0.2.12 to tend itself, the last step of the release before its live check. The pin moves from `@0.2.11` to `@0.2.12` across the nine generated workflows. That brings in the agent running in the job's own checkout and home through a copy-on-write view ([#1333](#1333), [#1334](#1334)), plus the rest of the [0.2.12 release](https://github.com/max-sixty/tend/releases/tag/0.2.12). The generated files themselves change in three lines each at most: the header's version, `setup-uv`'s uv 0.12.17, and the review workflow's checkout comment. `review-reviewers.yaml` is hand-maintained, so `init` doesn't touch its ref; it's restamped onto the same version here, per **Nightly: restamp the hand-maintained workflow refs** in the overlay. Every `max-sixty/tend/...` ref in `.github/workflows/` now reads `0.2.12`. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Reverts [#1334](#1334) and [#1333](#1333), which shipped in 0.2.12. The code under `shared/`, `proxy/`, `claude/`, `codex/`, `generator/src/` and `docs/` is byte-identical to `b953f683`, the commit before #1333. A 0.2.13 release follows. The release's live check on tend found two regressions: - **SRT's masks land as files in the checkout the agent commits from** ([#1338](#1338)). #1333 made the SRT process `chdir` to `$GITHUB_WORKSPACE`, so SRT resolves its mandatory deny list (`.bashrc`, `.gitconfig`, `.gitmodules`, `.vscode`, …) there and binds `/dev/null` over each name. `git add -A` then fails with `can only add regular files`, every session sees thirteen untracked entries, and git warns `unable to access '.gitmodules': Permission denied`. Under 0.2.11 the launcher sets no working directory, so SRT resolved the list against the step's default, the runner's checkout, while the agent committed from a separate disposable clone. - **The experimental memory-gist save fails.** #1333 moved its key file from `RUNNER_TEMP` into the runtime's private directory, which the dispose step deletes before the save reads it. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…ite view, and deprecate sandbox_setup and sandbox_path (#1346) Reapplies #1333 and #1334, which #1339 reverted after 0.2.12's live check, fixes the defects that check and the weekly integration test found, and deprecates `sandbox_setup:` and `sandbox_path:`, which the view makes redundant. Ten commits: - The first two revert the two reverts #1339 squashed, and leave the code byte-identical to 6d74214, the 0.2.12 tree. - The third, `Resolve SRT's write protections off the checkout, and keep the memory key past dispose`, fixes the regressions. - The fourth, `Remove sandbox_setup, and refuse a checkout outside the runner's home by name`, and the fifth, `Remove sandbox_path: the agent runs with the job's PATH`, remove both keys' machinery. - The sixth, `Warn on sandbox_setup and sandbox_path, and carry them over as setup: steps`, keeps configs that still set them working. - The seventh added a `setup-uv` step to the migration, the eighth reverts it, and the ninth, `Say that a setup: step installs the tools it calls`, puts that in the warning and the example config. - The tenth, `Run migrated sandbox_setup commands in one shell, and keep sandbox_path's order`, makes the migration match how the keys ran. Closes #1198: a cache `setup:` restores into the runner's checkout or home now reaches the agent, at the path it was restored to. ## What 0.2.12's live check found **SRT's write protections landed in the checkout the agent commits from** (#1338). SRT 0.0.76 resolves its mandatory deny list (shell rc files, `.gitconfig`, `.gitmodules`, `.mcp.json`, `.vscode`, `.idea`, `.claude/commands`, `.claude/agents`, `.git/hooks`) against its own process cwd, and binds only the entries inside `allowWrite`: one that exists is re-bound read-only, one that doesn't gets a `/dev/null` bind, or a read-only empty directory when an intermediate component is what's missing (`dist/sandbox/linux-sandbox-utils.js`, `linuxGetMandatoryDenyPaths` and the deny loop in `generateFilesystemArgs`). #1333 put the runner's home in `allowWrite` and chdir'd the launcher to the checkout, which sits under that home, so every session's checkout held thirteen character devices: `git add -A` failed with `can only add regular files`, and every git command reading submodule config warned `unable to access '.gitmodules': Permission denied`. Under 0.2.11 the launcher's cwd was the runner checkout, outside `allowWrite`, so the list bound nothing at all. **The experimental memory-gist save failed on every run.** #1333 moved the baseline key out of `RUNNER_TEMP`, correctly: the view's idmap shows the runner's 0600 files in the home to the agent as its own. It moved the key into the private directory inside the runtime container, which `Dispose sandbox resources` deletes right after the reap, before `Save experimental memory Gist` reads it (`cat: /var/tmp/tend-runtime.…/private/tend-auto-memory-key.…: No such file or directory`). The save is `continue-on-error`, so the job stayed green. ## Three further defects the fix removes - **A repository without `.claude/` could not start the agent.** `.claude/commands` and `.claude/agents` sit two levels deep, so where `.claude` itself is missing SRT mounted a read-only empty directory over `.claude`, and `run_claude` failed writing `.claude/settings.local.json` before the harness started (`tee: …/.claude/settings.local.json: Read-only file system`). The weekly integration test hit this; tend's own checkout tracks `.claude/`, so `test-sandbox` could not. - **Tracked protected paths were read-only.** A repository that tracks `.vscode/`, `.idea/`, `.gitmodules`, `.mcp.json`, `.claude/commands/` or `.claude/agents/`, at the root or up to SRT's search depth of 3, got each re-bound read-only, so the agent could not edit them. - **A pull request touching one of those paths could not be checked out.** The binds are computed once, at launch, against the reviewed base tree; `event_checkout` then moves that same checkout to the PR's ref inside the sandbox, and git cannot write a path that is a read-only bind or create one beneath a `/dev/null` stub. This one is inferred from the binds rather than reproduced. ## The fix - **`shared/steps/sandbox_runtime.mjs`** chdirs the launcher to its own staged directory, under the runtime container and outside every `allowWrite` path, so SRT's list binds nothing. The list exists to stop something unsandboxed from later running what a sandboxed process wrote, and under the view nothing outside the process tree runs what the agent writes in the home: every write lands in the overlay's upper layer, which the dispose step deletes. It was never a boundary on the agent's own config either — it leaves out `.claude/settings.json`, `CLAUDE.md` and skills. SRT has no switch for this list alone (`filesystem.disabled` drops all filesystem policy), so the cwd is the lever. The lifecycle's own cwd comes from the `spawn`'s `cwd`, so the harness still starts in the checkout. Resolving from the home instead is what #1333's first CI run hit: `~/.gitconfig` masked and `git config --global` failing. - **`claude/action.yaml`** creates the memory key beside the memory directory in `/var/tmp`, a 0600 runner file outside both the home and the runtime container. Moving the save ahead of dispose would also work, but `test_sandbox_resources_are_removed_immediately_after_agent_reap` pins dispose to the step after the reap. - **`docs/security-model.md`** says where the key lives and that SRT's built-in protections bind nothing, and why. Running SRT 0.0.76's own `wrapCommandWithSandboxLinux` (argument generation only, no bwrap) with `allowWrite` covering a runner home: a launcher cwd in the checkout emits exactly #1338's thirteen `/dev/null` binds plus read-only `.vscode` and `.git/hooks`; a cwd in the home emits a read-only `~/.gitconfig` and twelve more; a cwd in the staged directory emits none. #1340 took the other route, excluding the stubs from git after `event_checkout`; it would have left the read-only `.claude`, the read-only tracked paths, the failing PR checkout and the `.gitmodules` warning. ## `sandbox_setup:` and `sandbox_path:` are deprecated, and migrate themselves `sandbox_setup:` ran consumer commands inside the sandbox so the agent could have what `setup:` built, which a separate home and checkout kept from it. `sandbox_path:` prepended directories to the agent's PATH. Under the view `setup:` output is at the path it was left at and the agent's PATH is the job's, so both are redundant, and the view broke `sandbox_path:` besides: its `~` still expanded to the sandbox account's home rather than the runner home the agent now runs in. Their action inputs, `shared/steps/sandbox_setup.py`, the lifecycle's call (with its unused `probe` harness) and the `~` expansion in `proxy/setup_sandbox.py` are gone, and the docs no longer mention either key. At the maintainer's call, and against CLAUDE.md's rule that an old format fails, `init` does not refuse them yet, so that nothing breaks in a consumer before it migrates. It warns, naming the key and its migration, and performs that migration: each key becomes one `setup:` step appended after the consumer's own, in every agent job. `sandbox_path` comes first, since `sandbox_setup` ran with those directories on PATH, and becomes `echo "<dir>" >> "$GITHUB_PATH"` lines, with a leading `~` as `$HOME`. They are written last-first: the runner adds each `$GITHUB_PATH` line to its prepend list in order and builds PATH from that list reversed, so the first entry stays first. `sandbox_setup`'s commands share one `shell: bash` step, the `-eo pipefail` bash they were joined into before, so an `export`, `cd` or `source` still reaches the entries after it. The setup renderer now emits a multi-line string as a `|` block scalar rather than a double-quoted line of `\n` escapes, which also covers a consumer's own multi-line `run:`. A `TODO(2026-10-21)` in `config.py` marks turning the warnings back into refusals once the consumers have migrated. `enabled` keeps refusing. A migrated command runs as an ordinary `setup:` step, with what the consumer's `setup:` and the runner image provide. Inside the sandbox it also had tend's `uv` fallback on PATH, which no `setup:` step gets: tend's own `uv` stays off PATH, and the ubuntu-24.04 image ships none. So a command that calls `uv` needs `astral-sh/setup-uv` earlier in `setup:`, as in any workflow; the warning and `docs/tend.example.yaml` say so. Of the five consumers only PRQL/prql is affected: its `uv tool install pre-commit` needs `setup-uv` in its `tend-setup` composite before it takes this release. leaf and numbagg list `setup-uv` in `setup:`, and worktrunk's `tend-setup` composite runs it. On ubuntu-24.04, `~/.local/bin` and `~/.cargo/bin` are both on the job PATH the agent inherits: the `sandbox PATH:` line in this PR's `test-sandbox` log carries `/home/runner/.local/bin` and `/home/runner/.cargo/bin`. `sandbox_env` stays: the job's environment already crosses, but it is still the one way to give a value to the agent alone, which a consumer uses for a secret on some events only. ## Self-hosted layouts The view is an overlay of the runner account's home, so a self-hosted runner whose work folder is elsewhere would give the agent a read-only checkout and fail later, in the sandbox, on a probe that cannot say why. `proxy/setup_sandbox.py` now refuses that layout in the "Set up credential-isolation sandbox" step, naming both paths, and `docs/tend.example.yaml` says it is not supported yet and how to avoid it. #1348 tracks supporting it. ## Testing - `proxy/test-setup-sandbox.sh` (the `test-sandbox` job) asserts from inside the lifecycle that the checkout holds no character device, that `git add -A --dry-run` succeeds, and that `.claude/commands/` and `.mcp.json` are writable there. Those assertions ran through the `sandbox_setup:` hook; the Claude stub now runs them, from where the agent starts. The Claude launch moves `.claude/` out of the checkout first, so it runs the case most consumers are in, and the stub sits where the real Claude binary installs rather than on a `sandbox_path` entry. At 6d74214 the test never ran `git add`, `git commit` or `git status` in the checkout, which is why it stayed green. - `shared/steps/test_launch_sandbox_runtime.py` drives the real launcher against a stand-in SRT, with the workspace under the runner home as on a hosted runner, and asserts the cwd SRT reads while wrapping is outside every `allowWrite` path. It is Linux-only; run on macOS through a `process.platform` shim, it passes, and it fails against the 0.2.12 launcher. - `generator/tests/test_repo_pins.py` pins the memory directory and key to `/var/tmp`; `test_config_edge_cases.py` asserts both deprecated keys warn with their migration and turn into the expected `setup:` steps, `test_migrated_sandbox_setup_commands_share_one_shell` runs the migrated step under the bash GitHub uses and checks an `export` reaches a later entry and a failure stops the rest, and a regtest snapshots them rendered after the consumer's own step under the notifications pre-check; `proxy/test_setup_sandbox.py` asserts the layout refusal names both paths. - `uv run pytest`: 1216 passed, 4 skipped. All thirteen pre-commit hooks pass; the `sandbox_env` reserved-set parity hook now scopes to that list's new paragraph, and still reads every reserved name from it. Only a live run verifies the memory-gist save (no CI job runs the Gist steps) and a review in PR mode. ## For the release notes - 0.2.13 reverted the view, so this restores what 0.2.12 announced: what `setup:` builds reaches the agent again. - `sandbox_setup:` and `sandbox_path:` are deprecated. Their entries move to `setup:` automatically, one step per key after the consumer's own, and `tend init` warns with the migration; a later release will refuse them. Five consumers set `sandbox_setup` (worktrunk, PRQL/prql, numbagg, leaf, cargo-affected), none `sandbox_path`. A migrated command now runs as an ordinary `setup:` step, without the `uv` the sandbox provided, so a command that calls `uv` needs `astral-sh/setup-uv` earlier in `setup:`; PRQL/prql is the one consumer that needs it. - A self-hosted runner whose work folder is outside the runner account's home is refused by name (#1348). > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Regenerates the `tend-*` workflows with tend 0.2.13 (from 0.2.11). Mechanically the diff is the action pin `max-sixty/tend/[email protected]` → `@0.2.13` in the eight workflows that run the agent, the `astral-sh/setup-uv` pin `0.12.13` → `0.12.17` in the two that install uv directly (`tend-mention`, `tend-notifications`), and a regenerated header comment in all nine. The upgrade that matters for this repo is in CI polling. `poll_pr_checks.py` previously treated any gating check that settled without a red conclusion as green — so a required check belonging to a **cancelled** or **stale** run, or a `COMPLETED` check carrying no conclusion at all, let the bot report a PR as green when nothing had actually verified it. 0.2.13 splits those out as `unverified` and gives `poll` a distinct exit code for them (max-sixty/tend#1323). Practically: fewer "checks went green" claims on PRs whose required jobs were cancelled, at the cost of some polls ending unverified rather than green. The rest, in rough order of how visible it is here: - **Sandbox reliability** — the sandbox runtime now retries past a transient bridge-socket failure at launch (max-sixty/tend#1327). That failure is one of the shapes that produces a `tend-outage` issue, so it should show up as fewer of those. - **Sandbox environment** — root `/tmp` is writable inside the sandbox (max-sixty/tend#1324); the `run-tend` skill's note that it was read-only is gone. This repo's `running-tend` skill still restates that note, so it goes stale when this merges — I'll follow up separately rather than mix a skill edit into the generated-workflow diff. - **Instruction-path pinning** — the `run-tend` skill's description of which paths get restored from the PR base, and on which events, was wrong in 0.2.11; `.agents/` is now named alongside `.claude/`, and the event list is corrected (max-sixty/tend#1311). The restore behavior itself is unchanged. - **Auth hygiene** — the bot's claude.ai account is kept out of CI sessions (max-sixty/tend#1328). - **Harness pins** — claude-code 2.1.278 (max-sixty/tend#1330), uv 0.12.17 (max-sixty/tend#1331). `.config/tend.yaml` pins no model, so the harness-default check found nothing to adjust. Full comparison: max-sixty/tend@0.2.11...0.2.13 <details><summary>Copy-on-write sandbox view: landed and reverted within this range</summary> max-sixty/tend#1333 and max-sixty/tend#1334 moved the agent into the job's own checkout and home through a copy-on-write view; max-sixty/tend#1339 reverted both before 0.2.13. Nothing from that work is in this diff — noted so a later reader doesn't chase it out of the commit list. </details> Co-authored-by: worktrunk-bot <[email protected]>
Two gaps #1333 left in the sandbox launch chain, both in
shared/steps/enter_view.pyand the supervisor that calls it.The job's environment was on
sudo's command line. The launch passed the agent's whole environment asenv -i NAME=VALUE …arguments tosudo, which logs its command line, and which any process on the host can read from/proc. On a self-hosted runner, a secret a consumer sets in job-levelenv:ended up in the system log. The supervisor now writes the environment, NUL-separated, to a 0600 file in the private directory.enter_view.pyreads it without following links, removes it before anything that can fail, and passes it toexecve. Standard input would have avoided the file entirely, butsudocan relay its input through a pty in canonical mode, which mangles it.A host
/tmp/claudecould be written from inside. SRT always allows writes to/tmp/claudeand binds the host's whenever one exists at launch, and it resolves binds through the namespace it was launched from. So a world-writable host/tmp/claudecame back writable under SRT's own private/tmp, and anything written there outlived the run.enter_view.pynow mounts an empty/tmpin the view's private namespace, so SRT never finds the host's. The mount covers all of/tmprather than that one path: nothing SRT runs uses the host's/tmp, because its sockets followTMPDIR.plugins/tend-ci-runner/skills/run-tend/SKILL.mdloses one sentence that told every session thesudo envlaunch carries its environment in argv; the rule against printing a process's environment or command line stands without it.The unit tests cover the file handoff (last entry wins, the file is removed, a symlink is refused, nothing from the job reaches the argv) and hold
enter_view.py, which root runs straight from the action checkout, to the standard library.proxy/test-setup-sandbox.shchecks both on a real runner intest-sandbox:sudo's journal, which the test also requires to hold this launch's entry, so an absent marker means something;/tmp/claudefrom inside never reaches a world-writable host one.