What is Container Escape (Agent)?

2 min read Updated

Container escape in the agent context is when an agent running inside a containerised MCP server breaks out of the container boundary to access the host system.

WHY IT MATTERS

Containerisation is a common deployment pattern for MCP servers — each server runs in its own Docker container with isolated file systems, networks, and process spaces. Container escape defeats this isolation, giving the agent (or a tool running within the container) access to the host machine and potentially to other containers.

Escape vectors include exploiting kernel vulnerabilities accessible from within the container, abusing mounted host directories or Docker sockets, leveraging excessive Linux capabilities granted to the container, and using network access to reach the container orchestration API (e.g., Kubernetes API server).

In MCP deployments, the risk is elevated by common configuration mistakes. Developers mount host directories for convenience (giving tools access to the host file system), run containers in privileged mode for compatibility, or expose the Docker socket to enable container management tools. Each of these practices weakens container isolation.

A successful container escape is catastrophic in multi-tenant environments. If multiple users' agents share a host (each in separate containers), an escape from one container can compromise every other container on the same host — accessing other users' data, credentials, and tool outputs.

HOW POLICYLAYER USES THIS

Intercept operates as an external policy layer, enforcing rules before tool calls reach the containerised server. Even if the container is compromised, Intercept's YAML policies restrict which tools can be invoked and with what arguments — limiting the operations available for exploitation. Policies that block shell execution tools, restrict file paths, and deny network access to infrastructure endpoints reduce the attack surface available for container escape attempts.

FREQUENTLY ASKED QUESTIONS

Should I run MCP servers in containers?
Yes — containers provide meaningful isolation even though escapes are possible. Combine containerisation with non-root execution, minimal capabilities, read-only file systems, and proxy-level policy enforcement for defence in depth.
What container configurations are most dangerous?
Privileged mode, mounted Docker sockets, host network mode, mounted host directories (especially /), and containers running as root. Avoid all of these in production MCP server deployments.
Does Kubernetes help or hurt container isolation?
Both. Kubernetes provides network policies, pod security standards, and namespace isolation. But it also introduces new attack surfaces — the API server, service accounts, and etcd — that an escaped container can target.

FURTHER READING

Enforce policies on every tool call

Intercept is the open-source MCP proxy that enforces YAML policies on AI agent tool calls. No code changes needed.

npx -y @policylayer/intercept
github.com/policylayer/intercept →
// GET IN TOUCH

Have a question or want to learn more? Send us a message.

Message sent.

We'll get back to you soon.