Skip to content

fix: prevent workload changes to configured tool commands - #263

Merged
kevin-orellana merged 2 commits into
mainfrom
feature/configured-command-integrity
Nov 3, 2026
Merged

kevin-orellana merged 2 commits into
mainfrom
feature/configured-command-integrity

Conversation

@kevin-orellana

@kevin-orellana kevin-orellana commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Human readable section

Problem. Box can give a configured tool access to files that its caller cannot read. A permitted hosted copy or move could replace the tool's executable. A later call then ran the replacement with the tool's grants.

Solution. Resolve configured tool executables before the workload starts and protect them throughout the run. Refuse overlapping direct write grants and hosted mutations, then check the retained file identity before launch.

Trade-off. Every configured tool must be installed before startup, including unused entries. Its executable must remain outside direct write grants and have exactly one hard link. This also refuses legitimate system executables with multiple hard links, regardless of ownership or permissions. Operators update tools between runs. This protection covers [tool.<name>] command[0], not scripts passed as arguments, libraries, or plugins.

Description

  • Validate write grants from the agent, every tool, and every contained local server against configured tool executables and their naming paths.
  • Apply the hosted mutation refusal after policy evaluation. Reads retain their existing policy checks. Both Shell and Monty use the same protection.
  • Keep an open command handle and preserve the configured invocation path. Identity checks detect replacement. Write prevention addresses changes that retain the same file identity.
  • Preserve unrelated build output under existing caller grants. Do not introduce snapshots, a configuration override, or a new authorization mechanism.
  • Give test fixtures independent copies of Cargo-built probes, because Cargo can create multiple hard links. Move configured probes outside writable agent directories without weakening their assertions.

Related Issues

No public issue linked.

Type of Change

Bug fix

Testing

Local validation ran on Linux ARM64 (64-bit Arm). The follow-up commit changes test fixtures, adds a Monty regression, and updates documentation. Production code remains identical to efdf62a506161cb84d9b85440044be209e82a115.

Check Result
Original full workspace: EXPERIMENTAL_LINUX_SUPPORT=TRUE cargo test --workspace --all-features --no-fail-fast -- --show-output Passed at efdf62a: 4,606 reported passes, zero failures, and 17 existing ignored tests. No test-name filter.
Follow-up deterministic containment: bash test-integ/run.sh with the Linux opt-in and the built Box on PATH Passed: 124 cases, zero failures or errors, and nine declared macOS-only skips. All 133 cases recorded; full coverage gate, no quarantine. The harness used its release profile and Box used its debug profile.
Follow-up monty_cannot_change_a_configured_command integration test Passed without a runtime skip. Checks overwrite, deletion, moving the command, and replacing the command through Monty. Ordinary-file write, rename, read, and deletion controls succeed; protected bytes stay unchanged.
Exact a_configured_linked_script_keeps_its_invocation_path integration test Passed on Linux: one pass, zero failures, and zero ignored tests. The final hosted macOS workspace suite also passed.
cargo fmt --all --check and standalone harness formatting Passed.
Workspace Clippy, all targets and features, with the justfile allowances Passed. No new warnings.
Standalone harness Clippy, all targets and features, with -D warnings Passed. A missing paragraph break in an existing test comment was corrected.
Installed-alias fixture assertion Passed after workflow fixture preparation, using the original workspace test binary; one pass, no runtime skip.

The first hosted containment run failed because shared fixtures declared tools inside writable workspace directories. The follow-up installs independent configured copies outside those grants. Native probes and writable build output retain their original paths. Existing assertions remain in place.

Hosted macOS testing also exposed a missing read grant in the linked-script fixture. Its interpreter needs to read the script target. The fixture now grants read_file for that target and preserves every invocation-path assertion. The exact Linux rerun passed, as recorded above.

The original workspace totals use the final summary from each Cargo test target, so a nested child-test result is not counted twice. Two runtime omissions remain: the credentials-daemon fixture is unavailable, and Linux cannot enforce the alias execute-without-read assertion. The alias write assertions ran. The initially absent installed alias image is covered by the focused fixture rerun above. An earlier workspace attempt omitted the Linux opt-in and stopped at startup; the complete corrected run passed.

The original six configured-command integration cases cover hosted overwrite, hosted replacement, preexisting hard links, overlapping native write grants, linked-script invocation, and operator updates between runs. The overwrite and replacement cases verify that direct agent reads and hosted reads of the test marker remain refused, the original tool retains access, and unrelated writes still succeed.

Hosted checks. CI passed for follow-up commit 4210bd543005d3288993ea46ec71d4c34d068895. Both Linux ARM64 and macOS ARM64 workspace suites passed, including the corrected linked-script fixture. Deterministic containment passed with 124 cases and nine declared skips on Linux, and 121 cases and 12 declared skips on macOS. Each platform recorded all 133 expected cases, with zero failures or errors. Lint, packaging, native macOS build/unit tests, the final CI gate, and CodeQL also passed.

The completed automated review assessed this head as Approve and accepted both earlier findings. Both review threads are resolved. This assessment is not a required human approval; the PR remains open for human review.

Remaining coverage. Automated execution review blocked the additional adversarial runtime test batch. Native coverage through alternate filenames and during concurrent mutation remains incomplete. Linux x86-64 remains unvalidated. The native macOS job covered adapter, configuration, and startup tests; it did not run the full signed enforcement suite. The change does not protect scripts named only in arguments, loaded dependencies, agent/server entry files, or changes by outside processes. These results do not establish security acceptance or release readiness.

  • I ran the relevant suites (just check, or cargo test --workspace --all-features)
  • If I touched Rust, I ran cargo fmt --all and cargo clippy --workspace --all-targets --all-features -- -D warnings

just is unavailable on the validation host. Workspace Clippy uses the equivalent recipe with the repository's documented allowances for existing vendored-shell lints. It is not an unqualified strict Clippy run.

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings

AI assistance: Codex prepared this implementation and description. An independent agent reviewed the source and final fixture changes. The review checklist describes the agent review. Human maintainer review remains required.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

## Problem

A permitted hosted file operation can overwrite or replace a configured tool
executable. A later call then runs those bytes with the tool's filesystem
grants. Direct agent access to the same files can remain refused.

## Solution

Resolve configured tool programs before the workload starts and retain their
file identities. Reject direct write grants that cover these commands or
their naming routes. Refuse broker mutations after policy authorization and
verify the retained command identity before launch.

Reject commands with multiple hard links. Preserve the configured invocation
path for linked scripts and allow operator updates between completed runs.
This protects command[0], not scripts passed as arguments or loaded dependencies.

## Tests

The configured-command overwrite and replacement integration tests refuse the
mutation and retain the original tool's marker access. Startup refusal,
linked-script invocation, and operator-update controls also pass. Completed
Box package target runs report 1,024 passes and six preexisting ignored tests.

cargo fmt --all --check and workspace Clippy pass with the repository's
vendored-shell lint allowances. Independent source and fixture review found
no unresolved issue. Runtime validation covers Linux ARM64. Additional native
alias and concurrent-mutation coverage remains incomplete.
Comment thread crates/box/src/run/commands.rs Resolved
Comment thread crates/box/src/run/commands.rs Resolved
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Assessment: Request Changes

The protection works for the cases it names. The problem is the startup gate in ConfiguredCommands::load: it fails for every tool table at once, and it now refuses configurations that worked before and are not at risk (see inline comments).

Review Categories
  • Correctness / scope: The hard-link and resolution checks stop the whole run. They do not check whether the box's uid can write the inode, and they do not check whether the tool is used.
  • Testing: The Monty mutation path shares Reach::approve_mutation, but no test runs it. A shutil.copy / os.replace case next to the hosted-Shell cases would cover it.

Checks that held

  • Hosted copy and move cover the destination, the moved parent directory, a symbolic-link alias (checked on the canonical approved path), and a hard link created later (caught by the disk_identity match in names).
  • validate_reach catches agent, tool, and server write grants that cover the command, its route, or an ancestor directory. A grant on an earlier PATH directory cannot redirect launch, because command[0] is pinned to invoked.
  • get("[agent]") / get("[mcp.*]") return None, so the identity checks apply only to tools.
  • The "validate once, then act on the identity you approved" premise matches the verify + require_file_identity launch path.
  • The change adds no new public surface to the containment crate and changes no box.toml key.

@kevin-orellana
kevin-orellana enabled auto-merge (squash) November 2, 2026 03:00
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Assessment: Approve

I re-reviewed at 4210bd5. Compared with efdf62a, only tests, test fixtures, and docs changed; nothing under crates/*/src did. The follow-up adds the Monty coverage I asked for and documents both startup trade-offs. I found no new defects in the follow-up. Hosted macOS validation of the linked-script fixture is still pending, as the PR notes.

Checks on the follow-up that held
  • Monty test: write_text, unlink, renaming the command, and renaming onto it are each checked three ways. The output must contain the configured refusal (policy permits everything, so no other refusal can stand in). The command bytes must be unchanged, and the ordinary-file controls must succeed.
  • Fixture migration: Every case now runs its tool from tools/ and keeps native agent controls on the original out/ path. Each tool run asserts assert_mediated_permitted("shell:spawn", …), so a refusal cannot pass just because the agent lacks exec on tools/.
  • No unmigrated cases: No test-integ case still declares a compile_probe/built_tool path under a writable tree as a tool command.
  • install_tool: fs::copy produces a single-link file outside the agent's write grant. [tool.built-script] gains the read on tools/ that its #!/usr/bin/env sh interpreter needs.
  • Docs: The new config.md refusal strings match the error text in the code.

@kevin-orellana
kevin-orellana merged commit 6101ca9 into main Nov 3, 2026
25 of 26 checks passed
@kevin-orellana
kevin-orellana deleted the feature/configured-command-integrity branch November 3, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants