Skip to content

fix(sandbox): use Edit(path) for file denies, add the eval exclusion - #1311

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:fix/edit-path-denies-and-eval-exclusion
Sep 21, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
potiuk:fix/edit-path-denies-and-eval-exclusion

Conversation

@potiuk

@potiuk potiuk commented Sep 21, 2026

Copy link
Copy Markdown
Member

Summary

  • Claude Code warns at startup that the two Write(...) denies on the vetted-ops catalogue and policy "are not matched by file permission checks". It is right: Edit(path) is the path rule for file writes and binds every file-editing tool; Write(path) matches nothing. Both paths already had the correct Edit(...) rule, so the Write(...) lines protected nothing while reading as a second layer. Removes them and fixes every place that emits them (install recipe, vetted-ops README, secure-agent-setup, verify/update checklists, sandbox-lint baseline).
  • Adds an optional exclusion so eval suites can be graded by claude -p from inside the sandbox. Today an agent running a suite gets one ERROR per case, since the sandbox denies the nested CLI its credentials.
  • Updates the sandbox spec's excludedCommands list, which still named only gh and had missed the vetted-ops dispatcher from fix(vetted-ops): exclude the read dispatcher from the sandbox #1310.

Type of change

  • Skill change - setup-isolated-setup-{install,verify,update}
  • Cross-cutting (RFC, AGENTS.md, sandbox, privacy-LLM)
  • Documentation
  • CI / dev loop - sandbox-lint baseline

Test plan

  • prek run --all-files passes
  • sandbox-lint OK; its pytest suite passes (162 tests)
  • Evals on the final tree: install 13/13, update 15/15, verify 11/14 (see notes)
  • Exclusion verified end to end from a sandboxed tool call, no restart
  • Wrapper guards exercised: no args, a flag, .., absolute path, missing suite, two args all exit 2
  • No new eval fixture for verify check 13 (see notes)

RFC-AI-0004 compliance

  • Sandbox - widens what runs unsandboxed, optionally and narrowly
  • HITL - the install step is offered, never applied unprompted

Linked issues

Refs #1308, #1310.

Notes for reviewers

Why the excluded code sits outside the repo. An exclusion runs what the command executes outside the sandbox, so that code must not be writable by the sandboxed thing. Two simpler shapes fail: excluding the runner directly carves out --cli "curl ..." rather than the harness (and pinning --cli in the pattern fails, argparse being last-wins); excluding an in-repo wrapper needs tools/skill-evals/src/** denied too, a tree we develop here. So wrapper + runner package install to ~/.claude/scripts/, outside every allowWrite root, as container-gateway already does, with Edit(~/.claude/scripts/**) over the same directory.

The sandbox_write_denied coupling is not the objection. An in-repo deny does break the three whitespace hooks and the anchor from #1309 is the fix. I over-weighted that mid-authoring; it is a mechanical cost with a known remedy, and the security argument above is what decides the location. No anchor entry needed - the path is not in the repo.

Fixtures stay agent-writable, deliberately. They are data the runner reads, never code it executes. Check 13 says so, to stop a future report calling them protected.

The 3 verify failures are pre-existing - checked, not assumed. All in step-2-recommend; check 13 is in step-1-classify, which passes. case-3 and case-5 fail with byte-identical prompts before and after this branch. case-3 expects setup-isolated-setup-update, model says magpie-setup upgrade (stale since the rename?); case-5 gets both follow-ups right but in the other order and the suite is order-sensitive. case-4 is prose-judge flake (passed 3 of 4 runs). Separately, case-6-injection-attempt flipped FAIL/PASS/PASS on the same prompt - its check 5 grades a version sitting exactly on the min_version floor, genuinely ambiguous between pass and warn. Worth tightening.

Known gap: no eval fixture for check 13. CONTRIBUTING asks for one on a skill behaviour change. Happy to add n/a-path and drift-path fixtures before merge.

Spec sync is 6 commits behind. .last-sync is at 0e7012ba, main at 87be68b8. I updated the excludedCommands section because this PR changes it, but did not bump .last-sync - that would claim #1305-#1307 were reviewed for spec impact. A sync-specs run is still owed.

Checkout wrinkle, as in #1310. This changes .claude/settings.json, write-denied to the sandbox, so switching to/from this branch inside a sandboxed session fails with unable to unlink old. Normal terminals are unaffected.

🤖 Generated with Claude Code

`Write(path)` rules are not matched by the file permission check — only
`Edit(path)` is, and it already covers every file-editing tool. The two
`Write(…)` denies on the vetted-ops catalogue and policy were therefore
dead config that read as a second layer of protection, and Claude Code
now warns about them at startup. Drop them, and correct the install
recipe, tool README, docs and lint baseline that emit them. The same
correction applies to the `MultiEdit(…)` pair the secure-setup doc
showed for `.claude/settings.json`.

Also adds an optional exclusion so eval suites can be graded by
`claude -p` from inside the sandbox, which otherwise denies the nested
CLI its credentials and turns every case into an ERROR.

`--cli` takes an arbitrary shell command, so excluding the runner would
carve out `--cli "curl …"` rather than the eval harness, and pinning
`--cli` in the exclusion pattern does not hold because argparse is
last-wins. A wrapper fixes the CLI instead and accepts one positional
path under `evals/`, no flags. Since an exclusion runs whatever the
command executes outside the sandbox, the wrapper and the runner
package are installed to `~/.claude/scripts/` — outside every
allowWrite root — exactly as container-gateway already does, with
`Edit(~/.claude/scripts/**)` closing the agent's editing tools over the
same directory. An in-repo wrapper could not carry that guarantee: it
matters only for what it execs, so the runner's whole source tree would
have to be denied as well.

The step is optional and skipped for anyone who does not run eval
suites; `setup-isolated-setup-verify` reports n/a rather than a gap.

Also brings the sandbox spec's excludedCommands list up to date — it
still named only `gh`, having missed the vetted-ops dispatcher from
apache#1310.

Generated-by: Claude Opus 5
@potiuk
potiuk merged commit 5c75abd into apache:main Sep 21, 2026
10 checks passed
potiuk added a commit to potiuk/magpie that referenced this pull request Sep 21, 2026
Reconciles the spec-loop specs with the functionality that shipped
between 0e7012b and 5c75abd:

- agent-isolation-sandbox: records the write-deny over the vetted-ops
  **policy** on both surfaces it resolves to — the plugin-cache install
  and the committed `.apache-magpie-overrides/tools/vetted-ops/**`
  override — why it applies even though the write dispatcher is never
  excluded from the sandbox, and why the framework's own dispatcher
  source at `tools/vetted-ops/` is deliberately left un-denied. apache#1311
  landed the excludedCommands list and the "excluded code must not be
  agent-writable" rule that this builds on.
- sandbox-diagnostics: an eighth troubleshooting entry (the touch
  overlay's runtime-state directory denied) and the branch-order rule
  the hint hook follows where two entries both end in "agent refused
  operation".
- security-reporting: the per-issue event cache is trusted only when it
  was written after that issue's `updatedAt`, so a relabelled issue is
  refetched instead of being served stale label history.

Generated-by: Claude Opus 5
potiuk added a commit that referenced this pull request Sep 21, 2026
Reconciles the spec-loop specs with the functionality that shipped
between 0e7012b and 5c75abd:

- agent-isolation-sandbox: records the write-deny over the vetted-ops
  **policy** on both surfaces it resolves to — the plugin-cache install
  and the committed `.apache-magpie-overrides/tools/vetted-ops/**`
  override — why it applies even though the write dispatcher is never
  excluded from the sandbox, and why the framework's own dispatcher
  source at `tools/vetted-ops/` is deliberately left un-denied. #1311
  landed the excludedCommands list and the "excluded code must not be
  agent-writable" rule that this builds on.
- sandbox-diagnostics: an eighth troubleshooting entry (the touch
  overlay's runtime-state directory denied) and the branch-order rule
  the hint hook follows where two entries both end in "agent refused
  operation".
- security-reporting: the per-issue event cache is trusted only when it
  was written after that issue's `updatedAt`, so a relabelled issue is
  refetched instead of being served stale label history.

Generated-by: Claude Opus 5
potiuk added a commit that referenced this pull request Sep 21, 2026
`magpie-run-evals.sh` is excluded from the sandbox, so everything the
eval runner reads, it reads unsandboxed. Fixtures are deliberately left
agent-writable, on the stated grounds that a fixture can only route
*repository* text to the model — text the session could send anyway.

Nothing enforced the "repository" half of that. There are two ways out
of the tree, both reachable by a sandboxed agent writing a fixture:

- A symlink. `report.md -> ~/.ssh/id_rsa` is followed by `read_text()`
  and its contents go into the prompt piped to `claude -p`. The
  wrapper's guard constrains how its argument is spelled, not where it
  leads, and `-d` follows a directory symlink just as happily.
- A path string. `step-config.json` supplies `skill_md`, which is
  joined to the repository root and read with no containment, so
  enough `..` walks out with no symlink involved at all.

Either turns a fixture read into a read of any file the host can see,
including the credential paths the sandbox denies the session
directly — which is the one thing the exclusion was not supposed to
buy.

Resolve and contain instead: the wrapper resolves its target against
`tools/skill-evals/evals`, and the runner resolves every fixture path
it reads. Containment is by resolved path rather than a ban on
symlinks, so shared fixtures factored out inside the tree keep working.

Found by an adversarial review pass over #1311.

Generated-by: Claude Opus 5
@potiuk potiuk added substrate:framework-dev Tool substrate: build / validate / eval the framework itself substrate:sandbox Tool substrate: agent isolation, egress control, settings audit labels Sep 25, 2026
@potiuk potiuk added capability:platform Framework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap) family:docs Docs, MISSION.md, READMEs family:setup setup-* skills family:tools tools/* labels Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capability:platform Framework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap) family:docs Docs, MISSION.md, READMEs family:setup setup-* skills family:tools tools/* substrate:framework-dev Tool substrate: build / validate / eval the framework itself substrate:sandbox Tool substrate: agent isolation, egress control, settings audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant