Opening Framing: "Separate Them" Is the Oldest Security Strategy
We have spent this unit studying boundaries: memory boundaries (Week 5), identity boundaries (Week 3), service boundaries (Week 6), network boundaries (Week 8), and evidence boundaries (Week 9).
Virtualisation and containers represent the same idea at a higher level: when you cannot fully trust a system, you place it inside a controlled box.
Modern computing survives by dividing reality into compartments. Cloud providers run thousands of customers on the same physical hardware. Enterprises run untrusted workloads alongside critical systems. Developers test dangerous code without risking their machines.
But boxes are only secure if their walls are real. This week is about what the walls are made of — and how they crack.
Virtualisation is enforced separation at the hardware boundary. Containers are enforced separation at the operating-system boundary. Both exist because isolation is survival.
Mental Model: Apartments vs Hotel Rooms
Think of two forms of separation:
- Virtual Machines (apartments): each tenant has their own plumbing, wiring, locked front door, and separate utility meters. The building structure separates units.
- Containers (hotel rooms): each guest has a private room with a lock, but they share plumbing, electrical, HVAC, and building management. Walls are thinner.
Both can be safe. But the failure modes differ:
- Apartments: breaches require breaking structural walls or compromising building management. Higher isolation, higher overhead.
- Hotels: breaches can exploit shared infrastructure — a problem with the plumbing affects everyone. Lower isolation, lower overhead.
The security question is not "Are VMs/containers secure?" The question is: What exactly is isolated from what, and what still leaks?
Mental model: VMs are apartments with separate infrastructure. Containers are hotel rooms with shared infrastructure. Choose based on your threat model and trust requirements.
1) What Is a Virtual Machine?
A virtual machine is a full operating system running inside an emulated (or hardware-assisted) environment. To the guest OS, it looks like real hardware — real CPU, real memory, real disk. The guest doesn't know (and shouldn't need to know) that it's virtualized.
The controlling layer is the hypervisor (also called Virtual Machine Monitor or VMM). The hypervisor:
- Allocates resources: CPU time, memory regions, storage, network interfaces
- Enforces boundaries: prevents VMs from accessing each other's memory or resources
- Mediates hardware access: translates guest requests to physical hardware
- Manages lifecycle: starts, stops, snapshots, migrates VMs
There are two types of hypervisors:
- Type 1 (bare-metal): runs directly on hardware — VMware ESXi, Microsoft Hyper-V, Xen. Used in data centers and cloud providers.
- Type 2 (hosted): runs on top of a host OS — VirtualBox, VMware Workstation. Used for development and testing.
Security implication: the hypervisor becomes a high-trust authority. If the hypervisor is compromised, every VM it manages becomes negotiable. The hypervisor is to VMs what the kernel is to processes — the ultimate arbiter of access.
Key insight: VMs provide strong isolation because each has its own kernel. But they all trust the hypervisor, making it a critical security boundary.
2) What Is a Container?
A container is not a full OS. It is a process (or group of processes) running with isolation features that make it appear to have its own environment:
- Filesystem namespace: sees its own root filesystem, isolated from host
- Process namespace: sees only its own processes, PID 1 is the container's init
- Network namespace: has its own network interfaces, IP addresses, routing tables
- User namespace: can map container root to unprivileged host user
- Resource limits (cgroups): constrained CPU, memory, I/O usage
But containers share the same underlying kernel with the host and with each other. This is the defining security trade-off: containers are lightweight and fast, but kernel sharing means shared fate.
A kernel vulnerability affects all containers on that host. A container escape — where a process breaks out of its namespace — grants access to the host and potentially all other containers. The isolation is enforced by kernel features, not hardware boundaries.
Container runtimes like Docker, containerd, and podman manage the creation and lifecycle of containers. Orchestrators like Kubernetes manage containers at scale across many hosts.
Key insight: containers isolate at the OS level using namespaces and cgroups. They're lighter than VMs but share more — including the kernel attack surface.
3) Isolation Guarantees: What You Can Rely On
In well-configured systems, isolation aims to guarantee:
- Process separation: one workload cannot directly see, signal, or control another workload's processes
- Filesystem separation: one workload cannot read or write another's data unless explicitly shared
- Network separation: communication paths are explicit and controlled; workloads can't sniff each other's traffic by default
- Resource governance: CPU, memory, disk I/O, and network bandwidth can be constrained to prevent resource exhaustion attacks
- Privilege separation: workloads can run with minimal privileges, reducing impact if compromised
The security strategy is to make compromise local — not systemic. If one container or VM is breached, the isolation should prevent lateral movement to others.
This is called blast radius reduction. You assume breaches will happen and design systems so that each breach affects as little as possible.
However, these guarantees depend entirely on correct configuration. Default settings may not provide the isolation you expect. Security requires deliberate design.
Key insight: isolation is about limiting blast radius. Assume breach, contain damage.
4) Where Isolation Fails: How Boundaries Crack
Isolation fails when boundaries are misconfigured, bypassed, or undermined:
- Escapes: a workload exploits a vulnerability to break out of its VM/container boundary and access the host or other workloads
- Over-privilege: a workload is granted unnecessary capabilities — running as root, privileged mode, host namespace access
- Shared secrets: credentials, API keys, and tokens are reused across environments, so compromising one compromises all
- Shared storage: a mounted volume becomes a data bridge between workloads that should be isolated
- Control plane compromise: Kubernetes API, Docker socket, or hypervisor management interface becomes the attacker's lever
- Side channels: timing attacks, cache attacks, or resource exhaustion can leak information across isolation boundaries
The most dangerous attacks target the control layer: hypervisors, container runtimes, orchestration systems, and management APIs. Compromise the orchestrator, and you compromise everything it orchestrates.
Common misconfigurations that break container isolation:
- Running containers with
--privilegedflag - Mounting the Docker socket (
/var/run/docker.sock) into containers - Running as root inside containers without user namespace remapping
- Disabling seccomp or AppArmor profiles
Key insight: isolation is only as strong as its weakest configuration. Defaults may not be secure; hardening is essential.
Real-World Context: Isolation Failures in Practice
Isolation failures are not theoretical. They happen in production:
CVE-2019-5736 (runc container escape): A vulnerability in runc, the underlying container runtime used by Docker and Kubernetes, allowed a malicious container to overwrite the host runc binary. When an administrator ran any docker/kubectl command, the compromised binary executed with host privileges. One container escape led to full host compromise.
CVE-2020-2732 (KVM hypervisor vulnerability): A flaw in the Linux KVM hypervisor allowed a guest VM to cause a denial-of-service against the host, potentially affecting all VMs on that host. Even the hardware-level isolation of VMs depends on correct hypervisor implementation.
Kubernetes misconfigurations: Security researchers regularly find Kubernetes clusters exposed to the internet with default credentials, privileged containers, or the Kubernetes API accessible without authentication. Tesla, Weight Watchers, and others have been breached through misconfigured Kubernetes.
Virtualisation and containers intersect with everything we've studied: orchestration runtimes are services (Week 6), automated deployments are scheduled (Week 7), containerised services expose network surfaces (Week 8), logs must escape compromised containers (Week 9), and container images are supply chain objects (Week 10).
The modern compromise is not "hack one server." It is "move through the layers that manage many servers."
Common thread: isolation is engineering, not magic. Every layer depends on correct implementation and configuration. The control plane is often the weakest link.
Guided Lab: Comparing Isolation Boundaries
This lab focuses on understanding the difference between VM and container isolation by examining what is actually separated and what is shared.