Repository navigation
fix(box): refuse the box's private tree in the kernel - #145
Conversation
## Problem The workload must never reach `<box_dir>/private/`. The tree holds the record, the policy, the durable history, the containment configs, and the helper images. Today only the startup guards keep it closed. No profile carries a rule for it, so a grant spelling that a guard does not detect reaches the tree, and the kernel does not stop the access. Also, a refusal renders only its own spellings and not its `/System/Volumes/Data` spelling. ## Solution `Boundary::translate` adds one refusal of the canonical private tree, at `Root` scope, beneath every grant. Each profile that Box builds holds it: the agent box, each tool leaf, and each MCP leaf. On macOS the refusal renders after every allow. On Linux it lowers to an empty read-only overmount. The refusal is not an operator `deny` entry, so the startup disclosure does not show it. The startup guards do not change. Seatbelt now renders each refusal under its data-volume spelling too, the same as the credential floor does. This applies to every refusal, operator `deny` entries included. The Linux view plans a `Dir` grant as a fresh read-only filesystem unless a grant sits below it. A refusal below it now counts the same way, because its mountpoint cannot be created on a read-only filesystem. No frozen surface changes. ## Tests - `every_profile_refuses_the_private_tree_after_every_allow_that_reaches_it` shows that the agent, tool-leaf, and MCP-leaf profiles refuse the tree in both spellings. It fails when the refusal is removed and when the data-volume spelling is removed. - `a_refusal_renders_its_data_volume_spelling_after_every_allow` pins the Seatbelt half. - `a_refusal_replaces_its_metadata_only_ancestor` pins the Linux plan, and `a_refusal_beneath_a_metadata_only_directory_establishes` applies it. Without the planner change the apply fails with `Read-only file system`. - `the_eight_lists_translate_to_their_cells` now shows that only the refusal names the private tree. - `the_boxs_own_private_tree_is_unwritable_from_inside` writes into `private/` and its helper directory from a real box. The test passes on main too, because the guards hold there. It guards against regression and does not prove the floor. - The floor was proved on a macOS host, on a scratch branch with the guards disabled and a write grant on the directory that holds the box. On main the helper image changed and a new file appeared. With this change both writes failed with EPERM, and a write beside the box succeeded. - macOS host: box_filesystem 24/24 and the box library tests pass before and after. ARM64 Linux host: box_filesystem 24/24. The deterministic containment suite on EC2 gives the same result per case before and after: Linux 61/2/16, macOS 61/5/3/10, which is the standing set.
|
Assessment: Approve Focused security hardening that closes the box's private tree in the kernel rather than relying solely on the startup guards. The core change is a single unconditional Review notes
Nicely scoped change with strong defense-in-depth reasoning and thorough cross-platform verification. |
|
Re-review @ The incremental commit touches only Two prose-only, non-blocking notes:
No code changes requested. |
Summary
This change adds kernel-level enforcement for
<box_dir>/private/. Before, only startup checks in Box kept the workload out of this directory. Now the operating system also blocks every read, write, and execute in it, from the agent and from every tool and MCP server. The startup checks stay as the first, readable error.Description
Context. Each box keeps its own state in
<box_dir>/private/: the stored record, the policy, the durable history, the containment configs, and the helper images. The workload must never reach this directory.Before. Box checked each filesystem grant at startup and refused a grant that reaches or encloses
private/. No sandbox rule named the directory. If a grant got past the startup check, for example through a path name that the check did not recognize, the kernel did not stop the access. Also, on macOS a refusal rule named only the usual path, and not the same path under/System/Volumes/Data.After.
<box_dir>/private/beneath all grants: the agent box, each tool, and each MCP server. On macOS, Seatbelt denies every operation in the directory, and the rule comes after every allow rule. On Linux, the namespace view puts an empty read-only mount over the directory./System/Volumes/Data, as the credential rules already do. This also applies to operatordenyentries.denyentry, because Box adds it. No frozen interface changes.Related Issues
None.
Type of Change
Bug fix
Testing
every_profile_refuses_the_private_tree_after_every_allow_that_reaches_ita_refusal_renders_its_data_volume_spelling_after_every_allowa_refusal_replaces_its_metadata_only_ancestora_refusal_beneath_a_metadata_only_directory_establishesthe_boxs_own_private_tree_is_unwritable_from_insidewrites into the directory from a real box. It passes on main too, because the startup checks hold there, so it protects against regressions.private/succeeded. With this change it failed withEPERM, and a write next to the box still succeeded.private/on Linux, because the directory is an empty mount there. The test still requires every file read and write to fail, and the host files to stay unchanged./System/Volumes/Datadeny lines.box_filesystempasses 24/24 on macOS and on ARM64 Linux, and the deterministic containment suite gives the same result for every case before and after.cargo test -p strands-box --all-featuresandcargo test -p strands-box-containment --all-features --no-fail-fast, on x86_64 Linux, ARM64 Linux, and macOS.cargo fmtandcargo clippy --all-targets --all-featureson the changed crates. No new warnings.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.