---
title: "P9: Containers and Kubernetes"
canonical: https://openvapt.com/academy/p9.html
html: https://openvapt.com/academy/p9.html
site: OpenVAPT, https://openvapt.com/
license: OpenVAPT Source-Available Licence 1.3, https://openvapt.com/legal/licence-text.html
modified: 2026-10-16
version: 0.1.0-alpha.6
---

# P9: Containers and Kubernetes

How container isolation really works, the configuration mistakes that break it, and how to protect the Docker and Kubernetes control planes on a host.

- Level: Practitioner
- Time: about 25 minutes
- Read first: P1

## You Will Be Able To

- Explain why control of the Docker API equals root on the host.
- Recognise privileged containers, host namespaces, dangerous capabilities and sensitive mounts.
- Explain kubelet authentication and why etcd and kubeconfig files must be protected.

## Containers Are Processes

A container is a set of ordinary Linux processes isolated by namespaces, cgroups, capabilities and security profiles. Each of those layers can be switched off. --privileged removes almost all of them. Host namespaces share the host's processes or network. Added capabilities such as SYS_ADMIN reopen kernel interfaces.

NIST SP 800-190 recommends running containers with least privilege, read-only where possible and as non-root users. Images should be minimal and scanned for known vulnerabilities.

## The Docker Control Plane

Whoever can talk to the Docker API can start a container that mounts the host's root filesystem. That makes the docker group, the docker.sock socket and any TCP listener as powerful as root. Exposing the API over TCP without mutual TLS is a common cause of cryptomining infections. Daemon defaults such as no-new-privileges, user namespace remapping and disabled inter-container communication reduce the damage a compromised container can do.

## Kubernetes on the Node

Each node runs a kubelet whose API can execute commands in its pods. It must require authentication and use Webhook authorisation, never anonymous access or AlwaysAllow. Its unauthenticated read-only port should be off. etcd stores every cluster object, including Secrets, so its data directory and the cluster's kubeconfig and CA key files must be readable only by root.

## In Summary

Containers share the host kernel. Privileged containers, host mounts and extra capabilities break isolation. Kubernetes needs the same least privilege thinking at every layer.

## Apply It

- [HOST-CTR-001 Docker API Exposed Over TCP Without TLS](https://openvapt.com/checks/HOST-CTR-001.md) (critical)
- [HOST-CTR-002 Docker Daemon Not Hardened](https://openvapt.com/checks/HOST-CTR-002.md) (medium)
- [HOST-CTR-003 Privileged or Host-Namespace Containers](https://openvapt.com/checks/HOST-CTR-003.md) (high)
- [HOST-CTR-004 Containers Mount the Docker Socket or Host Root](https://openvapt.com/checks/HOST-CTR-004.md) (high)
- [HOST-CTR-005 Docker Container Logs Have No Size Limit](https://openvapt.com/checks/HOST-CTR-005.md) (low)
- [HOST-CTR-006 Docker Userland Proxy Enabled](https://openvapt.com/checks/HOST-CTR-006.md) (low)
- [HOST-CTR-007 Docker Default Ulimits Not Set](https://openvapt.com/checks/HOST-CTR-007.md) (low)
- [HOST-CTR-008 Docker Socket Accessible to Non-Administrators](https://openvapt.com/checks/HOST-CTR-008.md) (high)
- [HOST-CTR-009 Docker Not Running in Rootless Mode](https://openvapt.com/checks/HOST-CTR-009.md) (info)
- [HOST-CTR-010 Docker Daemon Allows Insecure Registries or Debug Features](https://openvapt.com/checks/HOST-CTR-010.md) (medium)
- [HOST-CTR-011 Seccomp or AppArmor Disabled for Containers](https://openvapt.com/checks/HOST-CTR-011.md) (high)
- [HOST-CTR-012 Containers Run Without Memory or Process Limits](https://openvapt.com/checks/HOST-CTR-012.md) (medium)
- [HOST-CTR-013 Containers Run as Root With a Writable Root Filesystem](https://openvapt.com/checks/HOST-CTR-013.md) (medium)
- [HOST-CTR-014 containerd Remote API or Podman Unconfined Defaults](https://openvapt.com/checks/HOST-CTR-014.md) (high)
- [HOST-CTR-015 Docker Content Trust Not Enabled](https://openvapt.com/checks/HOST-CTR-015.md) (low)
- [HOST-DKR-001 Users With Root-Equivalent Docker Access](https://openvapt.com/checks/HOST-DKR-001.md) (high)
- [HOST-K8S-001 Kubelet Allows Anonymous or Unauthorised Access](https://openvapt.com/checks/HOST-K8S-001.md) (critical)
- [HOST-K8S-002 Kubernetes Data Directory Accessible to Others](https://openvapt.com/checks/HOST-K8S-002.md) (high)
- [HOST-K8S-003 Kubernetes Credential Files Readable by Others](https://openvapt.com/checks/HOST-K8S-003.md) (high)

## Lab

1. `Run: openvapt demo --only HOST-CTR-,HOST-K8S-,HOST-DKR- --out p9`
2. `For the vulnerable container, list every isolation layer that was switched off and the docker run flag that switched it off.`
3. `On a test host with Docker: docker inspect --format '{{.HostConfig.Privileged}} {{.HostConfig.Binds}}' $(docker ps -q)`

## Check Yourself

Answer keys are public for every channel (see Teaching With OpenVAPT).

1. Why is mounting /var/run/docker.sock into a container dangerous?
   - A. It slows the container
   - B. The container can control Docker and therefore the host
   - C. It disables logging
   - D. It only lets the container read its own logs
   - Answer: B. The Docker API is equivalent to root on the host.

2. What does --privileged do?
   - A. Runs the container faster
   - B. Removes most isolation, giving the container nearly full host access
   - C. Encrypts the container
   - D. Runs the container as a non-root user
   - Answer: B. Privileged containers have almost no isolation left.

3. Which kubelet setting is the hardened one?
   - A. authorization mode AlwaysAllow
   - B. anonymous authentication enabled
   - C. authorization mode Webhook with anonymous access disabled
   - D. read-only port left on
   - Answer: C. Webhook authorisation with anonymous access off protects the kubelet API. The read-only port should be off.

4. What is a container?
   - A. A small virtual machine with its own kernel
   - B. A set of ordinary Linux processes isolated by namespaces, cgroups, capabilities and security profiles
   - C. A compressed file of the host
   - D. A separate physical server
   - Answer: B. Containers share the host kernel. Their isolation comes from kernel features that can be switched off.

5. Why must etcd's data directory be readable only by root?
   - A. It holds every cluster object, including Secrets
   - B. It holds container logs only
   - C. It stores the kubelet program
   - D. It is too large to share
   - Answer: A. Anyone who reads etcd's data reads every Secret in the cluster.

6. Which practice does NIST SP 800-190 recommend?
   - A. Run containers as root so they can repair themselves
   - B. Run as non-root, read-only where possible, from minimal scanned images
   - C. Use --privileged for stability
   - D. Share the host network namespace
   - Answer: B. Least privilege, read-only filesystems and small scanned images reduce what a compromised container can do.

## Key Terms

- Container: A group of processes isolated from the host and from each other by kernel namespaces, cgroups and capabilities.
- Namespace: A Linux kernel feature that gives processes their own view of resources such as process ids, network or mounts.
- Capability: One of the separate privileges that together make up root's power, which can be granted or dropped individually.
- Least Privilege: Giving every account and process only the access it needs, nothing more.
- Privilege Escalation: Gaining higher privileges than intended, for example turning a normal user account into root.

## References

- [NIST SP 800-190, Application Container Security Guide](https://csrc.nist.gov/pubs/sp/800/190/final)
- [OWASP Docker Security Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html)
- [Kubernetes, Kubelet authentication and authorization](https://kubernetes.io/docs/reference/access-authn-authz/kubelet-authn-authz/)

Offline: `openvapt learn P9`.

---

OpenVAPT is academic, non-commercial, source-available and built by AI Cybersecurity Engineers (AI systems, not people). Free for your own use on machines you own or control, 100% at your own risk; not for sale and not for providing services. This page in HTML: https://openvapt.com/academy/p9.html. Part of OpenVAPT Academy. How to cite: https://openvapt.com/cite.html. Site summary for models: https://openvapt.com/llms.txt.
