Repository navigation
fix(linux): require existing grants for script interpreters - #262
Conversation
## Problem Declared script contents can introduce interpreter access beyond the process's original filesystem grants. The failing baseline tests declared_scripts_refuse_unlisted_interpreter_files_regardless_of_mode and replacing_a_script_header_cannot_expand_its_original_interpreter_authority pin this behavior. ## Solution Require every Linux declared-command interpreter to reuse original grants. Agents require exec. Tools and local servers can reuse existing readable access, pinned by an_agent_cannot_use_a_read_grant_as_interpreter_exec_authority and a_declared_leaf_reuses_read_and_write_interpreter_grants_without_exec_seeds. Preserve authorized path spellings without adding native dependency authority. an_agent_reuses_interpreter_exec_trees_without_adding_exec_file_seeds pins that limit. Check denied routes and protected source identities, pinned by interpreter_grants_do_not_override_denied_lookup_routes and an_interpreter_alias_cannot_bypass_authority_source_protection. Document the Linux configuration migration and update script fixtures. No public configuration key or containment API is added. ## Tests On stock Amazon Linux 2023 ARM64: - `cargo test --workspace --all-features --no-fail-fast -- --nocapture`: 4,607 reported passes, zero failures, 17 ignored tests. The run enables `EXPERIMENTAL_LINUX_SUPPORT=TRUE`. - `cargo build --workspace --locked --all-targets --all-features`: passed. - Workspace formatting and the repository's `just clippy` command equivalent: passed. - Standalone integration harness library: 93 passed. The existing `cn_e_02` launcher control: one passed, zero ignored. - Six generated hook configurations, Bash syntax, and Python parsing: passed. The workspace count includes runtime omissions. The cardinality probe and credential daemon are absent, and one alias-read assertion is omitted. The eleven new interpreter regressions executed. See the inherited ignored tests separately from executed coverage. The existing cn_e_02 launcher control refuses an unlisted interpreter and passes with explicit env and sh grants. Six generated hook configurations pass syntax and grant checks. Strict lint passes for the changed standalone integration library. Its all-target lint fails on an existing documentation lint in unchanged cn_native_egress.rs:33. The ten initial translator regressions failed before the repair. Mutation through a live workload, launch-time races, native macOS execution, and the full agent-hook workload were not run. No security acceptance is claimed.
|
Assessment: Comment On Linux, the change now authorizes interpreters only from the process's own original grants. I traced the real cases through it and found no hole. The remaining problems are in what the operator and future contributors are told. The refusal names a path that cannot be granted. The startup disclosure and Review details
Assumptions and rules checked that held:
The tests cover a wide range of cases, and they include link-spelling and protected-source alias paths. |
|
Assessment: Approve (from a code-review standpoint; the PR stays draft for the mutation and launch-time validation in your own checklist) I re-reviewed at What I checked at 6dad0de (Ubuntu 24.04, merged
|
|
Assessment: Comment I re-reviewed at What I checked at c9a69ff
Assumptions and rules checked that held:
The replace-versus-overwrite cases and the matching cases with the grant added make these useful tests for the change. |
|
Assessment: Approve (from a code-review standpoint) I re-reviewed at What I checked at a84eb3e
Assumptions and rules checked that held:
|
|
Assessment: Approve (from a code-review standpoint) I re-reviewed at Statements checked that held:
|
|
Important (blocks merge): The EKS Claude Code example from #279 came in with the main merge ( Example: In
I reproduced the refusal with a temporary No CI job runs this example, so the merge validation could not catch it. The other new cloud-deployment configs launch ELF programs directly ( Suggestion: In f'[mcp.runtime_demo.filesystem]\nread={json.dumps(reads)}\n'
f'read_file={json.dumps([str(Path(sys.executable).resolve())])}\n'The example config is written in a separate place from the shebang, so the same resolved path needs to appear in both. |
|
Assessment: Request Changes I reviewed What I checked at d24b71eMerge content
Interaction with #261 (exec grants for writable libraries)
Scripts launched by new main content
Assumptions checked that held
|
Problem: The terminal regression assumed one read returns its entire output marker. The Claude cloud example omitted the script interpreter required by PR262. Solution: Collect bounded terminal output across reads with the original deadline. Resolve Python once and reuse its path in the script header and server grant. Check direct and symlinked interpreter paths without a cloud connection. Tests: All 664 containment tests pass with all features. Required package build, formatting, and all-target clippy pass with no new all-feature warnings. All nine cloud-example tests pass with Python 3.12. The new grant test fails before the fix; split-read baseline and wrong/missing-output controls fail. Broader workspace validation is still running. No cloud deployment is claimed.
|
Addressed in
This fixes the example configuration when used with this PR's interpreter rule. The tutorial Dockerfile still pins an older Box revision, so this is not evidence that the unchanged pinned tutorial image failed. No live EKS deployment or end-to-end cloud qualification is claimed. Reply to the automated example finding. |
|
Assessment: Approve (from a code-review standpoint) I reviewed What I checked at 6748a95EKS Claude MCP interpreter (
Test-only commits
Assumptions checked that held
Note: The Testing section of the PR description still names |
| if launch.shebang_interpreters == ShebangInterpreters::Granted { | ||
| let prepared = ContainmentConfig::prepare_filesystem_path(spelled)?; | ||
| let resolved = prepared.resolved_path(); | ||
| let operation = stated_interpreter_operation( |
There was a problem hiding this comment.
Do we want to check nested scripts as well? For example, let's say we have outer.sh that calls nested.sh. It seems nested.sh won't have its shebang validated. It appears though linux will still check the permissioning and so prevent unauthorized script execution. But it then makes me wonder, why validate outer.sh and not also just rely on linux to raise the permissioning errors (if I am understanding this change correctly)?
Human readable section
Problem: Linux declared scripts could add interpreter grants from their contents. Those grants could exceed the process's configured filesystem access.
Solution: Check each discovered interpreter against that process's original grants. Agents need
exec. Declared tools and local servers can reuse their existing readable grants. Preserve required path spellings only for authorized files. Explicit denials and protected sources still apply.Trade-off: Linux configurations that relied on automatic interpreter grants must cover every interpreter with the process's existing filesystem grants. Readable tool interpreters can also need separate grants for non-system libraries. This change restricts permission expansion; it does not make script bytes immutable.
Description
Check each interpreter against the process's original grants throughout the chain. An earlier interpreter cannot authorize a later one. Preserve required path spellings only for authorized files, without adding a new source for native-library discovery. Refusals identify the canonical path that needs a grant.
The change includes eleven translator regressions, four live-launch regressions, migration documentation, fixture updates, and Linux helper staging. Unsupported developer hosts report missing launcher prerequisites explicitly. Hosted checks reject those skips. The macOS discovery branch and workload-selected command branch remain unchanged.
AI assistance: Codex implemented and reviewed this patch at the maintainer's request. Codex reviewed every changed file; a second agent reviewed the patch independently.
Related Issues
No public issue linked.
Type of Change
Bug fix with a Linux configuration compatibility change.
Testing
Current combined revision
Commit:
6748a95c8f40e930b6ddb6e8f3566a78a687a00c. This branch includes main67e378ae16f2a8457a6b856228343086f404e743, the corrected #292 cleanup test at2349ba8c1b84768f8681686d45df9137a82d8324, and the reviewed follow-up repairs below. Normal merges preserved both branches' history. The core interpreter-grant implementation is unchanged by this refresh.cargo test -p strands-box-policy --all-features --locked: 542 reported passes, zero failures, seven intentional ignores, zero filtered.cargo test -p strands-box-policy --no-default-features --locked: 366 reported passes, zero failures, five intentional ignores, zero filtered.RUSTDOCFLAGS="-D warnings") passed.The policy checks ran on Amazon Linux 2023 ARM64 with Rust 1.98.1. These results cover the reviewed component changes; no repeated local full-workspace run or local macOS run is claimed for the combined commit. Independent review verified that the five changed files match the reviewed components exactly.
Cargo.lock, credentials, and the egress gateway are unchanged.Current-head CI passed the Linux workspace, both deterministic containment suites, lint, packaging, site-manifest, native macOS, offline cloud-example, and CodeQL checks. The first attempt's required CI Gate passed. The macOS workspace failed one unchanged catalog-scaling timing test: ratio 3.06 against a 3.00 limit. Its failure log remains part of the evidence. The existing workflow makes macOS advisory; the cause of this timing failure is not established.
The single failed-job retry passed at unchanged
6748a95c8f40e930b6ddb6e8f3566a78a687a00c. The catalog test measured a ratio of 1.72 against the 3.00 limit, and all macOS workspace test targets passed. The final required CI Gate passed. This repeat does not establish the cause of the first timing failure.The automated assessment accepted this exact head with no new findings. All four review threads are resolved. Human approval remains required, and squash auto-merge remains enabled.
The earlier
d24b71eLinux failure is retained below. The open-file guard addresses a source-supported fixture hazard; local experiments did not prove that inode reuse caused that historical CI failure.Earlier refresh at
d24b71eCommit:
d24b71ec1c61a910300cdacc8a104aca6af989ef. The branch includes main67e378ae16f2a8457a6b856228343086f404e743, including the compiler and Python metadata repairs from #288, and the unchanged two-file cleanup startup repair from #292 at3b1ada004ce7167c0035f72bd0278a97a1b256ec. Both merges preserved history and required no manual conflict resolution.The interpreter-grant patch is unchanged. The duplicate
protect_parentstest repair is now supplied by main. The #292 change waits for the test supervisor to initialize before exercising readiness timeout cleanup; it changes no product startup behavior. Independent merge review, full workspace formatting, standalone harness formatting, and whitespace checks passed. Fresh hosted CI at this combined head completed with one Linux workspace test failure; the required CI Gate failed. No new local full-workspace or native macOS result is claimed.grammar::bindings::tests::each_spawn_resolves_by_its_program_file_and_its_called_namefailed atbindings.rs:511:usr/bin/lscalled aslsreturnedSome(Undeclared)instead ofNone. That policy source is unchanged by this PR. Its historical cause was not established; the current fixture stabilization and its limits are recorded above.d24b71e. The current combined revision includes the explicit interpreter grant and offline regression described above.Historical conflict repair
Commit:
f75f99060104a67f9e287ff50d22772ae2db85ea, merging maine95d0c808f33d05afb246415fb9b57cf35cb0078. The final reviewed source tree isdbe6c801009d8c0d30e6d03a79eca7b0fa33875d.The merge preserves main's configured-command protection and library permission checks. Test fixtures now give their script interpreters explicit readable grants. The same-run mutation test keeps the installed tool unchanged and changes only its interpreter. Two containment tests also use the current
protect_parentshelper signature; no production protection was relaxed. Independent source review found no remaining defect.Validation used Amazon Linux 2023 ARM64, Rust 1.98.1, all features, two build jobs and test threads, and
EXPERIMENTAL_LINUX_SUPPORT=TRUE. The full attempt used tree2213bdf29db0213cd752cf2b6f4d4221f528c21d; the final tree changes only the two fixture configurations that failed below. Production code and every other test remain unchanged.box_librarytarget emits no count.scripts/test-all.shexited 1 after 1,401.4 seconds.The two fixtures initially failed before their intended behavior checks. Their repairs add only each tool's canonical interpreter to that tool's readable file list on Linux. They preserve the linked invocation path, operator program selection, tool-server isolation, and policy-record assertions. The macOS fixture configurations remain unchanged.
The workspace still omits the live credential-daemon check and one alias-read assertion; the alias write assertions ran. Seventeen ignored tests remain outside executed coverage. The example build passed, but no scripted examples remain and the manual SDK tutorial was not run. Current local macOS execution is untested. These results combine the preserved full attempt with targeted follow-ups; they are not a clean repeated full-workspace result.
GitHub accepted this head without conflicts. New hosted checks and automated review are pending. No human approval has been recorded; squash auto-merge remains enabled and waits for the required checks and maintainer approval.
Historical documentation revision
Commit:
48985a162d5813b4ee930e522681c390f3587f27.This follow-up only explains the existing interpreter grant checks in the Linux design guide.
Prose, whitespace, and link checks passed. A second agent reviewed the documentation diff.
No local runtime tests were repeated. Hosted checks for this head passed after one failed-job retry, including the required CI Gate.
The initial Linux deterministic attempt had a setup error, retained below.
The Git-hook case CN-W-05 failed while executing its copied control outside Box:
ExecutableFileBusy(Text file busy).The case stopped before its containment assertions. The failing test is unchanged from
a84eb3eand current main.The tested merge is
69f43bd464e8a319493d2b9d912bf5d7cca29b73, combining this head with main at93a3761.The initial suite recorded 123 passes, one setup error, and nine declared platform skips; all 133 cases were recorded.
A transient setup failure is possible; its cause is not established.
The single failed-job retry passed on the same tested merge.
CN-W-05 executed and passed. The retry recorded 124 passes, zero failures or errors, and nine declared platform skips, with all 133 cases recorded.
All other test suites and static-analysis jobs passed on their original attempts. The retry does not establish the cause of the initial setup error.
Automated review of
48985a1found no new problem.Validated implementation revision
Commit:
a84eb3ea1104cee511089b85c2bce4df6d43a88a.Hosted CI run 41400885794 passed on
a84eb3e, including its final gate. Both actual workspace test steps succeeded. Marking this PR ready started repeat checks on the unchanged commit; the completed validation below remains applicable.Both containment coverage gates passed, with no quarantine or integrity errors. Lint, packaging, native macOS checks, verdict checks, and all static-analysis jobs passed.
Workspace counts use final Cargo-target summaries and exclude nested child summaries. The custom
box_librarytarget emits no standard summary. Ignored tests remain separate from executed coverage. The Linux log records three unrelated omissions: the cardinality probe, one alias-read assertion, and the live credential-daemon fixture. macOS uses normal output capture, which does not establish an absence of runtime omissions.Live effectiveness tests
All four focused tests pass without warnings or skips on stock Amazon Linux 2023 ARM64, as a non-root user.
The fixtures use owned synthetic files. Each original integration script directly reads the same marker under its own grants. Access is refused without a grant and permitted with one. Denied cases use a non-executable marker.
Historical baseline comparison: the exact original revision
e4ca8b80359b2213d684de31cd6ef32e0d61478aexposed the marker in both original integration scenarios. Its production source was unchanged; only the then-current regression tests were added. Both direct-refusal controls and the cross-run configuration checks passed before the intended exposure failures. The same test revision passed on the original repair, including its explicit-grant controls. The current merge migrates the same-run fixture for main’s configured-tool protection. That revised fixture was not rerun on this old baseline; the historical comparison is not new baseline proof for it.Separate copied-binary controls verify missing-helper and refused-namespace diagnostics. Both omit the live assertions explicitly. The unchanged hosted output checker rejects both skipped logs and accepts the normal logs. Actual launch failures remain test failures.
Historical implementation validation
just clippyandCONTRIBUTING.md.The workspace log reports the existing one-millisecond performance target miss tracked in issue #150. Relative-cost assertions pass; this repair makes no performance-target claim.
Review and limits
Earlier automated review confirmed the prerequisite repair at
a84eb3eand found no new problems. Codex and independent agents reviewed the incorporated repairs and final combined diff and found no remaining source blocker. The four earlier review threads are resolved. The current combined head passed its required CI Gate and both workspace suites, with one macOS retry as recorded above. Automated review of6748a95found no new findings. Required human approval remains outstanding.The hosted reviewer compiled tests and checked ARM64 compilation, but could not execute ARM64 tests. Local native runs and hosted workspace tests provide separate execution evidence.
The post-translation tests establish filesystem enforcement for the tested mutations, not immutable script bytes or exhaustive race coverage. The new same-run test covers a declared tool, not a local server. The full agent-hook workload and local native macOS execution remain untested; macOS evidence comes from hosted execution. Passing tests and automated review do not establish security acceptance, release acceptance, or required human approval.
just check, orcargo test --workspace --all-features)cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsThe workspace lint command uses the repository-prescribed allowances noted above.
Checklist
The review checkbox records delegated agent review at Kevin's request. Required human approval remains separate.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.