Security
This page summarises what cairn isolates, what runs with extra privilege and why, and what it does not protect against. It is written for people who use or administer cairn. The audit-level detail is in three files you can read in one sitting each: cairn (supervisor, unit files, event channel, exec), cairn-jail and cairn-helper. How the pieces fit is in architecture.
The short version
- Your workload runs in a Firecracker microVM, with its own kernel. It does not share your kernel the way a container does.
- Firecracker runs as you, in a chroot built by a root-owned jail, with only the devices you could already open.
- Almost everything cairn does runs as you, with no privilege.
- Two small programs are privileged:
cairn-jail(setuid root) andcairn-helper(network capabilities). Only members of thecairngroup, and root, may use them. - The privileged programs read no environment, take no path or program from a request, and execute only fixed, compile-time paths.
What is isolated
The guest from the host. A compromised workload is inside a VM. To reach the host it needs a Firecracker escape. If it gets one, it lands in the jail: a tmpfs root holding only the Firecracker binary, the guest kernel (read-only), your machine directory at /vm (mounted nosuid,nodev,noexec) and three device nodes (/dev/kvm, /dev/net/tun, /dev/urandom). The VMM keeps Firecracker's own seccomp filter and is not given userfaultfd. The jail is bounded in size and inode count.
The jail grants nothing you do not have. cairn-jail refuses unless you can already open the host's /dev/kvm and /dev/net/tun for reading and writing. It puts the VMM in your own cgroup, so your limits apply. A jailed VMM is contained from the guest, not from you: you can still ptrace your own process.
One user from another. The jail checks that the network namespace and the machine directory belong to the calling uid, and keeps a per-user lock and a per-user machine limit (max_machines_per_uid in /etc/cairn/vmm.conf).
Networks from the host. Each network is its own user and network namespace, kept by cairn-netd. The agent's root inside it has no meaning on the host. Machines on one network reach each other only as the network allows (below); a separate network is a separate namespace. See networking.
Apps that share a network. A network is a trust domain: its members trust each other to the extent of the services they declare. A hostile image in one member gets this:
| It tries | What happens |
|---|---|
| Reach a peer on a port the peer did not declare, or on any port by the peer's machine address | Refused (a TCP reset, or ICMP admin-prohibited, rate-limited per guest) and counted. |
| Reach a peer at layer 2 with a pinned MAC or raw frames | Never delivered. |
| Send as a peer's or another app's address | Dropped by the guard. |
| See its peers' broadcasts | None are delivered. |
| Get round its egress list through a peer's address on port 80 or 443 | It reaches the peer only, which is allowed anyway. |
| Get round its egress list's DNS | DNS is still redirected to the gate. |
| Change another member's egress list or gate | Impossible: each list comes only from its own machine's attach. |
| Release another member's published port through a failed deploy | Refused before anything starts; claims are durable and a rollback releases only its own. |
| Bring back a destroyed member's name through a stale membership list | Refused by generation. |
| Reach the host or another network | Unchanged: the host's table is not touched by sharing. |
| Learn its peers' names | It can: names under internal resolve, and only names, not ports. |
| Exhaust connection tracking with peer connections | Bounded by its own network's count; the kernel's per-network maximum applies and the memory is shared with the host. |
Egress. A network can carry an egress allowlist. Then the guest can resolve only the listed names, and outbound traffic is refused in nftables except through cairn-egress, which relays TLS by SNI and HTTP by Host to addresses it resolved and checked itself. cairn-egress holds no capabilities. See networking.
Image content. An image is untrusted: it came from someone's build. It is unpacked by cairn-extract, a hardened tar extractor, and every later access to the unpacked tree is confined with RESOLVE_IN_ROOT, so a hostile archive cannot write or read outside the tree.
Guest input. Everything the guest sends is treated as untrusted: events, heartbeats, exec traffic. A guest can cause its own restarts or stops (bounded by backoff) but cannot influence what is signalled or deleted. Stop and cleanup use process identities, not anything the guest says.
cairn run's agent and your folder. The agent is untrusted and runs jailed, but what the sync brings back is a change to your files. What it can do to the host is what the sync does: create, replace or delete files inside the folder, within the scope your own Git rules set. Nothing under .git crosses, and no ignore file or Git control input is ever taken back. The host never reads the machine's Git repository: the machine's repository is built in the machine, by the image's Git, from a pack of your own objects, and nothing the agent does in it (commits, a hostile config, a replaced .git) reaches your side except as ordinary files. cairn's own Git on the host runs a closed list of commands that only read your repository, plus pack-objects (and init/commit in a scratch repository of its own, to check Git's behaviour), with every program-valued setting pinned. See run and SECURITY.md §11.
What runs privileged, and why
| Program | Privilege | Why it is needed | Blast radius if compromised |
|---|---|---|---|
cairn-jail | setuid root | The Firecracker jailer needs CAP_SYS_ADMIN, CAP_MKNOD, CAP_CHOWN, CAP_SETUID, CAP_SETGID, CAP_SYS_CHROOT, which together are root. | Root on the host. |
cairn-helper | setuid cairn-helper account, CAP_NET_ADMIN, CAP_NET_BIND_SERVICE | Veth links, the nftables table, port reservations, conntrack cleanup. | Control of the host's networking. Not file access, not kernel modules. |
Both are kept small and boring on purpose. Their dependency lists are short, unsafe is forbidden (the kernel calls with no safe wrapper live in the audited cairn-ns), and the request is read from stdin only. No request names a uid, gid, path, program or argument. The caller is whoever getuid() says. Neither reads its environment or searches PATH. make audit-jail checks that the jail has exactly one place that executes a program.
The helper manages only what is its own: cv-* links, table inet cairn, and two Docker-compatibility rules it records. It does not touch other interfaces, tables or chains, write files outside /var/lib/cairn/net, or signal other processes.
The cairn group
The privileged programs admit root and members of the cairn group. Membership is read from /etc/group and /etc/passwd on every call, so it takes effect immediately and revocation is immediate:
sudo usermod -aG cairn alice # alice may use cairn now
sudo gpasswd -d alice cairn # and now she may notA user whose primary group is cairn is refused, because gpasswd -d cannot revoke that. cairn access shows your own status and the reason for a refusal; see getting-started.
Root-owned policy files /etc/cairn/net.conf and /etc/cairn/vmm.conf set the limits and who may use privileged ports. They are loaded once without following links and refused unless root owns them and nobody else can write them. Check them with cairn admin check-config (see configuration).
Exec and console
cairn exec and cairn console give a shell in the guest as any user the image has, including root. The gate is the permission on the machine's v.sock: yours, mode 0700, inside a 0700 tree. That is the same trust as the VMM's own api.sock, which can already stop the VM. The client checks that the socket is served by your own Firecracker. In the guest, the exec agent accepts only connections from the host. No new privilege is added on the host.
What cairn does not protect against
- A compromised user account. It can edit its own unit files, records and machines. The protection is against the guest and the VMM, not against you.
- Anyone who compromises
cairn-jailis root; anyone who compromisescairn-helpercontrols host networking. Hence the group gate and the small code. - A custom kernel's ELF parse. Firecracker parses a custom kernel inside the jail but before its seccomp filter is installed, so the jail's boundaries contain that step. Use only kernels you trust. See kernels.
- Verified kernel versus the VMM's later open. Another process running as you could replace a kernel file between cairn's verification and Firecracker's open.
- Logs grow without limit. A noisy guest can fill the filesystem it shares with your other services.
truncate -s 0clears a live log safely. - The memory balloon is not a limit. Its statistics come from the guest.
mem_size_mibis the bound. - A dead network agent is repaired by
cairn startorcairn net up, not automatically. - Core dumps follow the host's
kernel.core_pattern. - A root who replaces a root-owned binary in a root-owned directory is outside the model.
Reading further
Each of the three SECURITY.md files separates "does not" (the code does not do this, and a review and a test say so) from "cannot" (the kernel enforces it). The difference matters: a "does not" is a promise a bug can break.