Kubernetes Network Policy for agents is the wrong grain once the agents stop being pods. A NetworkPolicy selects pods by label, so on Agent Substrate the policy on a worker is the union of every actor that will land there: a shared apartment with one key, not a zero trust architecture for AI agents.
Defensive security research. This post analyses publicly disclosed findings so the controls that stop them can be tested. It describes mechanisms, not procedures, and links the primary sources for anyone verifying the work.
I have written NetworkPolicy for agent namespaces the usual way: default deny, allow DNS, allow the model gateway, allow a tool host. That works when each agent is a pod with its own labels and its own ServiceAccount. It stops working the moment the runtime multiplexes actors onto a pool.
Why doesn’t Kubernetes NetworkPolicy isolate Agent Substrate actors?
Because Kubernetes has no object for an actor.
NetworkPolicy matches pods. ServiceAccount is mounted into pods. DNS policy, if you have one, is usually per namespace or per pod. Agent Substrate’s live assignment (which actor is on which worker right now) lives in ateapi, not in a pod label you can select. Kubernetes sees a WorkerPool and an ActorTemplate. The interesting state is elsewhere. I wrote the dataplane names in Agent Substrate dataplane.
A worker hosts one actor at a time. Density comes from time-multiplexing, not from packing two processes into one netns on purpose. In the first lab, nine agents ran on two worker pods. Later field-guide setups used 18 agents on the same two workers. The NetworkPolicy on those two pods cannot name “the refund agent” versus “the payroll agent.” It can only name the pool.
If you put the refund agent’s destinations on the worker, the next actor inherits them. If you put the union of every agent’s destinations on the worker, you have built a shared allowlist. Shared allowlists are how a permitted package registry became the sandbox escape in the July 2026 agent intrusion, and how paste sites and file-drop hosts became command and control. The destination was allowed. The principal was not.
Always-on kagent defaults sit at about 204 MiB resident and 50m CPU request idle. Nine of those is about 1.8 GiB and 450m CPU reserved around the clock. Substrate’s density story is the reason you multiplex. Multiplexing is also the reason pod-scoped policy is the wrong unit.
What can NetworkPolicy still do for a worker pool?
Keep it. Use it as the backstop.
Cluster-shaped rules belong on pods. I still write them. I just do not pretend they know who the actor is.
- Worker pods cannot talk to the Kubernetes API unless you meant them to. The Hugging Face timeline of the July 2026 intrusion has the agent reading a projected service account token and querying the cluster API. A NetworkPolicy that denies egress to the API server from a data-processing namespace removes that reconnaissance step. It does not need to know which actor is in the bay.
- Worker pods cannot reach other tenants’ namespaces. Namespace isolation is still a real control. Multiplexing inside one pool does not excuse a path into someone else’s.
- Egress from the pool goes only to the egress proxy, DNS you intend, and node-local sandbox plumbing. Not to the internet. Not to arbitrary ClusterIPs. The agent containment lab maps this onto two Docker networks: the agent sits on an internal network with the gateway, and only the gateway sits on the network that can leave. Same shape, different scheduler. Agent containment basics.
Those rules survive a restore onto a different worker because they are about the pool, not about a pod IP that will change.
They do not survive a CNI that ignores them. kind’s default CNI accepts NetworkPolicy objects, stores them, returns them from kubectl get, and passes the traffic anyway. I already burned that hour in agent LLM key Kubernetes controls. The DNS covert-channel lab had to install Calico for the same reason. If you are testing this on kind, install a CNI that enforces, or you will ship a policy that looks correct and does nothing.
How do you apply network policy to the actor instead of the pod?
Three things, in this order. Collapse them into one YAML file and you will put the refund rule on the pod and the next actor inherits it.
- Identity. The request leaving the actor has to carry this agent, not the worker’s ServiceAccount. Otherwise the proxy is authorizing a pod. Proof of agent identity is the evidence requirement: which agent, which session, on whose behalf. A ServiceAccount on a WorkerPool is proof of a pool.
- Egress. Default deny at a proxy that sees actor identity and a destination. Hostname allowlists fail on paste sites and “search.” Payload and destination both matter. agentgateway as an egress proxy is the pattern I run. In standalone v1.6.0, unmatched hosts have no route. DNS is a separate channel: an HTTP CONNECT proxy never sees a query that never becomes HTTP. That is the DNS egress covert channel.
- Tool policy. Network allow is not “the agent may call delete.” Gate the tool call. Tool-call guardrails sit on
tools/callbefore the tool runs. Agent action verification is the boolean on that path, not a second large-model prompt that says it is 90 percent sure.
A service mesh can sit in the middle for mTLS between the proxy and upstreams. It does not replace step 1. If the mesh only sees the worker, you have encrypted the wrong identity.
The composition I would ship looks like this:
actor -> sandbox netns -> egress proxy (actor identity + dest policy)
-> mesh mTLS to internal services
worker pod NetworkPolicy -> only the proxy, DNS, and node-local sandbox plumbing
Tradeoff: you now have two policy languages. Pod NetworkPolicy for “this pool cannot become a botnet.” Actor policy for “the refund agent cannot hit payroll.” That duplication is the point. Each layer assumes the other failed. That is the stack in the agent containment stack.
The other tradeoff is suspend. Suspend-safe networking is not a policy problem, but it is a network problem: if you park an actor, you cut its sockets. Do not write a NetworkPolicy that assumes a long-lived TCP session to a tool host if you also plan to suspend between turns.
Why is a service mesh not enough for multiplexed agents?
A mesh is zero trust for the worker pod if you do mTLS and authz on the pod identity. Multiplexed actors share that pod. Mesh without actor identity is encrypted shared-fate.
What is an agentic mesh is the longer definition: keep the service mesh for L4 identity and encryption, add an AI-aware hop that can see tool and model actions. Replacing Istio with agent-mesh marketing is the wrong mental model. Extending the mesh for agent protocols is the useful one.
atenet, the Substrate router into actors, is agentgateway under the hood in the lab I ran. Config lived at /etc/agentgateway/config.yaml inside the pod. Traffic to an actor goes through there, not through a Service per agent, because there is no Pod per agent. That hop is where actor identity has to show up. NetworkPolicy will never see it.
SPIFFE on the worker is still worth having. It proves which process is the proxy or the worker, and it gives you a handshake you can fail closed. It does not name the actor that was restored onto that worker five seconds ago. Mint actor identity at restore, drop it at suspend, and authorize the proxy on that identity. Do not ask the mesh to invent a principal Kubernetes does not have.
How do you test that NetworkPolicy is actually enforced?
If you cannot name the packet you expect to die, you do not have a test.
Pod backstop. From a worker pod, curl the Kubernetes API, a neighbor namespace, and an unlisted internet host. The first two should fail if you meant them to. The third should fail unless it went through the egress proxy and the proxy allowed it. Confirm the deny is in a log the agent cannot edit.
CNI enforcement. Apply a default-deny, watch kubectl get networkpolicy return the object, then send the packet anyway. On kind’s default CNI it will pass. That is the silent-success case from the secrets-hardening lab. Fix the CNI before you debate policy YAML.
DNS grain. A default-deny plus UDP/TCP 53 only to cluster CoreDNS stops a pod from querying 8.8.8.8 directly. It does not filter by domain name. It also does not follow the actor. Two actors on the same worker still share that resolver. Treat DNS as in-scope, not as plumbing you forgot.
Actor grain. Restore agent A, try an unlisted host, confirm deny. Suspend A, restore agent B on the same worker, try a host only A was allowed to reach, confirm deny. If B inherits A’s destinations, your policy is still on the pod.
Identity replay. Capture a token from agent A, replay as agent B, confirm 403. That test lives in proof of agent identity. NetworkPolicy cannot run it. If the only deny you have is a dropped packet at the pod, you have not tested the actor.
Checklist I would ship with the pool
- Default-deny egress on the WorkerPool pods.
- Allow DNS only to the cluster resolver you operate.
- Allow egress only to the egress proxy ClusterIP.
- Deny the API server from worker namespaces that do not manage the cluster.
- CNI that actually enforces NetworkPolicy, verified with a refused packet.
- Actor identity on the request, minted at restore, dropped at suspend.
- Proxy allow/deny logged off the actor’s filesystem.
- No long-lived TCP assumption in policy if you suspend between turns.
For the isolation layer under this, sandboxed networking for agents. Field guide: Agent Substrate. The lab that made multiplexing real is kagent Agent Substrate.