Repository navigation
fix(linux): protect denial ancestors while preserving permitted renames - #266
Conversation
## Problem Native ancestor renames can move a denial mask away from an operator's configured path. The workload can recreate that path and write host content there. The denied-files and denied-directories cases in box_denial_ancestors reproduce this failure when ancestor protection is removed. Visible ancestor mounts stop those replacements but break permitted cross-parent moves. ## Solution Collect the intermediate ancestors of file and directory refusals beneath writable grants. Establish the writable grant, bind those ancestors onto themselves, then cover them with the original grant. Hidden mounts keep the ancestors fixed inside the workload mount namespace while ordinary child paths share the visible grant. Keep nested-grant ordering and reuse existing source-pinning and mounted-identity checks for both grant binds. No public interface, dependency, or syscall rule changes. Qualify the native scope in the Linux design and the separate trusted Shell residual. ## Tests box_denial_ancestors::denied_files_survive_each_native_ancestor_rename and denied_directories_survive_each_native_ancestor_rename refuse all 24 native replacements. They check denied-path writes, hidden original bytes, and final host content. unrelated_native_renames_across_denial_ancestors_remain_permitted passes all 24 cross-parent controls with host checks. renameat2_variants_remain_refused_for_denied_ancestors preserves 18 existing filter refusals. The file_refusal_parent_moves_preserve_permitted_children and directory_refusal_parent_moves_preserve_permitted_children tests cover permitted moves, hard links, and nested read-only grants. The file_refusal_ancestors_remain_protected_above_metadata_only_grants and directory_refusal_ancestors_remain_protected_above_metadata_only_grants tests cover metadata-only children. The existing box_protected_state suite passes all four authority-protection tests. Full containment passes 551 tests; the focused product selection passes 32 tests. The full workspace run passes 4,603 reported tests and the custom library harness, with zero failures. It reports 17 ignored entries and two expected prerequisite gaps: alias-read assertions and the real credential daemon. The Linux skip checker accepts both gaps. Empty targets and a nested child summary are excluded from the count. Formatting and workspace Clippy pass with the repository's vendored lint allowances. Removing refusal-ancestor collection reopens all 24 native denied-path writes and fails both metadata tests. The visible-pin candidate fails the unrelated-renames test. New move/link assertions were not each independently mutated. An initial product run lacked the launcher; the complete 32-test rerun passed after an explicit launcher build. Measured on non-root ARM64 Amazon Linux 2023, kernel 6.12.113, Rust 1.98.1. Other kernels, architectures, startup races, arbitrary aliases, trusted broker moves, privileged host mutation, and combined repairs remain unqualified. Newer empty-mount-namespace behavior remains a source-derived qualification risk, not a reproduced bypass. The repair's startup performance, cloud deployments, and release readiness remain unqualified.
|
Assessment: Comment (I found no blocking issues) I reviewed head Assumptions and rules checked that held
Pre-existing and outside this diff: The covered-mount approach is a clean way to get both properties without changing any interface. |
## Problem The native ancestor regression accepted cross-mount errors from the rejected visible-pin design. Two existing documentation passages still described successful Linux authority-ancestor moves. ## Solution Require EBUSY for native ancestor renames in both product and metadata-grant tests. Preserve EPERM expectations for the existing renameat2 filter. Describe the native refusal on both platforms and retain the separate Linux broker limitation. ## Tests Rerun the two metadata-grant tests and all four production denial-ancestor tests with all features. Check formatting and affected Clippy targets. The production implementation is unchanged from the full workspace run at 796cb45.
|
Assessment: Approve (no new findings) I re-reviewed head What I checked on this commit
Everything that held at |
Human readable section
Problem. Through native filesystem calls, a Linux workload can rename an ancestor, then recreate and write an explicitly denied path.
For example, a write grant on
/workand a deny on/work/project/privatemust survive an attempted rename of/work/project.The denial mask moves with the original ancestor instead of protecting the configured location.
Solution. Keep each intermediate ancestor fixed inside the workload mount namespace while preserving ordinary moves within the writable grant.
Both denied files and denied directories use the same protection.
Trade-off. Each affected writable grant needs extra startup mounts.
The tested repair preserves unrelated moves; existing boundaries between separate grants or filesystems still apply.
Description
For each affected writable directory, establish its original grant, bind the protected ancestors onto themselves, then establish the original grant again.
The final bind covers the ancestor mounts without detaching them.
Linux retains their directory-entry protection, while permitted child paths share one visible mount.
Nested grants and denial masks retain their ordering.
Both grant binds reuse the existing source-pinning and mounted-identity checks.
This follows the covered ancestor mounts in Anthropic sandbox-runtime.
A visible-mount candidate stopped the forbidden moves but broke permitted cross-parent renames.
The covered-mount implementation passes both checks.
The production tests drive the built Box launcher with a native filesystem probe.
They check the workload result and independently verify the surrounding filesystem.
No configuration key, public API, dependency, or syscall rule changes.
Related Issues
Adjacent mount-view repairs: #254 and #261. Combined validation with those changes and #241 remains pending.
Type of Change
Bug fix
Testing
Local platform: Amazon Linux 2023 ARM64, Linux 6.12.113, Rust 1.98.1, non-root user.
The full workspace run used
EXPERIMENTAL_LINUX_SUPPORT=TRUE, all features, and the required launcher and alias binaries.The full workspace and earlier suite results below cover
796cb45.Follow-up
b57236cchanges only test assertions and documentation; its six affected tests, formatting, and affected Clippy targets also pass.renameat2filter controlsThe workspace count includes 13 documentation tests. It excludes 25 empty targets and one nested child summary.
The custom
box_libraryharness runs assertions without a standard Rust test summary; Cargo completed it successfully.The 17 ignored entries include child-process helpers, stress tests, live HTTPS fixtures, existing append and policy-macro defects, alias-read protection, and one documentation example.
The Linux skip checker accepted exactly two reported gaps: alias-read assertions and the unavailable real credential daemon.
The four new denial-ancestor tests executed without skips.
The native cases cover three ancestor levels and absolute or directory-relative
renameatcalls.Two destination layouts coincide for the outermost ancestor; the count describes executed cases, not unique paths.
denied_files_survive_each_native_ancestor_renameanddenied_directories_survive_each_native_ancestor_renamecheck both denial types.unrelated_native_renames_across_denial_ancestors_remain_permittedchecks the compatibility requirement.Containment tests also cover nested read-only and metadata-only grants and existing authority-file protection.
An initial product run lacked the launcher binary. After building it explicitly, the entire 32-test selection passed.
That first attempt is excluded from the acceptance results.
Limits: local measurements cover one ARM64 kernel. Other kernels and architectures, startup races, arbitrary aliases, trusted broker moves, and privileged host mutation remain unqualified.
Newer kernels that can create a mount namespace without child mounts need separate qualification of the mount-lifetime assumption.
The repair's startup performance, cloud deployments, and release readiness remain unqualified.
The automated review of
796cb45found no blocking issues.Follow-up
b57236caddresses its error-code assertion suggestion: all native ancestor cases now requireEBUSY, whilerenameat2retains its separateEPERMexpectation.The rerun again measured 24/24 native refusals, zero denied-path writes, 24/24 permitted moves, and 18/18 filter controls.
The two metadata-grant cases also passed. Neither suite reported a prerequisite skip.
The current-head hosted suite passes, including Linux and macOS workspace and containment tests, lint, native macOS checks, and the required CI gate.
The completed automated re-review of
b57236creports no new findings. The earlier inline thread is resolved.This automated assessment is not a formal human approval. The delegated ownership review is recorded below.
Two existing documentation passages now match the native authority-ancestor refusal and distinguish the Linux broker limitation.
just check, orcargo test --workspace --all-features)cargo fmt --alland workspace Clippy with-D warningsand the currentjust clippyvendored allowancesChecklist
AI assistance: Codex implemented and tested this change and performed an independent code review.
At Kevin's request, Codex reviewed the complete current diff at
b57236cand completed the ownership checklist on his behalf.The checked item records that delegated agent review. Formal human maintainer approval remains required.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.