Repository navigation
fix(containment): refuse Linux root sandbox directory writes - #300
Merged
Merged
Conversation
## Problem A Linux root launch lets a workload create root-owned files and symbolic links inside granted host directories. A later privileged host program can trust that ownership and write outside the workload grant or disclose data through a precreated file. Removing capabilities does not change new-file ownership. ## Solution Refuse directory write grants when either the real or effective launcher user ID is zero. Check every composed authorization during validation and again before namespace entry. Keep root reads, explicitly granted existing-file writes, private temporary storage, and non-root directory writes available. This deliberately narrows supported Linux root configurations. Kevin selected this behavior on November 4, 2026, after compatibility testing and directed its completion. Rootless containers that present user ID zero also meet the restriction. The check does not resolve arbitrary ancestor identity mappings. The configuration and design pages explain the migration to non-root launches. PR199 permission restrictions and inherited directory groups remain unchanged. ## Tests On Amazon Linux 2023 ARM64, the containment suite passed 669 top-level test outcomes. The workspace suite passed, including all features. The deterministic suite passed all 131 Linux cases from 140 declared cases, with nine macOS-only exclusions. Build, formatting, strict containment Clippy, and repository workspace Clippy passed. Bare strict workspace Clippy failed only on six unchanged vendored shell diagnostics covered by the documented allowances. root_directory_grants_are_refused_before_workload_execution failed without the guard and passed with it. Actual host-root comparison fixtures reproduced the symbolic-link write and regular-file disclosure on the baseline, prevented both with the candidate, and reproduced both after restoring the baseline. root_file_grants_preserve_private_access_and_temporary_storage and file_grants_preserve_private_access_and_refuse_new_host_entries preserved private existing-file access, private /tmp creation, ordinary modes, and special-mode refusal. nonroot_directory_grants_preserve_creation preserved non-root directory writes and symbolic-link creation. The real credential-daemon test and the existing Linux alias-read assertion remain unavailable. No scripted examples remain in this source tree, and the live SDK tutorial did not run. macOS checks remain for hosted CI. Separate real/effective-ID predicates and the apply recheck were not individually mutated. RoboSec has not revalidated this candidate.
|
Assessment: Comment The Linux sandbox guard does what it says for Checked and held
The test design (production trampoline, a non-root control, and a refusal test that leaves no side effects) is solid. |
kevin-orellana
enabled auto-merge (squash)
November 4, 2026 09:15
|
Assessment: Approve Re-reviewed at Checked and held
|
ferdingler
approved these changes
Nov 4, 2026
8 tasks done
This was referenced Nov 5, 2026
8 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human readable section
Problem: When root starts Box on Linux, a workload can create root-owned files in granted host directories. A separate privileged program can later trust those files and access data outside the workload grant.
Solution: Refuse sandbox directory write grants before a root workload starts. Root can still read granted directories, write explicitly granted existing files, and use private temporary storage.
Trade-off: Linux sandbox workloads that create files in host directories must run Box as a non-root account. This also applies to containers that present the launcher as user ID zero.
Remaining gap: Policy-approved Shell and Python file creation runs in the trusted process and retains its file identity. This PR does not change that route. The broader ownership finding must remain open until that route receives a disposition. macOS root creation also remains unchanged and unmeasured here.
Description
The Linux backend checks the launcher's real and effective user IDs against every composed directory write grant. It checks during validation and again before namespace entry. Agent, tool, and local-server workloads use this check.
This is an approved narrowing of Linux root behavior, selected on November 4 after testing the compatibility effects. The user configuration and containment design pages describe the restriction. The check uses the current user namespace. It does not resolve arbitrary mappings into ancestor namespaces.
PR #199's permission-bit restrictions and inherited directory-group behavior stay unchanged. Removing capabilities already occurs at startup, but does not change the identity that owns newly created files.
Related Issues
Follow-up to #199 for ownership assigned during file creation.
Type of Change
Breaking change
Testing
Tested the candidate on Amazon Linux 2023 ARM64, kernel
6.12.113-138.209.amzn2023.aarch64, withEXPERIMENTAL_LINUX_SUPPORT=TRUE. Runtime validation coversc479e216208471ca0f1cdb52344dd2525ef7e87b, based on1d5cb050d2072727a0dd53e2f11db4854b251615. Follow-upf089f4a6f03461fc8b18676ffd1863db966f33d3changes documentation only. Its runtime and test files are identical, and all 27 site-manifest tests passed again.scripts/test-all.shjust clippyandCONTRIBUTING.md. Bare strict Clippy reports six errors in unchanged vendoredcrates/shellcode.Hosted evidence: CI run, ownership test job, and CodeQL run. Linux deterministic results were 131 passes from 140 declared cases, with nine macOS-only exclusions. macOS results were 128 passes from 140 declared cases, with 12 Linux-only exclusions. Both had zero failures or errors. The hosted root cases use namespace user ID zero; the separate campaign below supplies actual-host-root evidence.
The new startup-refusal test fails without the guard and passes with it. A separate comparison used actual root and inert host-consumer fixtures. The baseline reproduced an outside-grant symbolic-link write and disclosure through a precreated regular file. The candidate prevented both, and restoring the baseline reproduced both again. Equivalent non-root controls kept file creation available.
Production-trampoline tests also preserve root existing-file reads and writes, private
/tmpfiles and links, ordinary permission changes, and special-permission refusal. The test file has four behavioral tests and one subprocess helper. The helper's top-level return is not extra behavioral coverage.Validation limits:
The deterministic verdict records its commit as
unknown. Separate source and executable hash manifests bind that run to this candidate. The staged patch SHA-256 is9b79c5006b3e9a8f567ba693be68caa70c952d3ded4cefaa857be222c3ce12d6.just check, orcargo test --workspace --all-features)cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsThe strict workspace command ran and failed on the documented vendored diagnostics above. The repository-prescribed lint command passed.
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.