Skip to content

fix(containment): keep Linux metadata-only parents empty and read-only - #157

Merged
kevin-orellana merged 4 commits into
mainfrom
feature/linux-readonly-denial-parent
Oct 27, 2026
Merged

kevin-orellana merged 4 commits into
mainfrom
feature/linux-readonly-denial-parent

Conversation

@kevin-orellana

@kevin-orellana kevin-orellana commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Human readable section

Problem: Denying a private child path could accidentally let a process create files in a parent directory where it had no write permission.

Solution: Keep the metadata-only parent empty and read-only. Metadata-only access lets the process inspect and enter that directory, without exposing child names or contents.

Example: The host has /tmp/project/box/private/record. The operator grants metadata-only access to /tmp/project and denies access to /tmp/project/box/private.

Before this fix, adding that denial let the process create /tmp/project/new.txt inside Box's private filesystem. The host's files stayed unchanged.

After this fix:

# Process operation Result
1 Inspect or enter /tmp/project. Allowed.
2 List the children of /tmp/project. The directory appears empty. No child names are exposed.
3 Create /tmp/project/new.txt. Rejected: the filesystem is read-only.
4 Read /tmp/project/box/private/record. Rejected: child paths remain hidden.

The executed Linux regression test checks these operations and confirms that host files remain unchanged. This example uses simplified paths.

Trade-off: Hidden children appear absent, including denied files. Explicit child grants retain their existing precedence.

Description

This fixes the regression introduced by #145 without exposing denied path names. The planner no longer treats a refusal as an authorized descendant that displaces a metadata-only mount.

After planning all refusals and write protections, it removes only descendant overlays already hidden by a final empty grant. Their redundant parent protections are also omitted. Denials and protections outside that empty grant remain. Fresh filesystems mount read-only immediately; no placeholder creation loop or temporary writable phase is needed.

Related Issues

Follow-up to #145.

Type of Change

Bug fix

Testing

Test repair validation

Updated to e061220. The main merge includes the explicit Cargo-home read grant from #151. The compiler fixture also declares its linker plugin and /usr/lib64 where present, matching #160. Its private-file, malicious-library, and hard-link refusal assertions remain unchanged.

The catalog timing check now runs in its own test binary. Its measured operation, assertions, timeouts, and ratio limit of 3 remain unchanged. This removes concurrent policy-staging workloads from that binary. Their interference is a suspected cause of the historical timing failure, not a proved root cause.

Check Result
Previously failing Linux Cargo case Passed, including all access-refusal assertions.
Full Linux containment suite Passed after the compiler fixture correction, without runtime prerequisite skips.
Policy-staging tests All 24 passed on Linux and native macOS.
Isolated catalog timing Repeated Linux passes near a ratio of 1.93-1.97. Native macOS passed at 1.91.
Timing guard control A temporary quadratic delay inside the measured section failed the unchanged ratio assertion at 3.36. The restored test passed at 1.93. No injected delay remains.
Formatting and lint Passed. Box test lint used repository allowances; containment lint used the documented chunks_exact_to_as_chunks allowance.
Independent review No actionable findings. No production interface or security premise changed.

Hosted checks are queued for this revision. These affected-suite results do not claim a full local workspace run. Earlier evidence below retains its original revision and scope.

Original local evidence covers 6b202a6, based on 7cf6bad.

Check Result
Original write regression The strengthened real Linux test failed when the original implementation allowed a sibling write.
Name-disclosure regression The final test failed on reviewed head 0202a4a because a metadata-only directory exposed names. It passes after this correction.
Linux containment unit tests 334 passed, zero skipped or ignored.
Linux containment integration tests 107 passed, zero skipped or ignored. All test targets built with --all-features.
Formatting and Linux clippy Passed; containment lint covers all targets and features with the repository's documented allowances.
Local final review No actionable findings.

a_refusal_beneath_a_metadata_only_directory_establishes checks empty enumeration, metadata access, directory entry, denied writes, absent children, and usable unrelated /tmp storage. It runs both without and with a broader outer read-write grant. Single and repeated file denials overlap write protections. Outside denial/protection controls remain effective, and surrounding files retain their original bytes.

Linux tests used ARM64 LinuxKit 7.0.12-linuxkit, Rust 1.98.1, UID 65534, and no container capabilities. The disposable Docker runner permitted namespace-related syscalls and unmasked system paths. These tests do not qualify Runtime or Lambda MicroVM deployments.

Baseline exceptions: Local macOS workspace tests hit two box_project startup timeouts. The local deterministic harness hit a_stream_accepted_during_stop_is_shut_down_and_stop_stays_bounded. All three failures reproduced on unchanged 7cf6bad. The hosted Linux Cargo workflow test, CN-W-06, also fails before namespace setup because its fixture grants writes to cargo-home without reads: base failure, current PR-head failure.

Draft status: Earlier head 0202a4a passed hosted Linux/macOS unit tests, lint, native macOS build/tests, macOS deterministic tests, and code scanning. The automated re-review of 6b202a6 recommends approval and confirms both original concerns are resolved. This is a bot recommendation, not a formal approving GitHub review. Remaining hosted checks are running.

  • I ran the relevant suites (just check, or cargo test --workspace --all-features)
    • Attempted on the earlier head; the local baseline failures above prevented a full-suite pass. Current local reruns cover the affected Linux crate.
  • If I touched Rust, I ran cargo fmt --all and cargo clippy --workspace --all-targets --all-features -- -D warnings
    • Formatting passed. Clippy uses the repository's documented allowances; this is not an unqualified strict run.

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
    • Not applicable: this restores the existing grant contract and adds no configuration or public API.
  • 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 refusal beneath a metadata-only directory removes that directory's read-only
mount. Under the private /tmp filesystem, the workload can then create sibling
files without a write grant.

## Solution

Keep the metadata-only mount. Prepare each refused descendant's mountpoint once
inside its fresh filesystem, then remount the parent read-only before continuing.
Keep the existing refusal mounts and authorized-descendant behavior.

## Tests

The regression a_refusal_beneath_a_metadata_only_directory_establishes failed
with the original implementation when a sibling write succeeded. It now checks
both parent levels, refused trees and files, repeated file refusals with write
protection, writable /tmp scratch, and unchanged surrounding files.
A separate red run caught duplicate preparation before target deduplication.
The planner test a_refusal_keeps_its_metadata_only_ancestor_read_only passes.

Final Linux ARM64 results: 334 containment unit tests and 107 integration tests
passed without skips. All test targets built with all features. Linux clippy
passed with the repository's documented allowances. cargo fmt --all passed.

macOS just check passed formatting and workspace clippy, then failed two
box_project startup waits. The full workspace suite did not finish. Additional
macOS deterministic checks and hosted review remain pending. No cloud target
or release qualification is claimed.
@kevin-orellana kevin-orellana self-assigned this Oct 23, 2026
@kevin-orellana kevin-orellana changed the title Preserve read-only Linux parents when denying descendants fix(containment): preserve read-only Linux parents when denying descendants Oct 23, 2026
@github-actions

Copy link
Copy Markdown

Assessment: Comment (approve-leaning)

Well-scoped, well-reasoned fix for the #145 regression. The planner correctly stops treating a refused descendant as a reason to drop the metadata-only parent, and the setup phase prepares refusal mountpoints inside the still-writable parent before remounting it read-only. Mount ordering (shallow-first), the "covered refusal" skip, and the duplicate-denial dedup all line up so the approach holds together, and the strengthened real-Linux test exercises the key paths (parent levels, file/dir/duplicate denials, usable /tmp scratch, unchanged surrounding files).

Review notes
  • Disclosure contract (worth confirming): the metadata-only parent fresh fs is now non-empty — it carries the refused-descendant skeleton, which the workload can enumerate. This relaxes the "empty fs is stricter" rationale for metadata-dir mounts. Likely an acceptable/necessary trade-off, but please confirm against the design decisions and consider a test pinning parent enumeration. (inline)
  • Readability (minor): the refused_descendants filter folds loop-invariant entry checks into the per-candidate closure. (inline)

Nice job pinning each behavioral claim with a named test and reproducing the duplicate-denial EEXIST case before fixing it.

@kevin-orellana kevin-orellana changed the title fix(containment): preserve read-only Linux parents when denying descendants fix(containment): keep Linux metadata-only parents empty and read-only Oct 23, 2026
@github-actions

Copy link
Copy Markdown

Assessment: Approve

Re-reviewed at 6b202a6. Both earlier threads are resolved by a redesign rather than a patch, and it's a clear improvement over 0202a4a.

What changed and why it's better
  • The temporary-writable phase, the placeholder-skeleton preparation loop, and the refused_descendants filter are all gone; the fresh-mount path is back to its simple MS_RDONLY-when-not-writable form. (Confirmed no dead code; remount_protected is still used only by the EmptyFile/Protection paths.)
  • The fix is now localized to the planner (view.rs:426-450): compute empty_roots (non-writable Fresh tmpfs grants) and drop any Refusal/Protection entry strictly beneath one, plus prune protected_parents.
  • Net effect resolves both concerns at once: the metadata-only parent stays empty and read-only, so siblings can't be written (fix(box): refuse the box's private tree in the kernel #145 regression) and descendant names can't be enumerated (the disclosure point). Denied descendants now return ENOENT, which is strictly stronger.

Correctness holds: a parent with an authorized descendant is never a fresh empty root (the planner skips it), so no authorized content is dropped; refusals/protections under an empty read-only parent are genuinely redundant; and starts_with is component-wise so there are no sibling-prefix false matches.

Testing is thorough: the regression test is parameterized over outer_read_write ∈ {false, true} with precise exit-code diagnostics, and the added outside controls (outside_refused / outside_protected) prove the new pruning does not over-drop refusals/protections that live outside the empty parent.

Nice turnaround — correcting the implementation to keep Operation::Metadata from leaking directory entry names is the right call over accepting the disclosure.

@kevin-orellana
kevin-orellana marked this pull request as ready for review October 23, 2026 07:58
@kevin-orellana kevin-orellana added the linux Linux containment and Linux launch work label Oct 23, 2026
@github-actions

Copy link
Copy Markdown

Assessment: Approve

Re-reviewed at e061220. The containment product code (view.rs) and its unit test (mod.rs) are unchanged from the already-approved 6b202a6; this push adds only test-infrastructure changes, which are sound.

What changed since the last review
  • Catalog timing isolated into a new binary (runtime_mcp_catalog_scaling.rs), removed from runtime_mcp_policy_staging.rs — a clean move that keeps the timing-sensitive NFR-09 ratio test away from concurrent policy-staging workloads. The <= 3.0 ratio with an EPSILON divide guard and the launcher-usability skip are all reasonable.
  • Compiler prerequisites declared in loader_dependencies_linux.rs — granting /usr/lib64 when present and the GCC LTO plugin — improves portability across distros/toolchains.

Two minor, non-blocking test-quality notes inline:

  • The LTO-plugin skip uses return inside the #[test] fn, skipping the whole test instead of just the missing grant (continue would preserve coverage).
  • Shared helpers/constants are now duplicated across the two test binaries rather than living in support/.

Good instinct isolating the timing test into its own binary.

@kevin-orellana
kevin-orellana enabled auto-merge (squash) October 27, 2026 06:10
@kevin-orellana
kevin-orellana merged commit f79b56d into main Oct 27, 2026
20 checks passed
@kevin-orellana
kevin-orellana deleted the feature/linux-readonly-denial-parent branch October 27, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linux Linux containment and Linux launch work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants