Skip to content

Support an opt-in agent backend for masked-proc containers - #182

Closed
Kimiyu-186 wants to merge 2 commits into
strands-agents:mainfrom
Kimiyu-186:codex/container-backend-review
Closed

Kimiyu-186 wants to merge 2 commits into
strands-agents:mainfrom
Kimiyu-186:codex/container-backend-review

Conversation

@Kimiyu-186

@Kimiyu-186 Kimiyu-186 commented Oct 27, 2026 •

Copy link
Copy Markdown

Description

Box's default Linux backend creates a nested PID namespace and mounts a fresh /proc. That mount fails inside a container whose runtime masks /proc. An outer seccomp allowance alone does not remove this kernel constraint.

This draft adds an opt-in container-agent backend. A trusted Box supervisor prepares the authorized filesystem view. A trampoline in a separate workload container accepts the prepared launch as that container's sole PID 1. It uses the runtime's private PID namespace, preserves its proc masks, binds that proc view read-only, and applies Box's remaining restrictions. Loss of the supervisor terminates the workload namespace. Default standalone behavior stays on the existing backend. Hosted tool/MCP configurations remain refused in container mode.

The motivating deployment is OCE with one provider Pod per Agent revision. OCE owns Pod/PVC selection, authentication, readiness, routing, and the exact setup seccomp profile. These remain adapter responsibilities. This PR adds no Kubernetes dependency.

Upstream ownership and dependencies

This revision includes merged main e0af331d457222d7fb189f9548653b92492eaa15. It uses the upstream mount-target and metadata-only-parent fixes from #159 and #157. It does not copy their implementation into a separate path.

Area Owner and treatment in this PR
Shell alias stdin forwarding #140 owns this feature. The duplicate implementation and its short-input test have been removed from this PR. Alias forwarding matches main; only independent inherited-FD cleanup remains here. #140 is a dependency for OCE's piped-input workflow, not for compiling the container backend.
Masked-proc container hosting This PR supplies a candidate for the constraint recorded in #26. That issue is open; upstream ownership and delivery timing are unconfirmed. This is not a claim that maintainers declined the work or selected this design.
Native filesystem interception and launch registration #186 and #188 own that work. This PR does not import their unmerged feature or BPF capability requirements. Their combination with container mode is not qualified.
OpenClaw launcher IPC, Node routing, and code-mode startup Integration changes stay in OpenClaw/OCE. No workload recvmsg grant or executable-memory exception is added here.

The draft should shrink further if upstream supplies an equivalent supported path. It must not be treated as a competing implementation of #140 or #188.

Remaining changes and necessity

Change Failure without it Boundary preserved
Container backend and private descriptor/lifetime handoff A fresh proc mount fails under inherited masks. An adapter cannot recreate Box's authorized filesystem identities, filters, or private launch descriptors. Runtime-provided private PID namespace; proc masks; Box filesystem and network restrictions; fail-closed startup and supervisor-loss cleanup.
Container-only renameat2(RENAME_NOREPLACE) Atomic no-replace publication returns EPERM; check-then-rename loses atomicity. Exchange, whiteout, and unknown flags remain denied.
Container-only namespace-local kill Native child/process-group cancellation fails. Targets 0, 1, and -1 remain refused. Signals cannot leave the private PID namespace. This is not a parent-child or signal-number restriction.
sendfile and copy_file_range return ENOSYS Native copy libraries abort on EPERM instead of using their existing read/write fallback. Both optimized syscalls remain denied. The fallback keeps the same filesystem and descriptor restrictions.
Complete alias inherited-FD cleanup Scanning a very large descriptor limit delays every alias invocation; a lowered soft limit can leave higher inherited descriptors open. Close the full range, or enumerate actual descriptors when close_range is unavailable. No arbitrary descriptor cap.

The syscall policy keeps upstream's existing constructor signature. Only container-mode callers select the additional scoped permits. No broad remount-flags rewrite, workload FD-import permission, direct network grant, or outer unconfined profile is included. Record version 24 represents the explicit backend choice.

Related Issues

Refs #26 for the masked-proc constraint. This draft does not establish support for all Kata configurations and does not close that issue.

OCE architecture proposal: openclaw/openclaw-enterprise#3230

Type of Change

New experimental backend, focused compatibility fixes, and operator/design documentation.

Testing

Prepared commit: 05efc455d65dfea67734f5cb71ca27b0ff5e9582. Tested source tree: eb04b1ab9249dc3964445755add7ad279d3e8d34, based on main e0af331d457222d7fb189f9548653b92492eaa15.

Check Result
Linux ARM64 containment test compilation, locked dependencies Passed for all containment test targets.
Native Linux namespace tests 268 passed, 0 failed, 0 ignored; no skip diagnostics.
Native Linux containment trampoline tests 51 passed, 0 failed, 0 ignored; no skip diagnostics.
macOS Box and containment builds All-features and no-default-features builds passed.
Formatting cargo fmt --all --check passed.
Scoped Clippy, all targets and features Exit 0; one existing warning in hosted.rs, also present in the prior baseline. This is not a clean workspace -D warnings result.
macOS affected runtime tests 85 passed: shell 54, inherited handles 2, MCP catalog scaling 1, MCP policy staging 24, MCP startup 4.
Deterministic containment harness Original run RED: 120 passed, 1 failed (PO-9), 8 declared Linux-only skips; all 129 rows recorded. See diagnosis below.

The focused Linux tests include:

  • ordinary_process_cannot_borrow_procfs and ordinary_process_cannot_be_a_container_receiver for container-entry refusals.
  • descriptor_handoff_preserves_the_opened_file_and_cloexec and unframed_transport_data_is_refused for the private handoff.
  • no_replace_rename_preserves_collisions_and_refuses_other_modes for the atomic rename permit.
  • child_termination_does_not_admit_init_or_broadcast_targets for signal targets.
  • optimized_copy_calls_remain_unavailable_for_read_write_fallbacks for denied-copy errno behavior.
  • ordinary_namespace_keeps_container_compatibility_calls_refused for default-backend isolation.
  • container_receive_cannot_import_descriptors for refused workload FD import.

Separate upstream composition check: owner #140 at aa1b8e419cf0deaad25113ab68d45451fef05450 applies cleanly to this source. Combined tree 7cafba29bdc8cb7db1b2db9512bb2a4bd0c15d20 compiled on Linux ARM64 and passed 33 alias tests and all 3 stdin regression tests, with no skip diagnostics. The alias tests include both_linux_cleanup_paths_close_descriptors_above_a_lowered_limit. The stdin tests cover silent open input, Python leaving input for later commands, and release of the broker's byte budget. This composition is a test artifact; #140 is not copied into this branch.

PO-9 diagnosis: the host PATH resolves git to a corporate og wrapper. Box correctly recorded a default-deny for that resolved executable, but the test expected a denial naming git. The single case passed with a task-local PATH selecting /usr/bin/git, without changing Box policy, test source, or global PATH. The original full-run RED is retained. This is not a fresh-main baseline or a green full-suite rerun.

The initial package-wide test attempt inside the coding tool's macOS execution sandbox failed on filesystem and nested-sandbox permissions. The affected runtime targets were then run in the native host environment and passed as listed above, with Box's own restrictions unchanged. scripts/test-all.sh could not unpack a dependency in that execution sandbox. A complete workspace suite has not been qualified in this revision. These limits remain merge gates.

Integration and merge gates

  • The deterministic run has the diagnosed PO-9 identity mismatch, 8 macOS-inapplicable Linux cases, and no fresh-main comparison. The complete workspace gate and existing owned Clippy warning also remain unresolved for merge qualification.
  • fix(box): forward the shell alias's stdin to the command #140 remains an unmerged external dependency for the motivating piped-input workflow. Its own published limits still apply; this PR does not claim complete stdin backpressure or script-hook support.
  • refactor: prepare containment handoff for Linux native policy #186/feat: activate Linux native filesystem policy #188 are not part of the tested runtime. Container-mode native filesystem interception needs separate integration and security review before it is enabled.
  • No fresh installed OCE end-to-end or VM-recovery result is claimed for this narrowed source. Earlier installed-image acceptance used another source revision and cannot qualify this head.
  • Linux ARM64 is the target. Other architectures, production capacity, and credential proxy are outside this validation.
  • This is a draft. Maintainer design approval and human review remain required. Nothing has been merged.

Checklist

  • I have read CONTRIBUTING
  • Human author has reviewed and can explain every line, including AI-generated code
  • The diff is limited to the container backend and remaining native compatibility failures
  • Duplicate stdin implementation is removed in favor of fix(box): forward the shell alias's stdin to the command #140
  • Operator and design documentation describe the backend choice
  • Complete final-source OCE acceptance and all upstream merge gates
  • Ready for merge

AI assisted the implementation and review. The repository's preferred Opus reviewer was unavailable; a separate Codex reviewer assessed the change and its checks.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

## Problem

Box cannot mount its nested proc view inside a container that retains the runtime's proc masks. Native copies and atomic publication also fail under the current syscall results, and the shell alias loses piped stdin.

## Solution

Add an explicit container-agent mode with a PID-1 trampoline, prepared descriptor handoff and supervisor lifetime tracking. Keep the masked proc view and workload policy. Admit only the container rename mode and namespace-local signals, and return ENOSYS for still-denied copy optimizations. Repair alias descriptor cleanup and input forwarding. Update operator and containment documentation and record version.

## Tests

On the refreshed main base, cargo fmt passes and 126 containment library tests pass on macOS. Focused Clippy completes with existing vendored and hosted.rs warnings; strict -D warnings fails. The focused stdin regression result is recorded in the PR. Fresh Linux port and complete integration verification remain pending. Earlier Linux and 32-case native OCE acceptance qualify the earlier source snapshot only. Independent review found a remaining large-stdin flow-control limitation, documented as draft follow-up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant