Skip to content

fix(ci): turn the read runner's sandbox off only for ci-context - #17029

Merged
kyle-sexton merged 4 commits into
mainfrom
fix/14740-sandbox-off-only-for-ci-context
Nov 18, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
fix/14740-sandbox-off-only-for-ci-context

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Refs: #14740

Summary

pr-run-activity-read.yml set sandbox: "false" on all three run-claude-cli legs (API key, OAuth token, fallback token), so every read activity ran Bash with no network limit. Now each leg turns the sandbox off only when the activity's prepare mode is ci-context. Every other read activity runs run-claude-cli's default sandbox, which allows Bash network to github.com and api.github.com (see Risks for a documented widening by WebFetch(domain:...) rules). This tightens a control. No permission or deny rule changes.

Fix

  • .github/workflows/pr-run-activity-read.yml: on all three legs, sandbox: ${{ steps.config.outputs.prepare == 'ci-context' && 'false' || 'true' }}. The line is identical on each leg, so Lane follow-ups: the automation-shape pass and six behaviour-preserving items #16966's credential-leg reusable can lift it as one expression. run-claude-cli's sandbox input takes true, false or empty, with true as the default (action.yml, sandbox input). The comment above each line cites ci-workflows#1060 and notes that ci-context reads untrusted CI log text.
  • credential-legs.test.mjs: a new test evaluates each leg's sandbox expression for every prepare mode this file runs (ci-context, review-threads, dependency-review, merge-base, none). It also fails if a literal sandbox: "false" comes back.
  • docs/conventions/pr-pipeline/pr-run-activity.md, step 3 of the read runner's legs, now says which legs run sandboxed. No doc said the read activities ran with the sandbox off, so that refinement criterion needed no edit. A pr-pipeline patch fragment records the change.
  • socat, which the sandbox's network proxy needs, is already installed for every skill. "Isolate the runner" passes install-subprocess-isolation: ${{ steps.config.outputs.kind == 'skill' }}, and only a skill reaches the legs.

The two statements Done-when asks for

  1. Does the subprocess env scrub keep the Claude API key out of the Bash child? Yes, on every leg, with the sandbox on or off.
    • run-claude-cli's legEnv sets the key for the CLI, then turns the scrub on unconditionally: lane.cjs:466 if (leg.leg === "api-key") env.ANTHROPIC_API_KEY = leg.value; and lane.cjs:468 env.CLAUDE_CODE_SUBPROCESS_ENV_SCRUB = "1";. This is the pin all three legs use.
    • Claude Code's table of what the scrub removes lists ANTHROPIC_API_KEY as "Removes it" (env vars: What the subprocess environment scrub removes, read 2026-11-18). The same table keeps GITHUB_TOKEN and GH_TOKEN, and run-claude-cli's steps set neither.
    • The refinement cites setup-runner-isolation/action.yml:18-20 as setting the scrub. That file only installs the bubblewrap and socat the scrub needs; run-claude-cli sets it.
  2. Does setup-runner-isolation limit egress? No.
    • It does two things: "Install subprocess isolation" (.github/actions/setup-runner-isolation/action.yml:22-72, bubblewrap and socat through apt, plus the AppArmor user-namespace sysctl) and "Remove sudo and docker access" (:77-92). Neither touches the network.
    • Bash egress is limited only by run-claude-cli's sandbox settings, lane.cjs:175 network: { allowedDomains: ["github.com", "api.github.com"] },. The CLI gets those settings only when sandbox is not false (lane.cjs:494). So after this change, a ci-context leg's Bash still has no egress limit. Every other read activity's Bash goes through the sandbox's allowlist, which the local probe below measured as GitHub only.
    • The refinement cites :49-67 for this; on main those lines are inside the install loop.

Verification

  • A local probe (Claude Code 2.1.327) launched the CLI the way lane.cjs does: the same sandbox settings JSON, the scrub on, dontAsk, --restricted. It asked whether the read runner's --disallowedTools deny rules (Read(./.git/**), Edit(./.git/**), an Edit deny on a state directory) stop a wrapper script's file access once the sandbox is on. That is the shape the issue lane's git-read and the review-threads tool's write under .lane/feedback/state/ rely on. Results:
    • With the sandbox on and the deny rules set, the wrapper read .git (git rev-parse HEAD) and wrote the denied directory.
    • The same run reached api.github.com, and example.com was refused with deny network-outbound example.com:443, so the sandbox was active.
    • With WebFetch(domain:*) also allowed (--allowedTools, the form the issue lane's web-access: any stages), example.com was still refused.
    • With the sandbox off, the wrapper wrote the same 0-byte claude-code scrub-mode stubs (.env, package.json and others, added to .git/info/exclude). They come from the scrub, not the sandbox, and they were there before this change.
  • node --test --test-concurrency=4 .github/scripts/pr-run-activity-read/credential-legs.test.mjs: 10 pass, 0 fail, including the new test.
  • actionlint .github/workflows/pr-run-activity-read.yml: no findings.
  • scripts/check-affected.sh: 14 passed, 5 skipped, 0 failed. The first run failed changelog-fragments; the pr-pipeline fragment fixed it.
  • Not run locally: .github/actions/resolve-config/callers.test.mjs. It imports ajv from resolve-config's own dependencies, which are not installed in this checkout. It holds no assertion on this file's sandbox input. CI runs it.
  • Not yet proven: a live read run under the sandbox for each non-ci-context activity with Bash (fix-docs, review-threads, the issue lane). Their check and verify wrappers run tools the run job installs from the base before the leg (Install the skill's dependencies). A sandbox that cannot start fails the leg red (run-claude-cli failIfUnavailable), so a break shows as a failed run.

Risks

The local probe ran Claude Code 2.1.327, and the legs run cli-version: latest. On two points the probe and the sandboxing page (read 2026-11-18) disagree, and a later release could follow the docs:

  • Deny rules merging into the sandbox. The page's table lists "Read and Edit deny rules: Block access to specific files or directories" and says "Paths and domains from both sandbox settings and permission rules are merged into the final sandbox configuration" (section "Permission rules"). If that applies to --disallowedTools rules, two things fail red under the sandbox: the issue lane's git-read (the runner denies Read(./.git/**)), and the review-threads tool's write of its replies file under .lane/feedback/state/ (denied to the file tools). Either one fails the leg visibly. Neither weakens a control.
  • WebFetch(domain:...) allow rules widening the network allowlist. The page says Claude Code "also pre-allows domains from WebFetch(domain:...) allow rules" and honors a bare * (section "Hosts outside your allowed domains"). If that applies to --allowedTools rules, the network limit widens to the activity's web-access hosts. For the issue lane (resolve-issue, web-access: domains: any, docs/conventions/pr-pipeline.yaml:428-430), that means any host. That is no wider than today's sandbox: "false", and the file-write limits still apply.

Remaining

Related

🤖 Generated with Claude Code

kyle-sexton and others added 4 commits November 17, 2026 22:29
The three run-claude-cli legs in pr-run-activity-read.yml set
sandbox: "false" for every read activity. Only a prepare: ci-context
skill gets bare Bash that may reach hosts beyond GitHub, so the legs
now turn the sandbox off for that mode alone and keep run-claude-cli's
default sandbox for every other read activity.

A test pins the input on each leg, and the read runner contract says
which legs run sandboxed.

Closes #14740

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 18, 2026 04:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T04:04:00.479447Z 7c18d20 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 7c18d202ba54364d41496d3595d99da0024df574: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #17029, turn the read runner's sandbox off only for ci-context

No findings. I read every hunk of the 4 changed files: the changelog fragment, credential-legs.test.mjs, pr-run-activity-read.yml and pr-run-activity.md.

What changed. All three run-claude-cli legs (act-key, act-token, act-fallback) used to set sandbox: "false". Now each sets sandbox: ${{ steps.config.outputs.prepare == 'ci-context' && 'false' || 'true' }}.

  • In GitHub expressions the string 'false' is non-empty, so it counts as true. The &&/|| chain therefore returns 'false' for ci-context and 'true' for every other mode, including an empty prepare.
  • The job already reads steps.config.outputs.prepare in its existing gates (around lines 1071–1112), so the value is set before the legs run.

The new test evaluates each leg's expression with the shared evaluator in .github/scripts/lib/model-credential.mjs. Its && and || return an operand, as GitHub's do, and value() turns the result into the string the step receives.

  • It covers each leg against all four prepare modes this file allows, plus none.
  • It also fails if a literal sandbox: "false" comes back.
  • I checked the evaluator's code by reading it. I did not run the test, since this lane has no shell. The author reports 10 passing; that is unverified here.

Docs. Step 3 of the legs in pr-run-activity.md now says each leg runs its Bash in the sandbox except under prepare: ci-context. That matches the workflow.

Closing issue. The PR says Refs: #14740 and closes no issue, so I checked no acceptance criteria. The PR body says the resync to pr-pipeline-sandbox is still to do after merge, and #14740 stays open until it lands.

Scope. Whether the sandbox is a sound security control (egress allowlist, how deny rules merge, how WebFetch(domain:...) rules widen the allowlist) is left to the separate security lane. Not checked here: the PR body's "Not yet proven" item. That is a live sandboxed run for each read activity that isn't ci-context but has Bash (fix-docs, review-threads, merge-base, the issue lane). If one of them needs a host outside GitHub, its leg fails red rather than passing silently.

Spend. The change only affects runtime behaviour of lane runs; it adds no billed resource and no new spend.

Loosened-check verdict: fail (no wrapper-supplied value; default used); patterns: 0. Nothing in the diff loosens a check: the sandbox is narrowed and a test is added.

Verifier dropped 0 of 0 candidates.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 7c18d202ba54364d41496d3595d99da0024df574: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Security review: no issues found

I read all four changed files in full: the changelog fragment, credential-legs.test.mjs, pr-run-activity-read.yml (a trusted path) and pr-run-activity.md.

What changed. Before this PR, all three run-claude-cli credential legs in .github/workflows/pr-run-activity-read.yml set sandbox: "false" with no condition. Each leg now sets sandbox: ${{ steps.config.outputs.prepare == 'ci-context' && 'false' || 'true' }} (L1828, L1889, L1940).

Trust-control check. This narrows a control and widens nothing:

  • No added exposure. Every prepare mode keeps the sandbox off (the old behaviour) or turns it on. No mode loses isolation it had before.
  • The expression evaluates correctly. 'false' is a non-empty string, so it is truthy in Actions expressions. The && || form therefore gives 'false' for ci-context and 'true' for every other mode, including an empty prepare.
  • It reads the step that validates the mode. steps.config.outputs.prepare comes from the config step (L1017). The guard at L1073-L1080 checks that value against the read modes, and the other ci-context-gated steps use the same output.
  • Nothing else moves. Permissions, token requests, tool allow and deny lists, and the credential-leg selection are unchanged.

The ci-context leg still runs without an egress limit, as it did before this change. The PR states that on purpose, and it is not new exposure.

The new test fails if a literal sandbox: "false" comes back, and it checks every prepare mode on each leg. The doc and changelog edits are prose that match the code.

Spend. This adds no billable resources or paid-plan changes, so no cost hold applies.

critical-findings: 0

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit c1a4cd8 Nov 18, 2026
98 checks passed
@kyle-sexton
kyle-sexton deleted the fix/14740-sandbox-off-only-for-ci-context branch November 18, 2026 04:55
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant