← Writeups

Container escape primer

Capabilities, mounts, and how containers reach the host.

I built a small lab environment to explore how container misconfigurations can lead to host access. The goal was not to develop a new exploit but to better understand the practical impact of common configuration mistakes.

Containers appear strongly isolated, but that isolation depends heavily on configuration. Options such as privileged mode, shared namespaces, or unsafe mounts can significantly weaken the boundary between container and host.

The lab included several intentionally weak configurations:

  • A container running with --privileged.
  • Access to the host PID namespace.
  • Mounted Docker socket access.
  • Writable mounts exposing host directories.

Each configuration demonstrates a different path that can allow interaction with the host.

For example, access to the Docker socket allows processes inside the container to launch additional containers on the host. If those containers are started with elevated privileges or host mounts, that effectively becomes host access.

Shared namespaces introduce other risks. With the host PID namespace exposed, processes inside the container can enumerate and inspect host processes directly.

I also explored how cgroups and system interfaces appear from inside the container. Observing these interfaces helps illustrate how container runtimes enforce isolation and where those boundaries weaken when misconfigured.

None of the techniques explored in this lab are new. They are widely documented and well understood by practitioners working in container security.

The value of the lab is practical understanding. Walking through the environment step by step builds a clearer mental model than reading about the concepts alone.

It also leaves me with a reusable environment for demonstrations, experimentation, and explaining how configuration choices influence container security.