Repository navigation
Description
User Story
I run OpenShell on Kubernetes in a deployment where network policy is enforced outside the workload, by a component that owns each sandbox's network interface.
I want that component to enforce each sandbox's OpenShell network policy and inject its provider credentials, instead of duplicating that enforcement in the sandbox supervisor.
I need OpenShell to keep the agent from running until the component has applied the sandbox's policy, and to tell me when it rejects one.
Problem Statement
OpenShell can't hand a sandbox's network policy or credentials to a trusted external enforcer, or learn whether the enforcer applied them before the agent starts.
The stock data path also defeats an external enforcer. The supervisor proxies every connection the agent opens, so agent traffic leaves from the supervisor's address. With shared supervisors, an enforcer on the wire sees one source for every sandbox on a node and can't apply each sandbox's policy.
Impact / Why This Matters
Deployments that enforce network policy outside the workload can't use OpenShell without running two enforcement points whose policies can diverge, or giving up per-sandbox policy. Configuring the external enforcer by hand from OpenShell policies is error-prone, and nothing stops an agent from running before the enforcer is ready.
Proposed Design
An operator enables native-network mode for the Kubernetes driver in gateway configuration. With it:
- Every new sandbox's workload Pod gets an enforcer-provided network as its only interface, and its agent traffic leaves directly on that network. The external enforcer on that network enforces the sandbox's network policy and injects its provider credentials.
- Filesystem and process policy,
exec, SSH, and the other sandbox controls stay with the supervisor and are unchanged. - The external enforcer is a new role in the supervisor protocol and implements a subset of it. It connects to the gateway the way a supervisor does, with its own identity separate from the supervisor's, and uses only the parts it needs: learning which sandboxes exist, reading each sandbox's effective policy and provider credentials, and reporting whether it accepted them. The gateway refuses the rest of the protocol for this role, so the enforcer can't launch or take over sandboxes, act as a sandbox's supervisor, or call the gateway on a sandbox's behalf.
- A new sandbox's agent doesn't start until the enforcer accepts its policy. Without an attached enforcer, new sandboxes stay pending rather than run unenforced.
- A policy change becomes current only after both the supervisor and the enforcer apply it. A credential rotation the enforcer hasn't accepted isn't installed in the sandbox.
- An enforcer that can't honor a policy feature can refuse it at the API through a gateway interceptor, so users get the error when they set the policy.
- The mode runs with shared supervisor topology from RFC 0018 and requires poll configuration delivery.
The design changes the isolation backend's mediation requirement from RFC 0012 for these sandboxes and needs cross-cutting review across the Kubernetes driver, gateway, supervisor, and sandbox runtime, so it is proposed as RFC 0029.
Full design: RFC 0029 in #6117.
Suggested UX
[openshell.drivers.kubernetes.external_enforcer]
namespace = "openshell-enforcer"
token_secret_name = "openshell-external-enforcer-token"
service_account_name = "external-enforcer"
[openshell.drivers.kubernetes.external_enforcer.network.sandbox]
network_attachment = "openshell-sandboxes/sandbox-vf"
resource = "example.com/sandbox-vf"
nameservers = ["192.168.100.1"]openshell sandbox create --name agent -- claude
openshell sandbox get agent
# Conditions:
# - ConfigurationReady: False EnforcerPending
# After the enforcer accepts the policy, the agent starts.
openshell policy set agent --policy ./policy.yaml --wait
# Returns once both the supervisor and the enforcer apply the revision,
# and fails with the enforcer's message if it rejects it.Acceptance Criteria
- RFC 0029 is open for review at
rfc/0029-external-network-enforcer/README.mdfollowing the repository RFC template, including its amendment to RFC 0012. - Maintainers accept or reject the RFC.
- Implementation work is tracked in its own issue.
Alternatives Considered
- Program the enforcer from a gateway interceptor. An interceptor sees gateway API operations as they happen, so it could forward each policy and provider write to the enforcer. But a sandbox's effective policy and credentials aren't just API writes: they include the global policy, the restrictive default, and credentials the gateway refreshes on its own, none of which pass through an interceptor. Interceptors also don't own sandbox state, so they can't hold an agent until the enforcer applies its policy, or report whether a revision was applied. And agent traffic would still leave from the supervisor's address. The design uses interceptors only for what they fit: refusing policies the enforcer can't honor at the API.
- A supervisor isolation backend that calls the enforcer. The supervisor would keep mediating agent traffic and push each sandbox's policy and credentials to the enforcer itself. The agent has connectivity to the supervisor, so the supervisor is exposed to the workload it would be describing to the enforcer. For hardening, the enforcer doesn't depend on the supervisor: it takes policy and credentials directly from the gateway, the source of truth, over its own authenticated channel. A new backend would also duplicate process launch, identity, and every other control the built-in runtime keeps.
- A separate policy-provider service the gateway calls to program each sandbox. It duplicates the supervisor protocol's desired state, admission, and authentication, and puts a synchronous dependency in the gateway's policy handlers. feat: pluggable policy sourcing via a Policy Provider subsystem #1713 added pluggable policy sourcing; this proposal is about enforcement.
- The enforcer as a supervisor. This would give sandbox lifecycle management to the external enforcement layer, which should only enforce network policy: it would launch and take over instances, and hold every sandbox's launch material and gateway credentials. Lifecycle stays with the gateway and the supervisor.
Agent Investigation
- On
main, the sandbox runtime routes agent socket calls through a seccomp user notification (crates/openshell-sandbox/src/linux/seccomp_notify.rs), and the network supervisor proxies the connection, so agent egress always leaves from the supervisor. - The enforcer can reuse existing contracts:
SupervisorHost.Attach,HostHello, andAssignmentSnapshotinproto/supervisor_host.proto, andGetSandboxConfig,GetSandboxProviderEnvironment, andReportSandboxConfigurationinproto/openshell.proto. Its identity is a dedicated enforcer token in a Secret in the enforcer's own namespace, which the gateway accepts only together with a Pod-bound service account token from that namespace. The gateway topology from RFC 0018 is onmain. - A prototype exists. Once the RFC is accepted, it lands in one PR behind the gateway's
experimentalfeature, inert without theexternal_enforcersetting.
Checklist
- I've reviewed existing issues and the published docs
- This is a design proposal, not a "please build this" request
Activity
drew commentedon Nov 30, 2026
You can grab RFC-0026 for this.
[-]feat(k8s): let an external policy enforcer enforce sandbox network policy[/-][+]feat(k8s): propose the external network enforcer and native-network mode (RFC 0029)[/+]