feat(sandbox): reserve namespaces for supervisor control state
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 8.7k
- Forks
- 1.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 253
Description
Problem Statement
OpenShell currently protects a concrete list of in-container supervisor paths from OCI WorkingDir, image VOLUME, and driver-config mount overlap. This is a reasonable fail-closed starting point, but a per-file registry can drift when privileged supervisor state gains a new path. A missed path could let a workload-writable workspace or mount overlap state later trusted by the root supervisor.
The long-term boundary should not depend on guessing every sensitive Linux path. OpenShell needs a stable rule for where its own privileged control state may live, while separately handling kernel filesystems and explicitly untrusted image inputs.
This was identified while reviewing the Docker OCI workdir support in #2530, which currently uses OPENSHELL_CONTROL_PATHS and a separately validated runtime-configured SSH socket.
Proposed Design
Define and document an in-container filesystem contract with three classes:
- OpenShell-owned privileged state must live beneath a small set of reserved namespaces:
/run/openshellfor sockets, credentials, TLS material, and mutable runtime state./opt/openshellfor the supervisor executable and immutable packaged assets.
- Kernel interfaces such as
/proc,/sys, and/devare identified from filesystem metadata rather than a distro-path denylist. Keep/run/netnsas a narrowly documented exception until network namespace handling can use an OpenShell-owned location or file descriptors exclusively. - Image-provided files such as
/etc/passwd,/etc/group,/etc/hosts, and system CA bundles remain explicitly untrusted inputs. Privileged code should parse or snapshot required data before the workload starts and must not use workload-mutable image files as control state.
Workspace and mount validation should reject both ancestor and descendant overlap with the reserved namespaces and documented exceptions. Shared tests should prove that every OpenShell-generated container mount target and privileged runtime path falls within an approved namespace or exception.
Migrate existing container control resources under /etc/openshell and /etc/openshell-tls to /run/openshell where practical. Preserve /opt/openshell for executable content because /run may be volatile or mounted noexec.
Alternatives Considered
- Keep a file-by-file protected-path registry. This is simple but retains the drift risk.
- Derive protection only from generated container mounts. This catches mount collisions automatically but misses supervisor-created or otherwise accessed control paths, so it is useful only as defense-in-depth.
- Deny broad Linux system trees such as
/etc,/usr, and/var. This is brittle, rejects legitimate application workdirs, and still cannot prove that every privileged dependency was covered. - Move everything under
/run/openshell. The supervisor executable is better kept under/opt/openshell, and Linux kernel interfaces cannot be relocated without deeper runtime changes.
Agent Investigation
crates/openshell-core/src/driver_mounts.rscurrently centralizes concrete supervisor, TLS, token, proxy-auth, Kubernetes TLS, and/run/netnscollision paths.- Docker validates OCI workdirs, image-declared volumes, and user mount targets with component-aware ancestor/descendant checks. Its configured SSH socket is validated separately against the workspace.
- Current OpenShell-owned paths span
/opt/openshell,/etc/openshell,/etc/openshell-tls,/run/openshell, and/run/openshell-sidecar. - The process and network supervisors necessarily access kernel interfaces under
/proc,/sys, and/devand currently use the conventional/var/run/netnsnamespace location. - The supervisor also reads bounded image inputs including account files, hosts data, and CA bundles; those reads need an explicit untrusted-input contract rather than inclusion in the control-state namespace.
- Searches for existing issues about reserved supervisor namespaces and control-path/workdir collisions did not find a duplicate.
Definition of Done
- The reserved-namespace and untrusted-image-input invariants are documented in the sandbox architecture.
- OpenShell-owned privileged container state is under approved reserved namespaces, with documented exceptions.
- Workspace, image-volume, and driver-mount collision validation uses the namespace contract.
- Tests inventory generated control targets and fail when a target falls outside the contract.
- Existing
/etc/openshell*container paths are migrated or explicitly tracked for staged migration. -
/run/netnsis either eliminated through a namespace-handling refactor or retained as a documented kernel/runtime exception.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with crates/openshell-core/src/driver_mounts.rs and review the Docker OCI workdir, image-volume, and user-mount validation described in the issue. Trace the generated control targets and privileged runtime paths, then inspect the sandbox architecture documentation and shared tests. Done means the namespace contract is documented, validation enforces it, tests inventory targets, and existing /etc/openshell* paths are migrated or explicitly tracked.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, linux, rust
- Domain
- operating-systems, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100