Skip to content

fix(box): allow startup while protecting inaccessible executable aliases - #343

Merged
kevin-orellana merged 1 commit into
mainfrom
feature/runtime-mounted-executable-aliases
Nov 6, 2026
Merged

kevin-orellana merged 1 commit into
mainfrom
feature/runtime-mounted-executable-aliases

Conversation

@kevin-orellana

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

Copy link
Copy Markdown
Collaborator

Human readable section

Problem: A Linux mount can expose an installed Box executable through a directory that the Box user cannot enter. The check added in #295 refuses every launch when inspection of that path returns permission denied. This blocks unrelated workloads, including non-root AgentCore Runtime deployments.

Solution: Retain the inaccessible path as a possible executable alias, meaning another path to the same file. Box still rejects writable grants and file changes that could modify that path or its enclosing directories. Workloads that write elsewhere can start.

Trade-off: An inaccessible candidate can point to a different file. Box protects it conservatively, so an overlapping write can still be refused. Unexpected inspection errors and unstable mount tables still refuse the check.

Description

Keep permission-denied candidates in the Linux installation protection list. The existing grant and hosted Shell/Python checks then protect those paths.

The real mount test hides a second executable path behind a directory that the test process cannot enter. While inspection fails, unrelated sibling grants remain usable. The test rejects enclosing write grants for the agent, tools, and Model Context Protocol (MCP) servers. It also checks the protection that Shell/Python apply to enclosing-path changes. After directory permissions are restored, it rejects a direct write grant and a change to the executable path. The installation documentation describes this behavior.

The core correction comes from Ravi Kandury's proposed fix. This PR includes AI-assisted implementation, tests, source review, and prose. Human review remains pending.

Related Issues

Follow-up to #295.

Type of Change

Bug fix

Testing

Check Source Result
Baseline Runtime comparison Original #295 merge, a4a4645 23 of 26 checks failed in both managed-code and container deployments. Ordinary workloads failed before entry.
Isolated Runtime correction a4a4645 plus the four-line correction All 26 checks passed in six runs. Each mode ran twice in one session and once in a fresh session.
Integration on newer main This PR at 57ee0b2 (parent 6097aed) All 27 checks passed locally and in six Runtime runs, with repeat and fresh sessions in both modes. These runs include startup from the packaged installation.
Focused mount tests Repair workspace 17 tests passed, including the real inaccessible mount. The reviewed source matches commit 57ee0b2.
Regression proof Isolated copy of the repair Both changed tests failed when the correction was removed and passed after restoration, with no skips.
Repository checks Repair workspace Formatting, repository lint, and the build without default features passed. The complete workspace rerun reported 5,044 passes, one telemetry failure, and 17 ignored tests. Two tests also returned early for unsupported or missing prerequisites. Both initial failures passed targeted retries; the full suite is not claimed as passed.
Hosted checks Current head 57ee0b2 Linux and macOS deterministic containment, lint, packaging, site-manifest, and CodeQL checks passed. Full Linux and macOS test suites are still running. Automated review completed with two nonblocking comments about refusal diagnostics and exact alias assertions; their disposition is pending.

The isolated correction and newer-main integration checks use different source revisions. The isolated Runtime results do not establish final-commit qualification. The newer-main Runtime package contains the exact source change in commit 57ee0b2.

The first workspace run failed in failed_agent_stops_detached_descendants. Its helper read an empty release-code file and panicked, producing exit code 101 instead of 17. The process cleanup assertions passed before that status assertion failed. The exact test passed on retry. An isolated run of the unchanged helper reproduced the empty-file panic; this was not a full baseline product rerun. Two tests that first skipped for a missing helper also passed without skips after the helper was supplied.

The telemetry failure occurred after its fixture captured an empty HTTP header. Its targeted retry passed without skips. An empty local connection reproduced the same assertion in the unchanged fixture. This demonstrates fixture fragility; the original empty connection remains unexplained. The complete workspace result is not claimed as passed. The examples runner found no scripted examples, so its zero exit code does not establish example or SDK tutorial coverage.

  • 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

Formatting and just clippy passed. CONTRIBUTING.md requires the repository's vendored warning allowances, so the strict Clippy command above is not claimed as passed.

The initial draft run skipped containment and left a failed CI Gate. A new run started after review was enabled. Its Linux and macOS deterministic containment checks passed; the full platform tests and final gate remain pending.

Checklist

  • 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

A Linux bind mount can expose an installed Box executable through a directory
that the Box user cannot enter. The installation check aborts on that path's
permission error, so unrelated workloads cannot start. Both managed-code and
customer-container AgentCore Runtime deployments reproduce this failure.

## Solution

Keep a permission-denied candidate in the protected alias list. Existing checks
still reject writable grants and hosted mutations that overlap that path or its
ancestors. Unrelated operations can proceed. Other inspection errors still
refuse the check. An inaccessible candidate can protect an unrelated path
conservatively until Box can inspect its identity.

Extend the real mount regression test and update both installation reference
pages. No public interface or foundational premise changes.

## Tests

- an_unreadable_mapped_alias_is_protected_as_an_alias and
  real_mount_aliases_preserve_link_counts_and_refuse_overlapping_write_grants:
  both failed with the fix removed and passed after restoration, without skips.
- The focused mount suite passed all 17 tests. The real mount case covers
  unrelated writes, agent/tool/MCP ancestor grants, hosted mutation refusals,
  and protection after directory permissions are restored.
- AgentCore Runtime V2: all 27 checks passed in six current-main-plus-fix runs.
  Each deployment mode ran twice in one session and once in a fresh session.
  Tests include packaged launches, ordinary writes, and installation mutation
  refusals. The isolated original-merge comparison passed all 26 checks in
  six runs with the correction; the original merge failed 23 checks per mode.
- Workspace build, formatting, and the repository's workspace clippy recipe
  passed. Box library tests passed 783/783; installation integration passed 8/8.
- Initial just check failed in failed_agent_stops_detached_descendants because
  an unchanged test helper parsed an empty release file. The targeted rerun
  passed; the unchanged baseline helper reproduced the same empty-input panic.
  Two tests skipped for missing helper copies passed after the CI fixture setup.
- Full workspace rerun, no-default-features build, examples, deterministic
  containment checks, and hosted platform checks remain incomplete at commit.
  This commit is prepared for draft review, not merge approval.

Co-authored-by: Ravi Kandury <[email protected]>
@github-actions github-actions Bot added Area - Agent Containment bug Something isn't working labels Nov 6, 2026
@kevin-orellana
kevin-orellana marked this pull request as ready for review November 6, 2026 00:27
@kevin-orellana
kevin-orellana enabled auto-merge (squash) November 6, 2026 00:42
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Assessment: Comment

The fix is narrow and closes the startup failure without weakening write protection. My two comments are about what the operator sees when the new arm causes a refusal, and about the new tests checking too loosely.

Checked and held
  • Assumption: when stat on a candidate returns PermissionDenied, protecting that path and every directory above it is enough. Cases checked:
    • The hidden file-bind case.
    • A grant that names an ancestor of the hidden path through a different path to the same directory. lies_within falls back to comparing directory identity on the ancestors Box can still stat.
    • A direct write_file on the hidden path. The grant can't be resolved, so config refuses it.
    • EPERM from a security module. Rust maps it to PermissionDenied, so the path is protected.
  • Other errors still refuse: ELOOP, ESTALE and ENOTCONN still refuse the inventory, as before.
  • No other consumers: aliases() is used only by validate_reach and refuses_mutation. Neither needs a verified identity for an alias, and refuses_mutation still treats an inventory error as a refusal.
  • Nothing else changes: inputs that were valid before this change behave the same. No frozen surface or premise in AGENTS.md or crates/box/AGENTS.md changes. The new refusal reuses the existing documented text.
  • Tests run here: the 17 focused tests pass on an unprivileged runner. The real-mount test skipped because this host refuses the user namespace (uid_map write denied). So this review does not independently confirm the capability-drop part of the test.

The real-mount test also covers the case where permissions are restored, which is the important follow-through.

@abhisheksp

Copy link
Copy Markdown
Contributor

The verification/testing isn't too clear

What test was missing before and what test fails without this change now?

@kevin-orellana

Copy link
Copy Markdown
Collaborator Author

Regression coverage for 57ee0b2:

  • The old unit test, an_unreadable_mapped_alias_refuses_the_inventory, explicitly expected a permission error to abort discovery. Its replacement, an_unreadable_mapped_alias_is_protected_as_an_alias, requires discovery to succeed while retaining the inaccessible path for protection.
  • The extended real_mount_aliases_preserve_link_counts_and_refuse_overlapping_write_grants test creates an actual mounted executable behind a directory the test process cannot enter. It checks that unrelated write grants remain usable, enclosing write grants and hosted mutations are refused, and direct executable protection remains after access is restored.
  • Removing only the four-line production correction made both changed tests fail with PermissionDenied. Restoring it made both pass, with no skips. The 17 focused tests also passed. Real Runtime validation covers both managed-code and customer-container deployments.

The two nonblocking review refinements are deferred from this startup repair. Follow-up owner: @kevin-orellana.

  • Distinguish an unverified executable candidate in the refusal message and document the useful recovery actions.
  • Tighten both changed tests to compare the complete expected alias lists.

The current correction retains conservative write protection. Missing-path handling remains unchanged. The example revision update is also separate and is not included in this PR.

@kevin-orellana
kevin-orellana merged commit e39544d into main Nov 6, 2026
40 of 45 checks passed
@kevin-orellana
kevin-orellana deleted the feature/runtime-mounted-executable-aliases branch November 6, 2026 01:18
@github-actions github-actions Bot mentioned this pull request Nov 6, 2026
7 of 8 tasks
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