Security Differences Between Hardware-Level Isolation and Docker's Shared Kernel

Hardware-level isolation runs each workload in a dedicated kernel under a hypervisor, eliminating shared-kernel attack vectors that make Docker containers vulnerable to container escapes.

CubeSandbox implements a hardware-level isolation model using KVM MicroVMs that fundamentally differs from Docker's shared-kernel architecture. Understanding these security differences is critical when deploying untrusted code or multi-tenant workloads. This analysis examines the architectural distinctions, attack surface variations, and isolation guarantees based on the TencentCloud/CubeSandbox source code.

Execution Environment and Kernel Architecture

The foundational security difference lies in how each model handles the operating system kernel.

Hardware-Level Isolation (MicroVM)

In CubeSandbox, each sandbox runs a dedicated Linux kernel inside a KVM MicroVM. According to the architecture documentation in docs/architecture/overview.md, the guest kernel is completely separate from the host kernel. The hypervisor implementation in hypervisor/src/hypervisor.rs launches these MicroVMs usingRustVMM, ensuring that sandbox code executes against its own kernel image rather than the host's.

This architecture means that kernel vulnerabilities in the guest do not affect the host, and vice versa. The only attack path to the host requires hypervisor-level exploits, which present a significantly smaller attack surface than a full kernel.

Docker's Shared-Kernel Model

Docker containers share the host kernel; processes run in separate namespaces but execute the same kernel image. While namespaces provide process-level isolation, they do not create a security boundary at the kernel level. A vulnerability in the shared kernel—such as a privilege escalation bug—can be leveraged by a compromised container to execute arbitrary code on the host, creating the classic container escape scenario.

Attack Surface Comparison

The isolation model directly determines the attack vectors available to malicious code.

Hardware-level isolation restricts attackers to hypervisor-level exploits. Because the sandbox runs its own kernel, even severe kernel bugs (e.g., memory corruption vulnerabilities) remain contained within the MicroVM. The host kernel is unreachable from the guest.

Docker containers face a shared-kernel attack surface. Any container process can potentially trigger kernel bugs that affect the host, as demonstrated by historical CVEs targeting the Linux kernel's namespace handling or file system implementations. The security boundary exists only at the process scheduler level, not at the kernel level.

Network Isolation Mechanisms

Network topology represents another critical security divergence.

CubeSandbox provides per-sandbox TAP devices managed by eBPF-based CubeVS, as documented in docs/architecture/network.md. Network policies are enforced inside the kernel for each MicroVM, with no shared bridge or iptables rule explosion. This design prevents malicious containers from sniffing traffic or manipulating routing rules that could affect other workloads.

Docker typically uses a Linux bridge or overlay network shared among all containers on the host. Network policy enforcement relies on host-level iptables, which a privileged or compromised container can potentially modify or bypass, opening lateral movement avenues.

Memory and System Call Security

Memory isolation implementation reveals architectural security depth.

In CubeSandbox, memory is backed by a dedicated virtual RAM region for each MicroVM, implemented in Cubelet/storage/cubecow_engine.go. The guest cannot read or write host memory directly, and the copy-on-write snapshot engine ensures memory isolation at the hardware level. Additionally, the CubeHypervisor runs with a minimal seccomp whitelist that limits the syscalls the guest can issue, reducing the kernel surface area exposed to the sandbox.

Docker containers inherit the host's seccomp profile (typically the default "runtime/default"). While this profile can be tightened, it still runs against the same kernel instance. Any kernel bug triggered by a permitted syscall can compromise the host, and container memory is allocated from the host's process heap, making it vulnerable to kernel memory-corruption exploits.

Credential Protection and Secret Management

Secret handling demonstrates the practical security benefits of stronger isolation.

CubeSandbox injects secrets via CubeEgress (an L7 proxy) as described in docs/guide/security-proxy.md. The sandbox sees only the proxied request; credentials never reach the sandbox filesystem or memory. This prevents credential exfiltration even if the sandbox is fully compromised.

Docker containers typically receive secrets through environment variables or mounted volumes. Unless explicitly restricted with security profiles, a compromised container can exfiltrate credentials it has access to, and shared kernel access may allow memory scraping attacks against other processes.

Practical Implementation Examples

The following examples demonstrate the isolation model differences when provisioning sandboxes.

Creating a CubeSandbox (Hardware-Level Isolation)

package main

import (
    "context"
    "log"

    "github.com/tencentcloud/cubesandbox/sdk"
)

func main() {
    client := sdk.NewClient(
        sdk.WithEndpoint("http://localhost:12088"),
        sdk.WithAuthToken("YOUR_TOKEN"),
    )
    sandbox, err := client.CreateSandbox(context.TODO(),
        sdk.SandboxCreateOptions{
            TemplateID: "python-3.10",
            Resources: sdk.Resources{
                CPU:    1,
                Memory: 512, // MB
            },
        })
    if err != nil {
        log.Fatalf("failed to create sandbox: %v", err)
    }
    log.Printf("sandbox ready, ID=%s, IP=%s", sandbox.ID, sandbox.IP)
}

This Go SDK call provisions a MicroVM with dedicated kernel resources as implemented in hypervisor/src/hypervisor.rs.

Creating a Docker Container (Shared Kernel)

import docker

client = docker.from_env()
container = client.containers.run(
    "python:3.10-slim",
    command="sleep 3600",
    detach=True,
    network_mode="bridge",
    mem_limit="512m",
    cpu_quota=100000,
)
print(f"container ID={container.id}")

This Python example creates a process sharing the host kernel, relying on namespace isolation for security.

Summary

  • Hardware-level isolation provides dedicated kernel instances under KVM, eliminating shared-kernel vulnerabilities that affect Docker containers.
  • Attack surface reduction restricts malicious code to hypervisor exploits rather than the full Linux kernel surface available in container escapes.
  • Memory isolation in CubeSandbox uses dedicated virtual RAM regions (Cubelet/storage/cubecow_engine.go) instead of shared host heap allocation.
  • Network security leverages per-sandbox TAP devices and eBPF filtering (CubeVS) rather than shared bridges and iptables.
  • Secret protection via CubeEgress ensures credentials never enter the sandbox, unlike Docker's direct injection methods.

Frequently Asked Questions

What is the primary security advantage of hardware-level isolation over Docker?

Hardware-level isolation eliminates the shared kernel attack vector. Because each CubeSandbox MicroVM runs its own Linux kernel under a hypervisor, kernel vulnerabilities in the guest cannot compromise the host. Docker containers share the host kernel, meaning any kernel bug exploited by a container grants immediate host access.

How does CubeSandbox prevent container escape vulnerabilities?

CubeSandbox prevents escapes through hardware-enforced boundaries implemented in hypervisor/src/hypervisor.rs. The dedicated kernel, memory isolation via Cubelet/storage/cubecow_engine.go, and minimal seccomp whitelists create multiple security layers. Even if an attacker gains root inside the MicroVM, they remain trapped in the virtualized environment without access to host resources.

Does hardware-level isolation impact performance compared to Docker?

CubeSandbox MicroVMs are lightweight (approximately 5 MiB memory, less than 60 ms boot) and run near bare-metal speed because they avoid heavyweight virtualization layers. While Docker has negligible overhead, CubeSandbox achieves strong isolation with minimal performance cost, making it suitable for latency-sensitive workloads requiring security guarantees.

How does network isolation differ between CubeSandbox MicroVMs and Docker containers?

CubeSandbox uses per-sandbox TAP devices managed by eBPF programs in the CubeVS directory, enforcing network policies inside each MicroVM's kernel. Docker uses shared Linux bridges and host-level iptables rules. A compromised Docker container can potentially manipulate bridge configurations or iptables, while CubeSandbox's network stack is isolated from the host networking namespace.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →