Repository navigation
test: cover mount restrictions in nested user namespaces - #267
Conversation
## Problem Linux can restore capabilities within a nested user namespace after Box clears startup capabilities. Existing coverage does not check the later mount refusals. A source comment incorrectly treats startup capability removal as a permanent mount backstop. ## Solution Add behavioral tests for seven namespace creation and entry routes. Each route compares contained execution with a successful private-namespace control. Check startup capability removal, namespace identity, scoped capability restoration, and continued mount and fsopen refusals. Also check ordinary process and thread creation through the production containment trampoline. Correct the comment and document the capability boundary in the Linux design guide. Runtime behavior, public interfaces, and namespace permissions stay unchanged. The final namespace restriction policy remains undecided. ## Tests - nested_user_namespaces_restore_scoped_capabilities_and_keep_mount_refusals passed all seven routes without skips. Both mount operations succeeded in matching uncontained controls and returned EPERM inside containment. - ordinary_process_and_thread_creation_remain_available passed fork, pthread_create, and posix_spawn controls inside and outside containment. - Three isolated mutation checks failed as expected when mount or fsopen was permitted, or process creation was refused. Both restored tests passed. - bash scripts/test-all.sh passed 4,597 tests and one custom harness. It reported 17 ignored cases and two existing prerequisite omissions: the credential daemon and an alias read-denial assertion. The example build passed, but no scripted examples remain. The SDK tutorial was not executed. - bash test-integ/run.sh reported GREEN: 124 passes, nine macOS-only skips, zero failures, and zero errors. - All-feature builds, formatting, configured workspace Clippy, and the containment build without default features passed. Bare strict Clippy failed on six diagnostics in unchanged strands-shell code. The configured lint gate uses the seven existing justfile allowances; the changed code has no warnings. The build without default features reported 66 unused-code warnings in unchanged files. Validation ran on non-root Amazon Linux 2023 ARM64, kernel 6.12.113. Actual Box runs plain unshare --user. Bubblewrap setup stops at refused capget; root mapping stops at the identity-map write. Matching uncontained controls passed. These observations do not establish complete nested-sandbox support. Native macOS, browser compatibility, and security acceptance remain unverified.
|
Important (non-blocking): This PR fixes the wrong reason for mount refusal in Example: In the "Nothing here refuses or detects root" list, the Suggestion: Change that clause so the seccomp filters are the reason. For example: "Startup clears every capability set, and a nested user namespace restores them inside that namespace. The seccomp filters refuse the mount API ( |
|
Assessment: Comment The tests and the design-guide section are correct for every case I traced. I found one remaining issue: a stale copy of the corrected claim in Checked and held
The uncontained control beside each contained route makes these regression tests trustworthy. |
|
Addressed in 829770e. The crate guidance now separates startup capability removal from privileges restored within a nested user namespace. It attributes the The documentation-only delta passed independent review and This resolves the capability-wording finding. |
|
Assessment: Approve I re-reviewed at Checked and held
|
|
Assessment: Approve (one non-blocking suggestion) I re-reviewed at Suggestion (non-blocking): After the merge, Checked and held
|
Human readable section
Problem. Box removes Linux capabilities before the workload starts. Creating or entering a nested user namespace can grant capabilities again within that namespace. Existing tests check startup removal and permitted calls, but do not exercise the later mount restrictions. A source comment also attributes mount refusals to capability removal and
no_new_privs.Solution. Add behavioral regression tests for seven namespace creation and entry routes. Each route has a successful, uncontained control in a private mount namespace. The contained route must regain scoped capabilities while
mountandfsopenremain refused. A second test checks ordinary process and thread creation. Correct the source comment and the crate agent guidance. Explain the capability boundary in the Linux design guide.Trade-off. This preserves current namespace behavior and its shared-kernel exposure. It does not establish complete nested-sandbox support or security acceptance.
Description
The namespace test covers
unsharewith user-only and user-plus-mount flags, legacyclone,clone3, and threesetnsforms. Those entry forms use an explicit user namespace type, automatic type selection, and a process descriptor with combined user/mount flags.The probe checks all five startup capability sets, namespace identity, restored capability sets,
no_new_privs, and seccomp mode. It observes restoration before another executable runs. Parent deadlines and child alarms bound each probe. Prerequisite failures have explicitskipping:records; a contained refusal after a successful control fails the test.ordinary_process_and_thread_creation_remain_availableexercisesfork,pthread_create, andposix_spawnthrough the production containment trampoline.Independent mutation checks at
a454e8059c30149043a58d11da933512fbe6d86econfirmed that the new tests fail when either mount call is permitted or process creation is refused. The restored source passes again. These temporary changes were confined to a separate review copy.Earlier manual compatibility checks at
a454e8059c30149043a58d11da933512fbe6d86eused the actualstrands-box runlauncher on non-root Amazon Linux 2023 ARM64, kernel 6.12.113, glibc 2.34:unshare --usercapgetis refused before the inner payload starts.unshare --user --map-root-userEPERM.A separate control reproduces the mapping refusal without Box or seccomp by removing only
CAP_SETFCAPfrom a parent namespace with user ID zero. This matches Linux's documented mapping requirement. These results do not measure a browser or Bubblewrap's mount behavior inside Box. They were not repeated after the conflict integration below.Related Issues
None.
Type of Change
Documentation update
Other: Behavioral regression coverage for existing Linux restrictions.
Testing
Conflict integration on November 2
Merge commit
fabc08ba2b080dd0625546c9a9c7618adf268721incorporates mainef009143f5ed960d18c145c4fcc7063da1e9ec93. The conflict resolution keeps both the nested-namespace probes and the memory probes added by #241/#243. The reviewed namespace tests are unchanged. The resolution changes no runtime implementation and passed independent Codex review.Local validation used non-root Amazon Linux 2023 ARM64, kernel 6.12.113, Rust 1.98.1, four build jobs, and four test threads. Linux startup consent was enabled. Formatting, the Box/containment build, and repository-configured workspace Clippy passed. The focused suites passed five tests: two namespace tests with all seven routes and no skips, plus three memory tests. The guide's 15 relative links and
git diff --checkpassed.cargo test --workspace --all-features --locked --no-fail-fast -- --nocaptureexited successfully: 4,617 passed, zero failed, 17 ignored, plus the custom library harness. The raw Linux log audit failed because an installed-alias test omitted its assertions when its helper was absent. After the workflow's helper-install step, that test passed in the existing workspace test binary: one passed, 643 filtered, no skips. Its supplemental log audit passed. This completes one previously omitted test; it adds no unique test to the workspace total. An initial binary-target attempt selected zero tests and provides no assertion evidence.The two other prerequisite omissions and all 17 ignored cases remain as described below. Workspace compilation emitted eight warnings in unchanged shell tests. Bare strict Clippy, local deterministic tests, mutation checks, and manual compatibility probes were not repeated for this merge. The policy performance output still reports the existing issue #150 latency target miss; passing tests do not establish that requirement.
Main subsequently advanced to
db481935ec27d183e8b3aa4a87a518c0f55ece21through #217. A read-only merge check found no conflict. Hosted checks forfabc08ba2b080dd0625546c9a9c7618adf268721passed; the separateVerdictjob was skipped. Automated review approved that head with one non-blocking documentation suggestion. This status refresh confirms the check conclusions. It does not add a new audit of hosted checkout revisions or aggregate test counts.Earlier revision evidence
The following local and hosted results cover the earlier revisions named here. Local validation covers
a454e8059c30149043a58d11da933512fbe6d86e, based one4ca8b80359b2213d684de31cd6ef32e0d61478a. Follow-up829770eddf3bc2bf4fd3d5920ab9e029f5552aefonly corrects the crate agent guidance; Rust and test files are unchanged. That documentation delta passed independent review andgit diff --check.--all-featuresbash scripts/test-all.sh)cargo fmt --all --checkandcargo fmt --allpassed.justfile. No new warnings.-D warningsonly)strands-shellcode.Hosted tests used merge revision
ae284cac0f6c098b914c8491eaa9a4051aed15ee. Its tree matches earlier head829770eddf3bc2bf4fd3d5920ab9e029f5552aef's tree,30be544f60490534c8c769833c469a08343b0f78.Linux's log audit confirms both new tests and only the two existing prerequisite omissions described below. The macOS job hides successful-test output, so its passing status does not prove that every prerequisite-dependent assertion ran. All scheduled checks passed. The separate
Verdictjob was intentionally skipped because its tool sources were unchanged.just check, orcargo test --workspace --all-features)cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsThe earlier strict command ran but did not pass. This conflict update reran the configured gate instead. Its six diagnostics concern argument count, recursion, a borrow across an await, and automatic dereferencing. The configured gate uses these allowances:
The workspace skipped a live credential-daemon test because the daemon was absent. It also omitted the existing alias read-denial assertion; that test's write assertions ran. Its 17 ignored cases comprise six child probe entry points, five known behavior gaps, three long measurements, two live HTTPS fixtures, and one documentation example. Parent tests invoke the child probe entry points. The namespace suite had no skips or ignored cases in those earlier runs.
Checklist
At Kevin's request, Codex reviewed this conflict resolution and recorded its validation. 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.