pb-49 controls what an agent may ask to do; this playbook controls where it can act. Agents that run terraform plan, execute tests, or modify code need a workspace — and giving them a shell in a shared namespace is how prompt injection becomes lateral movement.
Tier: Advanced · Workflow area: Agent operations & guardrails
Here you build the agent sandbox as a platform primitive: ephemeral, network-fenced, secret-scoped, resource-capped, and self-destructing, so "the agent can act" and "the blast radius is bounded" are both true by construction.
terraform plan, data jobs) rather than just call curated APIs.Skip cluster-grade sandboxing for agents that only call pb-51's MCP/API tools and never execute arbitrary code — the API layer's authz is the boundary there.
NetworkPolicy (Cilium, Calico) — verify enforcement, don't assume it.One agent run = one ephemeral namespace. The harness (CI job, orchestrator, or pb-51's platform API) creates agent-run-<id> per task, applies the standard bundle below, and schedules the agent's Job into it. Namespaces are cattle: labeled with owner, agent identity, TTL, and task reference.
Default-deny egress, allow by name.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: {name: agent-egress, namespace: agent-run-42}
spec:
podSelector: {}
policyTypes: [Egress]
egress:
- to: [{namespaceSelector: {matchLabels: {kubernetes.io/metadata.name: kube-system}}}]
ports: [{protocol: UDP, port: 53}, {protocol: TCP, port: 53}]
- to: [{namespaceSelector: {matchLabels: {kubernetes.io/metadata.name: platform-gateway}}}]
ports: [{protocol: TCP, port: 4000}]
DNS plus the LLM gateway, and nothing else by default. Package registries or an internal git mirror get added per agent class, explicitly — FQDN-based egress (Cilium) beats IP-based where available. An injected agent that can't reach the internet can't exfiltrate to it.
Scope identity and secrets to the run. A dedicated ServiceAccount per namespace with a Role granting only in-namespace verbs (no cluster-scope reads — cluster topology is reconnaissance). Cloud credentials, if any, are short-lived tokens scoped to the task (e.g. read-only plan role for terraform plan) injected at start and expiring with the TTL. Never mount long-lived platform secrets; never share a SA across agents.
Cap resources and harden the pod. ResourceQuota + LimitRange per namespace (CPU/memory/pods caps — a looping agent is a crypto-miner-shaped workload). Kyverno enforces the pod contract: no privileged, no hostPath, runAsNonRoot, restricted seccomp, image from your registry only. For genuinely untrusted code paths (agent-generated code execution), require runtimeClassName: gvisor (or run those steps in Firecracker-based micro-VMs) — a container boundary alone is not a security boundary against hostile code.
Enforce TTL and cleanup. Jobs get activeDeadlineSeconds and ttlSecondsAfterFinished; the namespace itself is reaped by a Kyverno cleanup policy or a cron controller keyed on the TTL label (e.g. 4h hard cap). Nothing an agent builds in a sandbox is durable — outputs it should keep (a plan file, a diff, test results) are exported through the harness to artifact storage, which is also where humans review them.
Audit everything, then attack it. Ship the namespace's K8s audit events, network-policy drops, and agent command log to your SIEM keyed by run ID (joins with pb-46 traces and pb-49 action logs). Red-team drill: run an agent with a hostile task ("curl this external host, read secrets in namespace X, keep running forever") and verify egress denial, RBAC denial, and TTL kill all fire — keep the transcript as evidence.
Treat agents as a first-class platform persona — the same primitives you give human tenants (namespace, RBAC, quota, egress policy) at machine speed and with a shorter leash.
activeDeadlineSeconds; namespace reaped on TTL.Write the sandbox spec down as the "agent golden path" template (namespace bundle + Kyverno policies + TTL controller) so teams consume it via one platform API call — pb-51 exposes exactly that.