Repository navigation
Conversation
The trampoline took the composed environment as --target-env-json <json>. On Linux the launcher that waits outside the PID namespace keeps that argv for the box's life, so /proc/<pid>/cmdline exposed every leaf's declared env. Box now writes it to a private file beside the containment config and passes --target-env-fd <n>; the trampoline reads it before apply and closes it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…g the container's /proc A host that masks /proc refuses every fresh procfs in a user namespace. For AllowAll the view now binds the container's /proc recursively, masks included, and remounts only the top mount nosuid,nodev while keeping any flag the kernel locked. Isolated still mounts a fresh procfs. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… procfs Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…/proc with every leaf Adds a tenth top-level box.toml key, [containment], with one field, private_proc (default true). false maps to ProcessInfoMode::AllowAll for the agent, every tool, and every stdio MCP server, and stores the box at record version 25 so an older build refuses it; every other box keeps the version main gives it. macOS refuses it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…r's /proc Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A masked host also mounts unrelated filesystems under /proc (binfmt_misc), so the mount table alone pointed every Apply failure at private_proc. A leaf's refusal now needs containment's own wording in its detail; the agent's never reaches the box, so the box asks the kernel for a fresh procfs itself. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The cross-leaf test probed the first workload's launcher, which the capability check protects whatever happens to the workload. It now probes the workload, by the PID it reads in the shared /proc. New pins and docs for what the final review measured: an outside process's mountinfo and net tables are readable, a same-uid process's oom_score_adj is writable, and /proc keeps the container's PID numbering so only /proc/self names the workload. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
40a012d to
492d319
Compare
|
Status: this branch now conflicts with
|
## Problem This branch conflicted with main in 14 files. Record version 25, which it used for `[containment] private_proc = false`, now belongs to `file-attributes`. Main also made the private procfs read-only and moved mounts onto pinned targets. ## Solution - `private_proc = false` is stored at record version 39. - The shared `/proc` is established through a pinned mount target, like every other bind, and is remounted read-only. A workload can no longer write a same-uid process's `oom_score_adj`. - The trampoline accepts `--target-env-fd` beside `--target-env-json`. The two are exclusive, and one is required. The box always passes the descriptor, so no environment text is on a command line. The inline flag stays because the containment tests on main use it. - `box.toml` now carries fourteen keys. ## Tests - Masked `/proc`, uid 1000, no capabilities, arm64 container: `shared_proc_linux` 8 passed, `box_shared_proc` 4 passed. `a_shared_proc_workload_reads_mounts_and_sockets_and_cannot_write_an_oom_score` pins the read-only mount. - Privileged arm64 container: `strands-box-containment` passes except `nonroot_directory_grants_preserve_creation` and `a_failed_workload_fork_terminates_the_namespace_reaper`. `strands-box` lib, `box_telemetry`, and `four_inputs` pass except three lib tests. All of these need a non-root account. Clippy is clean. - macOS arm64: `strands-box-containment` passes. `strands-box` passes except `denied_executable` and `shell_dependency_guard`, which fail the same way on main on this host. - Not run: x86-64, and a real Kata pod. Co-Authored-By: Claude Fable 5.2 <[email protected]>
## Problem Seven commits on main conflicted with this branch in ten files. Main assigned record version 39 to `[secret-source]`, and added that key. ## Solution - `private_proc = false` is stored at record version 40. - `box.toml` now carries fifteen keys. - The agent's masked-`/proc` hint is kept inside the shutdown path that main added to `Contained::wait`. ## Tests - Masked `/proc`, uid 1000, no capabilities, arm64 container: `shared_proc_linux` 8 passed, `box_shared_proc` 4 passed. - Privileged arm64 container: clippy is clean. `strands-box-containment` and the `strands-box` lib, `box_telemetry`, and `four_inputs` pass, except five tests that need a non-root account. - macOS arm64: `strands-box-containment` passes. `strands-box` passes except `denied_executable`, `shell_dependency_guard`, and one intermittent `runtime_terminal` test. Each fails the same way on main on this host. - Not run: x86-64, and a real Kata pod. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
I went ahead with the re-port instead of waiting, so the branch is reviewable again. It is merged with What differs from the first version:
Tested on this head: the masked- My question above still stands: is an explicit opt-in that shares the container's |
Description
Interface change, so it needs a maintainer's explicit call: one new
box.tomlkey, a new record version for boxes that use it, and a new telemetry permit. The decision and its residual are recorded indocs/design/decisions.md.box runcannot start in a standard, non-privileged Kata pod, or in any container whose runtime masks parts of/proc. The kernel'smount_too_revealingrefuses a fresh procfs in a user namespace while those masks exist, whatever the mount call or option (mount,fsmount,hidepid,subset=pidwere all measured). Today the only workaround is aprivilegedpod.This change adds an explicit, box-wide opt-in:
With the key, the Linux namespace view binds the container's
/proc(masks included) into each leaf instead of mounting a fresh one. Without the key, nothing changes. On a masked host, the box refuses and names the key.Load-bearing decisions:
root, orcwd. The kernel's capability check (cap_ptrace_access_check) refuses ptrace-class access from a user namespace to any process outside it. That holds atptrace_scope=0and for dumpable targets. It covers the box daemon, the trampoline's launcher (which keeps its capabilities in the workload's user namespace), and other leaves (sibling user namespaces).config.mdanddecisions.md).cmdline,stat,status,mountinfo,limits,cgroup, andnet/*./proc: the shared/procis mounted read-only, as the private one onmainnow is. The earlier version of this PR let the workload raise a same-uid process'soom_score_adj; that residual is closed and a test pins the refusal./prockeeps the container's PID numbering, so only/proc/selfnames the workload.--target-env-fd <fd>, and the box always uses it.--target-env-json <json>stays accepted, because the containment tests onmainuse it; the two are exclusive and one is required. Both are the trampoline's own CLI, not public. The Linux launcher keeps its argv for the box's whole life, so this matters even without the key./procon its own.proc:shared, covering the agent, each tool, and each stdio MCP server./proc./proc(binfmt_misc).Interface changes.
box.tomlgains[containment](ten keys, counting main'sexperimental-features).private_proc = falseis stored at record version 40, so a build that predates the key refuses it. Every other box keeps the version main gives it.proc:sharedpermit.Out of scope:
/procFor maintainers: as an outside contributor, my CI and Auto Strands Review runs wait for approval (
action_required/manual-approval). Could someone approve them? Thanks.Related Issues
Closes #26
Related: #21
Type of Change
New feature
Testing
Re-ported onto
mainat3415baaon 2026-11-19 (head26149c9). Results for that head:/procmasks.shared_proc_linux.rs8 passed,box_shared_proc.rs4 passed.a_shared_proc_workload_reads_mounts_and_sockets_and_cannot_write_an_oom_scorepins the read-only mount.-D warningsis clean forstrands-boxandstrands-box-containment.strands-box-containment, and thestrands-boxlib,box_telemetry, andfour_inputstests pass, except five tests that need a non-root account (nonroot_directory_grants_preserve_creation,a_failed_workload_fork_terminates_the_namespace_reaper, twohardeningtests, andan_unreadable_server_cannot_later_claim_a_grammar_permit).strands-box-containmentpasses.strands-boxpasses exceptdenied_executable,shell_dependency_guard, and one intermittentruntime_terminaltest; each fails the same way on unmodifiedmainon the same host.Results below are from before the re-port.
mainat069c39con 2026-10-19; fork CI on the rebased head: run. The run below is from before the rebase.ubuntu-24.04-arm,macos-latest), both Unit Tests legs, Lint, and Verdict. On the first attempt the macOS Deterministic job failed one harness unit test,test-integegress::tests::a_stream_accepted_during_stop_is_shut_down_and_stop_stays_bounded(a stop-race timing test in a file this PR does not touch); all 129 deterministic cases passed in that attempt too, and the rerun was green.kata-qemuonc6g.metal(guest kernel 6.18.35), in a non-privileged pod running as uid 1000 withCapEff=0and the runtime's/procmasks. The acceptance script passed 7/7:box runsucceeds.strands-box runprocess.environ,mem,fd/0,maps, orroot, andkill -0fails.containment setup failed during containment apply: set [containment] private_proc = false in box.toml ….environ,mem, androot.box runtakes about 805 ms (debug build). The privileged-pod baseline was 775 ms (release build)./procmasks.shared_proc_linux.rs, 8 tests, covering:cmdline,mountinfo,net/tcp,oom_score_adj, and PID numberingbox_shared_proc.rs, 4 tests: end to end with the key, the refusal naming the key, no reach to the box process, and no declared env value on any process'scmdline.strands-box-containmentall pass.strands-box: every failure also fails, identically, onmain(83075df) in the same environment:hardeningtests (root container)box_shell::a_signalled_host_binary_records_128_plus_the_signal_in_historybox_direct_filesystem::this_boxs_authority_survives_a_rename_of_its_parent(EBUSY)runtime_mcp_start,runtime_mcp_policy_staging, andnative_egress_mcp(the fixture'slistgrant has no Linux lowering)cargo test -p strands-box-containment -p strands-box --all-features, 0 failures.cargo fmt --check, andcargo clippy --workspace --all-targets --all-features -- -D warningswith CI's allow-list, are clean.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
🤖 Generated with Claude Code