Repository navigation
fix: protect Box executables from workload writes - #295
Conversation
## Problem A workload with write access to the installation can replace Box's executable or containment helper. A later launch can run the replacement before sandbox restrictions apply. Configured tool programs already receive protection against otherwise permitted writes. ## Solution Extend that protection to the installed Box executable and helper, as the user explicitly decided. Retain their file identities and refuse direct writable grants and broker mutations that reach their names or containing directories. Account for hard links and verified mounted paths, and refuse incomplete inventories or changed identities. Preserve Cargo layouts when every binary name is accounted for and the workload cannot change the installation. Retain descriptor execution on Linux and the private helper copy on macOS. Record the accepted decision and the installation-directory cost in the documentation. The operator owns initial contents, outside writers, and updates between runs. Executable-format and public-marker checks identify artifact kind rather than authenticating contents. Reuse the existing hosted Site value to remove an owned macOS Clippy warning without changing tool-spawn behavior. Codex prepared the implementation, documentation, and validation. Human review remains pending. ## Tests - Direct replacement refusal: every_process_table_refuses_writes_to_installed_executables_and_their_ancestors passed on Linux and macOS. - Broker replacement and deletion refusal: the_hosted_shell_cannot_rename_installed_executables_or_their_ancestors and monty_cannot_remove_installed_executables_through_their_paths_or_symlinks passed on both platforms. - Cargo binary names: cargo_hard_links_and_all_their_ancestors_remain_protected passed on both platforms. - Linux mounted names: real_mount_aliases_preserve_link_counts_and_refuse_overlapping_write_grants passed without a skip. - Ordinary reads and sibling writes: installed_executables_remain_readable_and_an_unrelated_sibling_remains_writable passed on both platforms. - Operator updates: an_operator_can_replace_installed_executables_between_runs passed on both platforms. - Linux just check passed: 4,921 top-level tests, zero failures, 17 ignored. The custom box_library harness passed separately. - macOS all-features Box tests passed: 1,156 top-level tests, zero failures, five ignored. The custom box_library harness passed separately. - Installation coverage ran without skips: 30 units and seven product tests on Linux; 17 units and seven product tests on macOS. - Both platforms passed build, formatting, and Clippy checks. Plain changed-package Clippy reported zero owned warnings and six unchanged vendored Shell warnings. - The site-manifest tests passed on both platforms: 27 tests each. - Linux deterministic containment passed: 131 cases, zero failures or errors, nine declared macOS-only exclusions, and full coverage of its 140 defined cases. - scripts/test-all.sh box-examples passed its all-features build. No scripted examples remain; the full workspace gate covered its Rust-test section separately. - The live Strands Python tutorial with Amazon Bedrock passed an allowed README read and a denied synthetic .env read on macOS. Its isolated copy used a 512-token output cap. - The no-default-features build passed with 66 warnings in unchanged containment sources and no Box warning locations. - The initially absent installed-alias fixtures passed focused reruns on both platforms using legitimate binary copies. - Independent feature-critic review found no blocking, design, or documentation issues. All manifested source files remained unchanged during the gates. Clippy follows CONTRIBUTING.md and the just recipe's vendored-code allowances. Remaining Linux runtime limits are the absent optional instrumentation probe, the alias-read restriction, and the absent credential-daemon fixture. The macOS filesystem cannot run the non-UTF-8 filename case. Intentional ignored tests remain unchanged. The deterministic runner's embedded commit label was unknown; source and binary hashes identify the tested candidate separately. Validation uses legitimate binaries and plain fixtures. It does not establish release qualification or formal security closure.
|
Assessment: Request Changes This review covers DetailsReview Categories
Checked and held:
The broker and direct-grant checks are wired consistently across agent, tool, and MCP tables. |
|
Assessment: Comment (re-review of
Review Categories
Checked and held:
|
|
Assessment: Approve (re-review of
What I checked
Checks that held, one line each:
Verification on Linux:
|
Human readable section
Problem: A workload with write access to installed Box programs can replace them. Later launches can use the changed programs, including helpers that start the sandbox.
Solution: Protect Box's main executable, containment helper, socket alias helper, and the macOS package wrapper from workload modification. Refuse direct write grants and hosted file operations that can replace these installed programs.
Trade-off: Box refuses write grants that cover its installation, including development trees containing the running build output. Cargo source builds remain supported when Box can account for every hard-link name of the installed programs. The operator owns initial installation contents, updates between runs, and changes from processes outside Box.
Description
The accepted decision extends configured-tool protection to installed Box programs. These programs start containment or route workload operations to its checks. The socket alias runs inside the agent's sandbox. Replacing that alias alone does not demonstrate execution outside the sandbox.
The run retains file identities and opened helper files. It accounts for hard links, which give one file additional names, and verified paths through mounts. Write checks cover the installed names and containing directories. An incomplete inventory or changed identity causes a refusal. Linux executes the retained containment helper through its open file handle. macOS executes a private copy. Alias copies use the opened file and preserve its shared read offset.
An executable regular sibling named
boxreceives package-wrapper protection. A standalone application bundle tolerates an unrelated directory, symbolic link, or nonexecutable sibling with that name. Launch scripts and additional names outside this inventory remain operator responsibilities. This decision does not add blanket protection for customer launch settings.Executable-format checks and the public build marker identify the expected artifact kind. They do not authenticate initial contents. No command-line vocabulary, configuration keys, stored-record shapes, broker protocol, or public crate interfaces change.
Related Issues
No public issue linked.
Type of Change
Bug fix
Testing
Tested revision:
4f41d7f0d88245acca29c48479d8c0a7503bb11f, based on67e378ae16f2a8457a6b856228343086f404e743. Local validation used Amazon Linux 2023 ARM64 and macOS 27.2 ARM64. Both platforms match all 23 changed source files in manifest5ffd15b50dcf8ec248d09831d95cea409c37738e38839309671da47865a8b75e.Hosted source: The hosted test jobs used merge
0160da32f2453e2e68fa81506429d36a3a8d3b72, combining this head with main1d5cb050d2072727a0dd53e2f11db4854b251615. This merge includes newer test-harness changes from main. All 23 changed files match the locally tested manifest. Automated review checked out the pull request head. The final hosted workspace runs satisfy the suite checklist for this revision.Tests use legitimate executables and plain, nonexecuted file fixtures. The macOS fixture copies the shipped package layout and uses the wrapper text from
scripts/macos-release.py.The regressions cover:
Agent, tool, and local-server write grants against installed programs and their containing directories.
Shell and Monty writes, deletion, rename, and replacement, with unchanged-file controls.
Cargo hard links, Linux mount paths, and refusal when inventory is incomplete.
The macOS package wrapper, readable alias image, and standalone bundles beside unrelated paths.
Namespace setup refusals without hiding failures after the Linux mount test starts.
Cargo helper freshness when the profile directory and dependency directory contain different helper copies.
Alias copies after pathname replacement and reads that preserve a shared file offset.
Permitted reads, sibling writes, and operator updates between runs.
I ran the relevant suites (
just check, orcargo test --workspace --all-features)If I touched Rust, I ran
cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsClippy qualification: The Rust gate uses the recipes required by
CONTRIBUTING.md:just fmt-checkandjust clippy. Formatting ran in check mode. Clippy used-D warningswith the repository's seven vendored-code allowances. Separate plain package checks reported zero Box-owned warnings and six unchanged Shell warnings on each platform. The checked template line denotes this prescribed gate, not an unqualified bare-command pass.Existing exclusions: The local package suites retain six declared ignores on Linux and five on macOS. Hosted workspace suites retain 17 on Linux and 16 on macOS. Linux logs retain exclusions for unavailable cardinality instrumentation, the existing alias-read limitation, and an absent credential service. Local macOS excludes absent cardinality instrumentation and filesystem rejection of non-UTF-8 names. Hosted macOS hides successful test output, so that job cannot confirm the absence of runtime skips. The separate native-filesystem job passed but skipped bridge checks, which require the macOS 27 software development kit.
Separate local focused runs executed the installed-alias test on both platforms and the controlling-terminal test on macOS without skips. The native build retains its existing containment
render_profilewarning. Both Linux build modes retain the 66 existing containment warnings. Hosted workspace build and test logs contain eight warnings from unchanged Shell tests; the prescribed lint job passed.The earlier revision passed six plain-file unit controls and detected each isolated defect mutation. This follow-up passed eight control invocations and detected four intended defects across five unique units, without skips. Product tests used legitimate binaries. The live tutorial used isolated binaries from
cargo build --all-features. Cargo test builds produced different binary hashes from the same source, with separate receipts. The earlier three product guard-removal checks remain historical evidence. This revision did not repeat every product test with protection disabled, and no counterfeit-launcher replay ran. These results do not establish release qualification or formal security acceptance.Checklist
Codex prepared the implementation, documentation, and validation. Human review of the complete diff remains pending, so the code-ownership attestation remains unchecked.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.