Skip to content

fix(linux): require existing grants for script interpreters - #262

Merged
kevin-orellana merged 15 commits into
mainfrom
feature/script-interpreter-grants
Nov 4, 2026
Merged

kevin-orellana merged 15 commits into
mainfrom
feature/script-interpreter-grants

Conversation

@kevin-orellana

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

Copy link
Copy Markdown
Collaborator

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 main 67e378ae16f2a8457a6b856228343086f404e743, the corrected #292 cleanup test at 2349ba8c1b84768f8681686d45df9137a82d8324, and the reviewed follow-up repairs below. Normal merges preserved both branches' history. The core interpreter-grant implementation is unchanged by this refresh.

  • The terminal regression collects its expected output across reads within the original deadline. It still rejects wrong or missing output.
  • The Claude cloud example resolves Python once and uses that same path in the generated script header and its explicit readable-file grant. This supports this PR's interpreter rule. The unchanged tutorial image pins an older Box revision; these checks do not establish that image failed or qualify an EKS deployment.
  • The test: initialize supervisor before timeout cleanup checks #292 cleanup regression exercises the real spawning helper with a ten-second startup budget and checks that timeout cleanup stops the workload.
  • The policy binding fixture keeps the replaced shim open until every assertion completes. This prevents its old file identity from being reused by a later fixture. Production policy code is unchanged.
Local verification of the incorporated changes Result and limits
Policy, all features cargo test -p strands-box-policy --all-features --locked: 542 reported passes, zero failures, seven intentional ignores, zero filtered.
Policy, optional features disabled cargo test -p strands-box-policy --no-default-features --locked: 366 reported passes, zero failures, five intentional ignores, zero filtered.
Required policy gates Build and all-target Clippy passed for both feature sets. Policy-owned warnings were zero. Scoped formatting and strict documentation builds (RUSTDOCFLAGS="-D warnings") passed.
Policy binding controls All eleven binding tests passed, including the replaced-file and unbound-file assertions. A separate 100-trial unretained control and 100-trial retained control did not reproduce the historical allocation failure. The retained control confirmed the old unlinked file identity stayed allocated.
Terminal and example repair The peer's reviewed revision passed all 664 containment tests and all nine offline cloud-example tests. The repaired split-read control passes; the baseline and wrong/missing-output controls fail. The new example regression fails without the explicit grant and covers direct and symlinked Python paths.
Cleanup regression All eleven process tests passed on the incorporated #292 revision. Forcing the helper to kill only its direct child fails the workload-liveness assertion. A two-second startup delay passes with the new ten-second budget and fails with the old one-second budget.

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 d24b71e Linux 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 d24b71e

Commit: d24b71ec1c61a910300cdacc8a104aca6af989ef. The branch includes main 67e378ae16f2a8457a6b856228343086f404e743, including the compiler and Python metadata repairs from #288, and the unchanged two-file cleanup startup repair from #292 at 3b1ada004ce7167c0035f72bd0278a97a1b256ec. Both merges preserved history and required no manual conflict resolution.

The interpreter-grant patch is unchanged. The duplicate protect_parents test 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.

  • The Linux policy test grammar::bindings::tests::each_spawn_resolves_by_its_program_file_and_its_called_name failed at bindings.rs:511: usr/bin/ls called as ls returned Some(Undeclared) instead of None. That policy source is unchanged by this PR. Its historical cause was not established; the current fixture stabilization and its limits are recorded above.
  • macOS workspace tests, lint, packaging, native macOS tests, site manifest, and Verdict passed.
  • All 104 Linux and 103 macOS standalone harness library tests passed, including the repaired cleanup regression. No library tests were ignored or filtered.
  • Full deterministic integration passed: Linux recorded 131 passes plus nine declared platform skips; macOS recorded 128 passes plus twelve declared platform skips. Both recorded all 140 expected cases, with zero failures or errors. The ignored documentation test and existing platform gaps remain.
  • Automated review identified a newly merged example migration: the EKS Claude example generates a Python server script without an explicit interpreter grant. That repair was not in d24b71e. The current combined revision includes the explicit interpreter grant and offline regression described above.

Historical conflict repair

Commit: f75f99060104a67f9e287ff50d22772ae2db85ea, merging main e95d0c808f33d05afb246415fb9b57cf35cb0078. The final reviewed source tree is dbe6c801009d8c0d30e6d03a79eca7b0fa33875d.

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_parents helper 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 tree 2213bdf29db0213cd752cf2b6f4d4221f528c21d; the final tree changes only the two fixture configurations that failed below. Production code and every other test remain unchanged.

Check Result and limits
First full workspace attempt Failed: 4,827 reported passes, two failures, 17 ignored, and zero filtered across 148 final target summaries. Counts exclude one nested child summary; the custom box_library target emits no count. scripts/test-all.sh exited 1 after 1,401.4 seconds.
Two fixture repairs The linked-script and operator-launcher fixtures lacked the interpreter grants this PR requires. Each corrected case passed separately, with its original assertions intact and no prerequisite skip. Their first targets recorded 60 other passes plus one ignored test, and 11 other passes, respectively. The full workspace was not repeated.
Three omitted helper checks The first workspace attempt returned early from the alias-image check and both post-translation mutation checks because helpers were missing beside the unit binary. After staging the built helpers as the workflow does, all three executed and passed without skips. These follow-ups do not inflate the original workspace pass count.
Live interpreter regressions Both script integration cases executed and passed. Both post-translation cases also executed in the helper follow-up, retaining permitted and refused controls for agents and tools. The installed tool remains unchanged in the revised same-run fixture.
Linux containment cases 124 passed, nine declared macOS-only skips, all 133 cases recorded, no failures, errors, integrity problems, or quarantine. The first setup attempt failed 13 cases because the copied runtime directory omitted three test helpers; it recorded 111 passes and nine skips. Supplying the documented helpers fixed setup without source changes. Both attempts are retained.
Mount-protection tests All ten alias-protection cases executed and passed within the full containment-library target.
Formatting, workspace lint, and builds Passed. Final lint checked all workspace targets and features with the repository's existing allowances. The build without default features passed with 66 existing containment warnings.
Output audits The original raw Cargo-output audit failed for the two failed tests and missing-helper diagnostics. All four supplemental logs passed the unchanged audit without prerequisite skips. The original failed audit remains recorded.

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 a84eb3e and current main.
The tested merge is 69f43bd464e8a319493d2b9d912bf5d7cca29b73, combining this head with main at 93a3761.
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 48985a1 found 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.

Suite Result
Linux workspace 4,610 passed, zero failed, 17 ignored, zero filtered. All four new live regressions executed without prerequisite skips.
macOS workspace 4,361 passed, zero failed, 16 ignored, zero filtered. Linux-only tests were excluded.
Linux deterministic containment 124 passed and nine declared platform skips; all 133 cases recorded.
macOS deterministic containment 121 passed and twelve declared platform skips; all 133 cases recorded.

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_library target 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.

Scenario Observed result
A workload changes a declared script between runs The later launch refuses the ungranted interpreter. An explicit grant permits the control. Authored configuration bytes remain unchanged.
A workload changes a declared tool’s interpreter during one run The original tool runs. The workload changes only its interpreter header; installed tool bytes remain unchanged. The next invocation refuses the ungranted interpreter. An explicit readable grant permits the marker-read control.
An interpreter changes after permission translation Real launches cover overwrite and atomic replacement for agent and tool grants. The unlisted interpreter produces no output; explicit grants permit execution.
Script-body bytes change after permission translation The changed script cannot read an ungranted marker. An explicit read grant permits the control.

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 e4ca8b80359b2213d684de31cd6ef32e0d61478a exposed 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

  • Formatting, whitespace checks, workspace builds, and repository-prescribed Clippy pass. Clippy uses the vendored-code allowances in just clippy and CONTRIBUTING.md.
  • The ten initial translator regressions failed against the original implementation. The final eleven cover original grants, nested chains, edits, process isolation, denied routes, protected sources, and diagnostics.
  • Building without default features passed, with 66 warnings in the unchanged containment crate.
  • The scripted-example command exited successfully but reported no scripted examples. The manual SDK tutorial remains untested.

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 a84eb3e and 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 of 6748a95 found 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.

  • 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

The 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.

  • 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

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

## 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.
Comment thread crates/box/src/run/contain/boundary.rs Resolved
Comment thread crates/box/src/run/contain/boundary.rs Resolved
Comment thread crates/box/src/run/contain/boundary.rs Resolved
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

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 crates/box/AGENTS.md still describe grants that Core adds automatically.

Review details
  • What I checked: I built at d3278f8 on Ubuntu 24.04 (merged /usr). All 26 interpreter lib tests pass. I wrote temporary probes, now reverted, for the #!/bin/sh refusal path and for the disclosure output.
  • Operator guidance: When a script names its interpreter by a link, which is the common case on merged-/usr systems, the operator needs a second failed start before they find the path to grant (inline).
  • Written rules: The crate AGENTS.md still says Linux grants the interpreter chain automatically. The disclosure labels interpreter spellings as exec grants that Core added (inline).

Assumptions and rules checked that held:

  • An [agent] interpreter needs exec coverage: a read-only grant is refused, and an exec root becomes a Read alias that view.rs makes executable because its source is inside that root.
  • A leaf read/read_file/write grant can run the interpreter because of the leaf's broad exec, and it adds no file to library (dependency) discovery.
  • When the operator's own exec grant names the interpreter, the alias grant replaces it once (interpreter_exec_files skip). The alias binds both spellings, so no access is lost.
  • An earlier interpreter cannot authorize a later one: each check uses only the original grants.
  • Route checks hold. Denied paths, Box state, and protected authority sources are refused on the script's spelling, on every link it passes through, and on the final file. The canonicalize step at denial.path cannot fail on a missing path, because Linux already refuses a deny on a missing path in filesystem.rs.
  • Credential floors apply to the aliases too, because require_bounded_grant checks every node on the lookup path (traversal_paths).
  • The MustBeListed and macOS branches are unchanged.
  • The mcp.md uv mcp-server-fetch example still starts: its read root covers the venv's linked python.
  • deny entries must exist on Linux, so building the denial list cannot fail when a configuration is valid.

The tests cover a wide range of cases, and they include link-spelling and protected-source alias paths.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

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 6dad0de. All three earlier findings are fixed, and I found no new problems in the follow-up commit.

What I checked at 6dad0de (Ubuntu 24.04, merged /usr)
  • All 26 interpreter tests and all 59 contain::boundary tests pass.
  • I added a temporary test, now removed, for a script starting with #!/bin/sh:
    • [agent]: the refusal now says add /usr/bin/dash to exec``. After that one change, translation succeeds on the first try.
    • [tool.t]: the refusal now says add /usr/bin/dash to read_file``. After that one change, translation also succeeds on the first try.
    • In both cases the startup output shows alias /bin/sh -> /usr/bin/dash (interpreter spelling) in its own section. No exec … (interpreter) line appears under "runtime minimum, added by Core" any more.

Assumptions and rules checked that held:

  • The recommended path is always the real file, and following the advice is enough to start. The route checks (denied paths, Box state, protected sources) run before the coverage check, so the refusal never recommends a path that a later check would refuse.
  • On Linux, interpreters only feeds the startup output. Removing the alias push changes no grant.
  • macOS is unchanged: interpreter_aliases is always empty there, and the old (interpreter) lines still print.
  • For tools, read_file on a system interpreter is enough. The tool minimum already reads /usr/lib and the other loader directories as trees, so the interpreter's own libraries are visible.
  • crates/box/AGENTS.md, docs/user/config.md, and docs/design/architecture.md now match the output. This satisfies the root AGENTS.md rule that a startup-output change updates those documents. No skill under .agents/skills describes the old behavior.

The fixes are narrow and each one comes with a test.

Comment thread crates/box/src/run/contain/boundary.rs Resolved
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Assessment: Comment

I re-reviewed at c9a69ff. The new commit only adds tests and a CI step; the product code is unchanged from 6dad0de, which I approved earlier. One test problem remains (inline): the new library tests that run a real sandbox fail, rather than skip, on ARM64 Linux machines outside CI.

What I checked at c9a69ff
  • Scope of the commit: compared with 6dad0de, it changes three files. It adds the live_script_mutation test module in boundary.rs, adds tests/script_interpreter_grants.rs, and adds a CI step that copies the trampoline into target/debug/deps. Product code is unchanged.
  • Test logic (read only; this runner is x86_64, where the module and file are compiled out):
    • The library tests cover four cases (agent or tool, script edited in place or replaced). They check that changing the script after translation cannot start an unlisted interpreter or read an ungranted file, and that adding the grant makes the same case succeed.
    • The integration tests use an interpreter file named env, copied from cat. The script names the marker as the program that env selects. Without a grant, the refusal must name the marker. With the grant, the marker's contents are printed.
    • Both suites test a script changed by an earlier run and a script changed during the same run.

Assumptions and rules checked that held:

  • Limiting the tests to ARM64 (target_arch = "aarch64") matches the existing tests: Box runs boxes on Linux only on ARM64 (fixture.rs::namespace_launcher_is_usable), and the Linux CI runner is ubuntu-24.04-arm.
  • A real box run finds the trampoline next to the box executable in target/debug. Only library tests need the new CI copy step.
  • check-linux-test-output.py would reject a new skipping: line in CI, so adding a skip guard locally does not weaken the CI requirement to actually run these tests.

The replace-versus-overwrite cases and the matching cases with the grant added make these useful tests for the change.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Assessment: Approve (from a code-review standpoint)

I re-reviewed at a84eb3e. This commit fixes my earlier finding: the new library tests now skip with a skipping: line, instead of failing, on machines that cannot run a sandbox. I found no new problems.

What I checked at a84eb3e
  • Scope: compared with c9a69ff, the commit changes test support only.
    • boundary.rs::live_script_mutation now starts each test with launcher_is_usable().
    • The namespace check moved to tests/support/namespace_launcher.rs. fixture.rs and the library tests now both use that one copy.
  • How the new check handles each case:
    • In CI (ARM64, trampoline copied, namespaces allowed), the tests run.
    • On a developer machine running just test, where target/debug/deps has no trampoline, the tests print skipping: no plain executable strands-box-contain-trampoline beside the test binary.
    • On a machine that blocks user namespaces, the shared namespace check prints its usual skip line.
    • If the trampoline is a symlink, the tests skip. This matches the real trampoline lookup in validate_installed, which also refuses links.
    • If CI ever loses the copied trampoline, the skip text is not in EXPECTED_SKIPS, so check-linux-test-output.py fails the job instead of hiding the gap.
  • Build checks:
    • cargo check -p strands-box --tests --all-features passes on x86_64.
    • cargo clippy -p strands-box --all-targets --all-features -- -D warnings with the just clippy allowances passes when cross-compiled for aarch64-unknown-linux-gnu. That build is the only one that includes the live_script_mutation module and script_interpreter_grants.rs.
    • I could not run the ARM64 tests here: the box_entry_guard build script links with the x86_64 compiler.

Assumptions and rules checked that held:

  • The new check accepts the same file that the real trampoline lookup accepts (a regular file with an execute bit). A test therefore skips exactly when a real launch would fail with TrampolineError.
  • CONTRIBUTING.md: "A test that cannot run on your host skips instead of failing." This is now met for the library tests as well as the integration tests.
  • Changing the shared namespace check from pub to pub(crate) breaks nothing: every caller is inside its own test crate.

@kevin-orellana
kevin-orellana marked this pull request as ready for review November 2, 2026 06:52
@kevin-orellana
kevin-orellana enabled auto-merge (squash) November 2, 2026 06:52
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Assessment: Approve (from a code-review standpoint)

I re-reviewed at 48985a1. Compared with a84eb3e, which I approved, this commit changes one file: it adds 5 lines to docs/design/linux-enforcement.md and removes 1. Each new statement matches the code and docs/user/config.md. I found no problems.

Statements checked that held:

  • Agent needs exec; tools and servers reuse grants they already have: tools and servers use RuntimeReach::Leaf in hosted.rs, and the agent uses RuntimeReach::Agent. This matches the table in config.md § Script commands on Linux.
  • Interpreters are checked against original grants, with no system-path exemption: this matches the behavior I verified at d3278f8 and 6dad0de. Each interpreter is checked only against the original grants, and config.md also says "System paths have no exemption".
  • Link: the target ../user/config.md#script-commands-on-linux exists. It is the ### Script commands on Linux heading.
  • Neighbouring text: the paragraph keeps "This discovery does not inspect script interpreter lines", and the new sentences don't contradict it. They describe the check on the declared command, which is separate from library discovery.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Important (blocks merge): The EKS Claude Code example from #279 came in with the main merge (a329ab9). Under this PR's interpreter rule, its local MCP server is refused at startup.

Example: In examples/cloud-deployments/eks/claude/claude_runtime.py:214-230:

  • The script writes runtime-demo-mcp with the shebang #! + Path(sys.executable).resolve().
  • In the image (eks/Dockerfile, Amazon Linux 2023 with python3.12), that resolves to /usr/bin/python3.12.
  • [mcp.runtime_demo.filesystem] grants only read = [/usr/lib, /usr/lib64, <mcp-data>, <stdlib>] and write = [<mcp-data>]. None of these covers /usr/bin.

main.py runs this path with exercise=True, and the EKS tutorial links to that Job. So the documented Claude Job, and its 23-check verifier, fails at this head.

I reproduced the refusal with a temporary boundary.rs test (since reverted). It used the same MCP grants, the real /usr/bin/python3.12, and RuntimeReach::Leaf:

invalid `[mcp.runtime_demo]` table: …/bin/run names the interpreter /usr/bin/python3.12, which no `read`, `read_file`, `write`, or `write_file` entry of [mcp.runtime_demo] authorizes; add /usr/bin/python3.12 to `read_file` in that table

No CI job runs this example, so the merge validation could not catch it. The other new cloud-deployment configs launch ELF programs directly (/usr/bin/bash, the resolved python3.12), so the rule does not apply to them.

Suggestion: In claude_runtime.py, grant the interpreter to the server table the way the PR's own fixtures do:

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.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Assessment: Request Changes

I reviewed f75f990..d24b71e. The branch now merges main 67e378a (a329ab9) and #292 (3b1ada0). The code in this PR is unchanged. The one blocking problem is the EKS example that main brought in (see the separate comment).

What I checked at d24b71e

Merge content

Interaction with #261 (exec grants for writable libraries)

Scripts launched by new main content

  • I scanned every #! line that main added since e95d0c8.
  • The only config that launches a declared script is the EKS Claude MCP server. It breaks under this PR.
  • The AgentCore and EKS-scripted configs run ELF commands directly, so the rule does not apply to them.

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.
@kevin-orellana

kevin-orellana commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

Addressed in 6748a95c8f40e930b6ddb6e8f3566a78a687a00c, incorporating reviewed commit dfedfc717444e2edb400304bfea6deeed54d2011.

claude_runtime.py now resolves Python once and uses the same path in both the generated server's shebang and [mcp.runtime_demo.filesystem].read_file. The new offline regression checks direct and symlinked interpreter paths and fails without the explicit grant. All nine offline cloud-example tests passed on the reviewed component revision. Fresh offline cloud-example checks passed at the combined head.

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.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Assessment: Approve (from a code-review standpoint)

I reviewed d24b71e..6748a95. The blocking EKS finding from my last round is fixed, and the other new commits only change tests. I have no new findings.

What I checked at 6748a95

EKS Claude MCP interpreter (dfedfc7)

  • claude_runtime.py now resolves sys.executable once. It uses that path both in the shebang and in [mcp.runtime_demo.filesystem].read_file, so the two cannot drift apart.
  • I checked how the fix handles each case:
    • The Amazon Linux 2023 image's real /usr/bin/python3.12: allowed.
    • A symlinked sys.executable: resolves to the same canonical path (the new test covers this).
    • exercise=False (check-policy-boundaries.py): writes no server and no grant.
    • The agent table: gets neither the read_file entry nor an exec grant.
  • I re-ran my earlier temporary boundary.rs probe with the example's grants and the real /usr/bin/python3.12, now reverted. Without read_file the server is refused; with it, Box accepts the table.
  • python3.12 examples/cloud-deployments/eks/test_run.py: 9 tests pass, including the new configuration test.
  • The Claude agent binary comes from the claude-code-linux-arm64 package, which ships a native executable, so the agent table needs no interpreter grant.

Test-only commits

  • terminal.rs now reads terminal output in pieces until a deadline. A closed terminal or a read error still fails the test.
  • bindings.rs keeps the replaced shim open so the system cannot reuse its file identity while the test checks bindings.
  • test-integ/src/process/tests.rs (2349ba8) is byte-identical to the current head of pr/292. Main is unchanged at 67e378a.

Assumptions checked that held

Note: The Testing section of the PR description still names d24b71e as the evidence commit, and dfedfc7 says broader workspace validation is still running.

@kevin-orellana
kevin-orellana merged commit 812b75e into main Nov 4, 2026
36 of 38 checks passed
@kevin-orellana
kevin-orellana deleted the feature/script-interpreter-grants branch November 4, 2026 16:04
if launch.shebang_interpreters == ShebangInterpreters::Granted {
let prepared = ContainmentConfig::prepare_filesystem_path(spelled)?;
let resolved = prepared.resolved_path();
let operation = stated_interpreter_operation(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - Agent Containment bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants