Skip to content

fix(linux): allow root directory write grants - #348

Merged
kevin-orellana merged 3 commits into
mainfrom
feature/linux-root-directory-grants
Nov 9, 2026
Merged

kevin-orellana merged 3 commits into
mainfrom
feature/linux-root-directory-grants

Conversation

@kevin-orellana

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

Copy link
Copy Markdown
Collaborator

Human readable section

Problem: The Linux nightly launches Box as root with a writable workspace. Box rejects that grant before the agent starts, including after #343 fixes executable-alias discovery.

Solution: Restore explicit directory-write grants for Linux root launches. Keep the existing filesystem restrictions, capability removal, and permission checks. Add a regression that proves root creation works while direct and symbolic-link access outside the grant remains refused.

Trade-off: Permitted output from a root workload can remain root-owned. The same ownership rule applies to file creation through built-in Shell and Python requests, which retain their policy and reachable-path checks. A separate program that consumes that output uses its own authority. Box bounds the sandboxed process's accesses and the operations it performs for the workload.

Root-owned output and filesystem reach. The sandbox enforces its grants. A separate program outside Box later uses its own permissions.

A root workload writes root-owned output through a directory grant. Its sandbox refuses access to an ungranted file. A separate program outside Box can read the output and access the other file only with its own permissions.

Editable diagram · Containment explanation

Description

This deliberately changes Linux startup behavior: a root launch with covering read and write directory grants now starts its workload. Operators who relied on the blanket startup refusal will instead get the configured writable directory. No configuration keys, record formats, or protocol versions change.

The scope follows Box protects the machine, not the box and direct grants.

root_directory_grants_preserve_creation replaces the blanket-refusal assertion. It checks ordinary reads, writes, creation, symbolic links, private temporary storage, cleared capabilities, refused special permission bits, and refused direct/symbolic-link outside access. It also checks that new files retain root ownership. Existing-file and nonroot controls remain.

The root regression failed against the original startup guard and passed with this change. The nightly harness remains unchanged. The separate nonroot harness workaround and macOS capacity fallback are outside this PR.

Codex prepared this PR and ran the reported checks under maintainer direction.

Related Issues

Related: #300, #343. #329 was withdrawn in favor of this proposal; its separate ownership-based refusal was not merged.

Observed in the requested Linux workload run at e39544d.

Type of Change

Bug fix

Testing

Diagram and documentation follow-up (78612af)

Added the editable diagram and PNG, with caption and alt text, to the Linux root-launch explanation. Moved the permitted Shell/Python root-output description out of the open-code-findings list and corrected its cross-reference. The existing policy, reachable-path, and symbolic-link controls remain documented. This does not close any separate security finding.

  • The diagram checker passed with zero errors and warnings; every label was measured and each icon name verified.
  • Exported with the pinned draw.io 32.4.1 container, at scale 2 and border 20. The unchanged security-enforcement.drawio reference rendered successfully; this repository has an SVG reference, so no committed PNG comparison was available.
  • Visually inspected both PNGs. The new figure has readable labels, visible icons, a white background, and no clipping or overlapping connections.
  • Independent documentation review and local link checks passed. git diff --check passed.
  • This follow-up changes documentation and images only. Rust implementation and tests are identical to f0abcb9; no additional local runtime suite was needed. The hosted CI run passed Linux and macOS unit tests, deterministic containment on both platforms, lint, packaging, the site manifest, and CI Gate. The automated review of 78612af accepted the diagram and documentation with no new findings. No unresolved review threads remain; formal maintainer approval is still required.

CI fixture correction (f0abcb9)

The initial Linux CI job failed all four behavioral cases in file_ownership_linux. The outside host file used the default temporary directory. Under /tmp, Box instead exposes writable private storage at the same spelling, so the write created a private file. The host marker stayed unchanged. Local checks had used TMPDIR=/var/tmp, which hid this fixture defect. The automated reviewer identified the same issue.

Commit f0abcb9 changes only the outside fixture to NamedTempFile::new_in("/var/tmp"). Every denial assertion and the host-file integrity check remain.

Validation of that correction on Linux ARM64:

  • Reproduced the four failures on unmodified d36ce29 with TMPDIR=/tmp.
  • The full all-feature containment suite passed with TMPDIR=/tmp: 678 reported passes, zero failures, ignored tests, or runtime skips.
  • All four ownership cases passed with both TMPDIR=/tmp and TMPDIR=/var/tmp.
  • Both root-specific cases also passed as actual host root with TMPDIR=/tmp; the nonroot controls remain covered.
  • Containment build, strict clippy, workspace formatting, and independent review passed with no warnings or blocking findings.

The hosted run for f0abcb9 passed Linux and macOS unit tests, deterministic containment, lint, packaging, the site manifest, and CI Gate. The automated review accepted the correction with no blocking findings. The addressed outdated fixture thread is resolved. Full-workspace, deterministic, macOS, and cloud campaigns were not repeated locally for that one-line test correction.

Initial local validation (d36ce29)

These checks ran on Linux ARM64 at the original PR head, based on 6bd1b2f, with EXPERIMENTAL_LINUX_SUPPORT=TRUE and TMPDIR=/var/tmp. The correction results above cover the changed test fixture.

Check Result
cargo test --workspace --all-features --locked -- --show-output Passed unit, integration, and documentation tests.
cargo fmt --all --check Passed.
Workspace clippy, all targets and features Passed with the seven repository allowances in the justfile; no emitted warnings.
Containment build without default features Passed. Its 68 dead-code diagnostics match clean current main exactly.
Linux x86-64 containment library check Passed after installing the compiler target. This is compile evidence, not runtime support qualification.
bash scripts/test-all.sh box-examples Built the final Box and containment binaries. This tree has no scripted run.sh examples.
Two live-script-mutation library tests Passed without skips after preparing the sibling trampoline binary.
Deterministic suite, test-integ/run.sh GREEN: 131 passed, zero failures or errors, ten macOS-only exclusions; all 141 manifest rows accounted for, no quarantine.
Source, documentation, and behavior review No blocking findings.

Workspace limits: 18 ignored entries include child helpers, manual long-running tests, external HTTPS fixtures, and existing upstream issues. Runtime exclusions were the absent credential daemon, the existing Linux alias-read assertion, and an intentionally removed cardinality probe. The two initially missing-trampoline tests were rerun successfully as reported above. Raw test compilation emitted eight warnings in unchanged vendored shell tests; the owned changes add none. Existing policy performance diagnostics still report the tracked latency target miss; their required assertions passed.

just is unavailable on this host, so validation used the template-supported Cargo commands and the exact repository lint allowances.

  • 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

Prior candidate evidence

The following results used e39544d plus the same Linux implementation. They precede the one-line fixture correction; the regression assertions remain unchanged. Main subsequently merged #327 and #335. The documentation conflict was resolved against current main; the cloud workload was not repeated after that synchronization.

Check Result
Full containment build, tests, strict clippy, and formatting Passed with all features. No runtime skip messages.
Nine separately selected root/nonroot ownership and permission checks All passed. Root checks used actual user ID zero; no runtime skips.
Site manifest tests 27 passed.
Native Box root startup with a writable workspace Workload completed and created a root-owned file.
Original Linux network-egress cloud case on Amazon Linux 2023 ARM64 PASS / CONTAINED across 44 tool calls. Seven targets attempted; four not attemptable. Box ran as root and the agent initialized.

The cloud result is one manual case, not a GitHub Actions candidate run or all Linux workload cases. The frozen source archive SHA-256 was 7748ed79afcbbfa59afff5dbdcf7971baea7ced3fb2fcd5f13b71990be70bad3. Two earlier driver setup failures stopped before Box; the successful retry used the unchanged source and harness. All three temporary instances were verified terminated. Raw cloud reports remain private because they include environment and agent details.

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

The Linux nightly launches Box as root with a writable workspace.
The blanket root directory-write guard stops the agent before it runs.

## Solution

Restore explicit directory-write grants for Linux root launches.
This is the operator-approved startup behavior change requested for this PR.
A root configuration that previously failed now starts with its declared grants.
Permitted files retain the launcher's identity, including root ownership.
Keep capability removal, filesystem restrictions, and special-permission checks.
Update the user guide and containment guidance with this behavior and scope.
No configuration, record, or protocol shape changes.

## Tests

Full workspace unit, integration, and documentation tests passed on Linux ARM64.
Formatting and workspace clippy passed with the seven documented repository allowances.
The no-default-feature containment build passed with the same warnings as current main.
The Linux x86-64 containment library check passed; runtime support was not qualified.
The examples gate built the final binaries; this tree has no scripted examples.
The deterministic suite passed 131 cases, with ten macOS-only exclusions and no failures or errors.
Two live-script-mutation library tests passed after preparing their sibling trampoline.
Existing workspace ignored tests and runtime exclusions remain documented in the PR.
Independent source, documentation, and behavior review found no blocker.

root_directory_grants_preserve_creation fails with the original guard and passes with its removal.
It proves root creation, cleared capabilities, refused special bits, and refused direct and symlink outside access.
Nine actual-root/nonroot ownership and permission checks passed without skips on the prior candidate.
The unchanged root network-egress harness returned PASS/CONTAINED across 44 tool calls on AL2023 ARM64.
That manual cloud run used e39544d plus the same Linux code before upstream #327 and #335.
Seven targets were attempted and four were not attemptable.
No cloud run was repeated after synchronization with current main.
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Assessment: Request Changes

Removing the startup guard works as described. The blocking problem is the new outside-access assertions: in CI's default environment they report the wrong result, so file_ownership_linux fails on ARM64 (see the inline comment). Once the outside fixture is moved off the private /tmp, this looks ready.

Checked and held
  • Special-permission bits stay refused at user ID 0: seccomp's special_file_mode_rules on fchmod, fchmodat, fchmodat2, openat with O_CREAT/O_TMPFILE, and mkdirat does not depend on the launcher's user ID.
  • No owner-change or extra-entry routes: fchownat, setxattr, mknodat, and linkat are absent from the permit table, so a root workload without capabilities cannot change owners, set file capabilities, or create device nodes and hard links.
  • Removed guard has no other users: no code, test, or doc in the repository still refers to require_nonroot_directory_writes or its error text.
  • Doc-update rule for filesystem-list changes (.agents/references/doc-updates.md): docs/user/config.md and docs/design/containment.md are both updated.
  • The replaced refusal test: it is replaced because the guard is removed on purpose, by the owner of the original decision, not to make a suite pass. The root AGENTS.md security-test rule is not broken.
  • Trade-off is stated: root-owned output and later privileged consumers are stated consistently in both AGENTS.md files and in the design doc, and the macOS root-launch support notes stay consistent.

The host-side "outside file unchanged" assertions are a good invariant to keep.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Assessment: Approve

f0abcb9 fixes the only blocking finding. The outside fixture now lives in /var/tmp, which is not visible in the sandbox, so the in-sandbox refusal checks report the correct result. file_ownership_linux passes on ARM64 CI. Nothing else changed since d36ce29.

Re-checked at f0abcb9
  • Outside probe cases: the default TMPDIR, /var/tmp as a symlink to /tmp, and the root launcher all reach a path missing from the view. Each one gives ENOENT, so it reports refused, which is correct. If a host has no /var/tmp, the test fails loudly during setup and gives no false pass.
  • Earlier findings still hold: the special-bit seccomp rules do not depend on the user ID, the permit table has no owner-change, xattr, mknod, or hard-link routes, the removed guard has no remaining users, and both pages the doc-update rule requires are updated.

@kevin-orellana

Copy link
Copy Markdown
Collaborator Author

Consolidating root-output behavior on this PR at the maintainer's request. PR #329 proposed extending #300's startup restriction to built-in Shell and Python creation and renames. It is now closed without merge in favor of the model here.

Under this model, an explicitly granted sandbox write and a policy-approved built-in file operation can both produce root-owned output when Box runs as root. Both paths must enforce their applicable grants, denials, and file-identity checks. Programs that later consume that output use their own authority and must treat the output as untrusted.

No independent policy or reachable-path repair was identified in #329 that needs to be copied here. Its implementation, tests, and review history remain available there. This leaves one active root-output proposal for review and does not claim that the related security assessment is closed.

The remaining documentation cleanup is to state the built-in route consistently with this model and distinguish any separately demonstrated defect from permitted root-owned output.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

Assessment: Approve

78612af changes only documentation. It adds Figure 1 (draw.io source and PNG) to docs/design/containment.md, and it moves the root-ownership note in crates/box/AGENTS.md from "Open findings" to a new "Root-owned output" contract section. No code or tests changed since f0abcb9, which I approved.

Checked at 78612af
  • Diagram and caption match the code: "Capabilities cleared", the write grant into a directory with covering read and write access, and the refused access to a file outside every grant all match the startup sequence and the file_ownership_linux probes.
  • No content lost in the move: the symlink-path controls (source read/write and destination write permission, verify_symlink_target refusing absolute targets and escapes beyond the bind root) and the /etc/shadow statement are kept word for word.
  • Links still resolve: the root AGENTS.md link to #open-findings--divergences-no-decision-covers still resolves, and the containment AGENTS.md now links to the new #root-owned-output anchor.
  • No published page affected: docs/design/ is not in site-manifest.json, and the Site manifest check passes.

@kevin-orellana
kevin-orellana merged commit fbe415c into main Nov 9, 2026
23 checks passed
@kevin-orellana
kevin-orellana deleted the feature/linux-root-directory-grants branch November 9, 2026 18:45
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.

3 participants