Repository navigation
fix(containment): preserve Linux grant identity through mounting - #160
Conversation
## Problem Linux grant validation could approve an object and later mount a replacement at the same pathname. The swapped_files_directories_and_sockets_refuse_before_startup regression reproduces this gap on the base. ## Solution Retain each validated object with an open descriptor and its device, inode, and type. Check an opened mount source against that identity, bind through its descriptor, and verify the mounted target before startup. Release retained descriptors before inherited-descriptor cleanup. Keep public configuration and wire formats unchanged. Correct Linux fixtures so private-state and permitted-access assertions reach their intended operations. Bound the copied-executable host control retry to the existing transient ETXTBSY case. ## Tests On Linux ARM64, bash scripts/test-all.sh passed the full workspace, including all 503 containment tests. concurrent_source_swaps_never_expose_replacement_bytes completed 12,000 attempts without replacement reads or unknown outcomes. read_only_and_writable_grants_keep_their_access_modes and unchanged_symlinks_and_hardlinks_preserve_permitted_reads passed. a_grant_mount_that_does_not_install_the_checked_object_is_refused detects a missing mounted-target check. The deterministic suite passed 120 cases with nine macOS-only skips. just fmt-check, just clippy, and strict all-feature containment clippy passed. Linux x86-64 and native macOS containment compile checks passed; runtime qualification on those targets was not run. Deliberate fault controls failed as expected. The copied-executable control passed 20 repetitions and still failed with a persistent writer. The workspace retains inherited ignored/optional cases, a base-reproduced telemetry teardown panic, and an existing debug latency target miss. The no-default-features build passed with existing dead-code warnings. The SDK tutorial and managed-runtime qualification were not run. Independent adversarial review verified the final source hashes and test receipts. Human acceptance and hosted checks remain pending.
|
Assessment: Comment (approve-leaning) This fix closes a real TOCTOU on the Linux grant path and does so fail-closed. I traced the full flow and the core mechanism is sound: the Review notes
Nicely scoped change with thorough adversarial tests, including the 3,000-iteration race control. |
|
Assessment: Comment (approve-leaning) — re-review of Re-reviewed after the rebase onto What changed since the last review
One new non-blocking suggestion inline: the Solid revision — the fork isolation is exactly right and the loader-pin reconciliation is handled cleanly. |
|
Addressed the optional compiler-plugin suggestion in 6ac4917. The test now recognizes the compiler's bare Linux validation covered the normal installed-plugin build and refusal controls, the absent-plugin response, a missing required helper, empty plugin output, and a failed query. Only the optional absence skipped; the three failure controls still failed. All 519 containment tests, formatting, and strict containment lint passed. Independent adversarial review verified the source hash and receipts. |
|
Assessment: Approve — re-review of The one open suggestion from the previous pass is resolved. Combined with the earlier-verified fixes (fork isolation via |
|
Assessment: Approve — re-review of merge This head commit is a merge of The conflict resolution is correct: it drops the branch-side inline My earlier finding (the |
|
I think we should also be explicit that this check doesnt carry over to MacOS.
|
Human readable section
Problem: Linux could validate a filesystem grant, then mount a different object placed at the same path before startup.
Example: You grant read access to
/work/report.txt, and Box validates that file.Before Box makes it available to the workload, another host process renames it and puts a different file at
/work/report.txt.Previously, the workload could read that replacement even though Box had validated the original file.
With this fix, Box either uses the original file it already opened or refuses startup when it detects the replacement.
When the original file stays in place, the workload can still read it.
Solution: Retain the validated object, mount through a checked open descriptor, and verify the mounted object before starting the workload.
Refuse startup when the object identity changes.
Trade-off: Prepared paths retain descriptors until release or drop.
A directory grant still permits changes inside that directory.
Configuration serialization remains unchanged; the receiving process captures identity when it prepares paths.
Description
Preserve explicit filesystem and socket grant identity through Linux mount completion.
Retaining the original object prevents inode reuse from defeating the comparison.
Opening the mount source inside the new namespace preserves existing namespace permissions.
The mounted-target check verifies that the bind installed the checked object.
Keep protection checks and descriptor cleanup ordering.
Correct Linux test fixtures so private-state assertions reach workload operations under existing grant rules.
Retry only the transient text-file-busy error in the uncontained copied-executable control, with a two-second deadline.
Equivalent fixed-size parsing loops clear owned lint warnings.
No public configuration or wire format changes.
Related Issues
No public issue is linked.
Type of Change
Bug fix
Testing
Conflict repair validation
Updated to
1d3d158by merging currentmain. The conflicting configuration fixtures use main's existing Linux read-grant helper. Their private-state refusal assertions remain unchanged.The full all-feature containment suite passed on Linux without runtime prerequisite skips. All 24 configuration tests, formatting, and strict all-target/all-feature containment lint passed. Independent review checked the combined grant-identity and dependency-admission changes and found no actionable issues.
Hosted checks are queued for this revision. The human ownership attestation remains unchanged. The earlier results below retain their original revision and scope.
Previous follow-up
6ac4917handles the compiler's bare-name response when its optional linker plugin is absent.That case reports an explicit prerequisite skip; required helpers, malformed responses, and failed compiler queries still fail.
On Linux, the normal compiler control, four injected-response controls, all 519 containment tests, formatting, and strict containment lint passed.
Independent review verified the changed file and test receipts. Hosted checks are rerunning for this commit.
The integration results below cover the preceding revision
060a1bf, whose required hosted checks also passed.The integration revision incorporates
mainatf0dc6f49ea8bb8608502afffa50c8748f6c24ca2.Its ten changed source files match the integration review and test manifest.
Runtime validation used an unprivileged ARM64 Amazon Linux development host, kernel 6.12.111, Rust 1.98.1, and native temporary filesystems.
Effective capabilities were zero before namespace setup.
just checkThe host prerequisite probe does not call production namespace setup, so a production regression cannot turn itself into a prerequisite skip.
The compiler fixture grants its discovered linker plugin and the standard
/usr/lib64library directory where present.Its private-file and malicious-dependency refusal assertions remain unchanged.
One intermediate workspace run failed an existing execute-permission test without reporting the underlying error.
That test now runs in isolation and reports actual kernel errors; the historical cause is not established.
The original patch also passed the deterministic suite with 120 cases and nine macOS-only skips.
That pre-integration result is historical; the standalone deterministic suite, examples script, minimal-feature build, and Linux x86-64 compile check were not repeated locally for this follow-up.
The workspace retains inherited ignored tests and optional/platform exclusions.
Local tests and compile checks do not establish managed-runtime or release acceptance.
just check, orcargo test --workspace --all-features)cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsFormatting used
cargo fmt --allandjust fmt-check.The exact second attestation remains unchecked because workspace lint used the required repository
just clippyrecipe and its documented allowances.Strict Clippy also passed for the containment package.
Checklist
This pull request was prepared with AI assistance. The human contributor must review and adopt the description and ownership attestation.
Code comments document the internal identity and descriptor rules; no user-facing configuration documentation changes are needed.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.