Repository navigation
fix(sandbox): use Edit(path) for file denies, add the eval exclusion - #1311
Merged
potiuk merged 1 commit intoSep 21, 2026
Merged
Conversation
`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
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
9 of 15 tasks
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
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.
Summary
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 correctEdit(...)rule, so theWrite(...)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).claude -pfrom inside the sandbox. Today an agent running a suite gets one ERROR per case, since the sandbox denies the nested CLI its credentials.excludedCommandslist, which still named onlyghand had missed the vetted-ops dispatcher from fix(vetted-ops): exclude the read dispatcher from the sandbox #1310.Type of change
setup-isolated-setup-{install,verify,update}Test plan
prek run --all-filespassessandbox-lintOK; its pytest suite passes (162 tests).., absolute path, missing suite, two args all exit 2RFC-AI-0004 compliance
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--cliin the pattern fails, argparse being last-wins); excluding an in-repo wrapper needstools/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, withEdit(~/.claude/scripts/**)over the same directory.The
sandbox_write_deniedcoupling 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 instep-1-classify, which passes. case-3 and case-5 fail with byte-identical prompts before and after this branch. case-3 expectssetup-isolated-setup-update, model saysmagpie-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-attemptflipped 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-syncis at0e7012ba, main at87be68b8. I updated theexcludedCommandssection 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 withunable to unlink old. Normal terminals are unaffected.🤖 Generated with Claude Code