Repository navigation
fix: verify approved directories during Linux sandbox launch - #264
Conversation
## Problem The complete workload route lacks regression tests for execution after a denied directory moves. Existing identity checks already refuse that route. ## Solution Add six production tests for directory replacement, missing names, symbolic links, and scripts with listed or unlisted interpreters. Check execution markers, file identities, permitted execution, and unrelated renames. Use the existing prerequisite probe to report unsupported Linux execution platforms explicitly. Production code and public interfaces remain unchanged. ## Tests All six denied_executable tests executed and passed on Amazon Linux 2023 ARM64 before the prerequisite probe addition. Workspace lint passed with the repository's vendored allowances, and cargo fmt --all passed. Independent review found and verified the prerequisite probe correction. The full workspace suite and deterministic suite are running for the final source. macOS execution remains pending hosted validation. Earlier mutation evidence on e0af331 showed three actual executions when the denial identity check was disabled. The other three variants retained overlapping refusals.
## Problem An allowed rename could replace an execution-granted directory after Box approved it. Later launches could then run a replacement program at that pathname. Independently prepared nested mounts could also select objects outside the retained execution directory. ## Solution Retain each execution directory's approved identity throughout the run. Reuse its prepared reference, validate identity across Linux helper serialization, and bind nested objects through the checked directory. Preserve supported aliases and document recovery and platform limits. ## Tests Add production regressions for directory and ancestor replacement, plus identity-lifetime, helper-loading, nested-mount, and alias controls. Both production cases fail on unmodified main and pass after this change. Formatting, lint, all-target/all-feature and no-default builds pass. Deterministic acceptance: 124 pass, 9 macOS-only skips. Workspace: 4612 pass, 1 initial catalog timing failure, 17 ignored. The original timing test passes its focused rerun; the initial failure remains documented and unexplained.
|
Assessment: Request Changes Keeping the directory identity closes the case the tests cover. Two cases with the same cause stay open or newly break: Review Categories
Assumptions and rules checked that held:
The tests run the real replacement end to end and check that it is refused. |
|
Assessment: Comment (re-review of Since What I checked in the follow-up
Rules checked that held: the new hint is attached only where a pin exists; the docs no longer suggest that file entries are covered; and the follow-up adds no new public API or wire change. |
|
Assessment: Comment (re-review of Since What I checked in the consolidation
Rules checked that held: the consolidated file matches the reviewed #201 revision; no frozen surface changes beyond the one already under discussion; the file-entry follow-up correctly goes through private reporting under |
|
Assessment: Comment (re-review of Since What I checked in the scope noteThe new rule is: "Unless a section explicitly states Linux behavior, this page describes … macOS." I checked each section that mentions Linux against it:
Rules checked that held: the note matches every section that names Linux; the change adds no code, wire, or API change; and the doc still marks the file-entry gap as out of scope. |
|
Assessment: Comment (re-review of I checked the merge resolution and found no new defect. Only What I checked in the bind arm of the resolved
|
## Problem A Linux launch can prepare one filesystem object and load a replacement at the same path. The serialized launch configuration need not change. Pinning an execution directory for the entire Box run also rejects later launches after an intentional replacement. ## Solution Carry each Linux grant's recorded identity through the launcher handoff. Keep the originating configuration with the process boundary, so its open references prevent object identifier reuse while the helper loads grants. Each new launch prepares the current object. Remove startup-directory retention and its extra nested-mount checks. Keep existing configured-command and denied-path guards, including the six unchanged regressions from PR201. The previously approved Linux identity wire field remains. Older helpers reject that field, so the library and helper must come from the same build. The change adds no public Rust types or methods and does not freeze contents. ## Tests On Amazon Linux 2023 ARM64, the baseline fails `a_directory_replaced_after_approval_is_refused_before_execution` and the fixed candidate passes. Both valid-launch controls pass on both revisions, including `a_replacement_approved_for_a_new_launch_runs_contained`. The baseline fails `a_boundary_keeps_unlinked_grants_open_until_it_drops`; the candidate passes in a 687-test Box library run with no skips. The two new grant-loading mismatch tests likewise fail on baseline and pass with the repair. The all-features workspace suite, 27 site-manifest tests, repository lint and format gates, and both feature-set builds pass. Deterministic containment passes 131 applicable cases with nine declared macOS-only exclusions. The no-default build's 66 warning identities match baseline exactly. Documented workspace ignores and Linux limits remain; the missing alias helper prerequisite was installed before the final Box library rerun. The examples runner finds no scripted examples; no live SDK tutorial ran. Current-head hosted macOS validation remains for CI after publication.
|
Assessment: Comment (re-review of This head is a merge of main Cases checked against the new
|
|
Assessment: Comment (re-review of
Interactions with main that I checked
Local evidence (x86_64): Assumptions and rules that held: the per-launch handoff refuses a replaced object and fails closed on a race; denials and legacy configs keep their wire shape; the containment façade adds no |
Human readable section
Problem. Box can run a program from a replacement directory on Linux even though it approved a different directory for that launch. Box first selects the files and directories the program may access. A separate launch helper then creates the Linux sandbox. If another process replaces a directory at the same path between those steps, the helper can use the replacement. The launch configuration does not need to change.
Solution. Box keeps the approved files and directories open and passes their identifiers to the launch helper. Before creating the sandbox, the helper checks that each allowed path still names the approved file or directory. If a path names a replacement, the helper rejects that launch before the program starts.
Trade-off. Box holds those open references until the launched process exits. Each later launch can select the directory then present, subject to existing checks. This change does not freeze directory contents or protect operator-authored configuration from an agent that can edit it.
Description
In Box's
box.toml, theexeclist under[agent.filesystem]names executable files or directories available for execution inside the agent's sandbox. Consider an entry that names the illustrative directory/tools:/tools./toolsbefore the launch helper loads its configuration.A later launch prepares its access separately. It can select the replacement directory if the existing checks permit it. The directory replacement operation itself is not blocked by this change.
Figure 1: Box checks the directory again before starting the program. A replacement after approval stops that launch; a later launch can approve the replacement.
Editable diagram source
How the check works
Linux identifies a file or directory by its filesystem device, inode number, and type. The inode number identifies an object within that filesystem. Box includes these values in the access configuration sent to the helper, and the helper compares them with the file or directory it opens. Keeping the original references open prevents Linux from reusing their identifiers during this handoff.
The check applies to allowed filesystem access. Existing checks for configured tool programs and denied paths remain in place.
Compatibility
The Linux helper configuration gains an
identityfield containing those identifiers. Existing configurations without the field retain their previous behavior: they select the file or directory present when loaded. Older helpers reject the added field, so the containment library and launch helper must come from the same build. The existing interface approval covers this field and requirement. This revision adds no public Rust types or methods.Related Issues
Supersedes #201. Its six tests for denied executables and their permitted-execution controls remain unchanged.
Type of Change
Bug fix
Testing
Implementation revision:
760d5125b259bde18104fe08e331482e3a3eade5. Its main parent is6097aed88c4c0e0a3f115efc40ad2b0e0c100c64. The diagram assets are published separately at2b48a9073d0983d85a38e72c262b2518455202d4; this description update does not change the PR’s implementation or tests.1d5cb05, the replacement program ran despite unchanged launch-configuration bytes. With the fix, that launch stops before execution. An unchanged directory and a replacement approved for a new launch both work.--locked --all-features --no-fail-fast -- --show-output. Hosted Linux and macOS workspace jobs also pass.760d512found no blocking issues. Formal maintainer approval remains required.The Linux workspace reports two documented runtime omissions: the optional service that supplies credentials was unavailable, and one file-read protection assertion was omitted while its write-protection assertions ran. The check for unexpected test skips passes. None of the 15 focused tests skips; tests declared ignored remain separate.
The production-helper tests control the replacement timing directly. They do not prove that an agent can cause the replacement under a particular operator policy. Both permitted-launch cases run inside the sandbox and cannot read a test file outside their allowed paths.
scripts/test-all.sh box-examplesrebuilds the candidate but reports that no scripted examples remain. The live SDK tutorial was not run.just check, orcargo test --workspace --all-features)Checklist
Codex implemented and reviewed this change at Kevin's request, including independent source and documentation review. These attestations describe that delegated work; they do not claim formal maintainer approval.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.