1 Container Security Misconfigurations
Docker provides isolation but is not a security boundary by itself. Common misconfigurations can lead to container escape and host compromise.
Running as root:
# Vulnerable: default root user
FROM ubuntu:20.04
RUN apt-get install -y myapp
CMD ["myapp"] # Runs as root inside container!If an attacker gains code execution in a root container, privilege escalation to the host is much easier via kernel exploits or volume mounts.
Privileged containers:
docker run --privileged myapp
# Gives container nearly all host capabilities
# Can mount host filesystems, access kernel features
# Trivial container escape!Secrets in ENV:
ENV DB_PASSWORD=admin123 # Visible in docker inspect, image layers!
ARG API_KEY=sk_live_xyz # Build args also visible in image history
# docker inspect --format='{{json .Config.Env}}' container_name
# Returns: ["DB_PASSWORD=admin123", "API_KEY=sk_live_xyz"]Exposed Docker socket:
docker run -v /var/run/docker.sock:/var/run/docker.sock myapp
# Container can now control the Docker daemon
# Effectively root access to the host!