# Security model

Hermitbox treats code in a sandbox as hostile. It keeps that code away from the host, from other
sandboxes and from the keys that run the fleet, at the strength of the tier you choose.

| Boundary | What holds it | Where it is weaker |
| --- | --- | --- |
| Sandbox and host | The tier's isolation, with policy from the host's configuration | `process` and `container` share the host's kernel |
| Sandbox and sandbox | Per-tier separation; credentials bound to one sandbox | Shared-UID process sandboxes can signal each other; wasm sandboxes share one sidecar |
| Sandbox and network | `network: 'none'` on every tier; egress only through gateways the node owns | Without kernel network policy, internet-enabled process sandboxes can reach host listeners |
| Client and API | A project key reaches only its project; control stores only its SHA-256 | The edge sees agent and exposed-port traffic in clear, since it terminates that TLS |
| Control and node | Mutual TLS 1.3, and an epoch on every change | The key exchange is classical |
| Releases | ML-DSA-65 signatures checked before a binary runs | — |

## What Hermitbox trusts

Hermitbox trusts the host's root and the operator, the operator token, the fleet's certificate
authority, signed releases, and the Linux kernel. Kernel bugs are outside the model, except that
the `vm` tier gives each sandbox a kernel of its own.

It never trusts anything from inside a sandbox: the data directory, a guest kernel, or what the
agent reports. Every walk of a data directory refuses links and special files. It never trusts DNS
answers, proxy settings in a sandbox, or images beyond the host's allowed prefixes.

## Host policy wins

Capabilities, mounts, images, users, network rules and limits come from the host's configuration,
never from a request. Control decides what runs, but it can't decide how weakly: a node refuses
weaker isolation than its policy, an image outside `allowed_images`, and any field it hasn't
announced.

A request that names a tier or a guarantee gets it, or a refusal that names what is missing.
[Isolation tiers](https://docs.hermitbox.dev/v0.2.4/concepts/isolation.md) shows how.

## Where keys live

Hermitbox's own keys never enter a sandbox. The project key stays with your client: a request to a
sandbox's agent carries a capability for that sandbox alone, valid for at most five minutes.

| Key | Where it lives |
| --- | --- |
| Project API key | Your client's `client.json` (mode 0600) or environment; control keeps only its SHA-256 |
| Agent signing key | One per sandbox, in the node's private state, outside data, snapshots and exports |
| Node identity key | Made on the node and never sent; root-only on a server |
| Fleet certificate authority | Control |
| Release signing key | The release workflow's protected environment; nodes and the CLI hold only the public keys, built in |
| Secret-sealing keys | Control's environment |

Secrets you pass at creation (`secrets`) are the one exception, by design: they reach the sandbox
you made them for. Control seals them at rest with AES-256-GCM, and they never appear in a view, an
event, a log or a record's digest. A `vm` guest receives them over vsock into memory, never onto a
disk.

## Post-quantum keys

| Use | Algorithm | Post-quantum |
| --- | --- | --- |
| Release, join bootstrap, host bundle and server manifest signatures | ML-DSA-65 (FIPS 204) | Yes |
| Node and control mutual TLS key exchange | X25519 or NIST curves (rustls with ring) | No |
| Fleet and node certificates | ECDSA P-256 | No |
| Sandbox capabilities | Ed25519 | No |
| SSH client and host keys | Ed25519, short-lived | No |
| Public API certificates | Public WebPKI | No |
| Secrets at rest in control | AES-256-GCM, symmetric | Not a public-key scheme |

A node checks every release before it downloads it: the version must be no older than its own, and
the offer must carry an ML-DSA-65 signature by a release or recovery key compiled into the daemon.
Control or its certificate authority can pass a signature on, but can't make one.

## Known limits

- **Process sandboxes share the host's kernel.** A kernel escape from one escapes its host or
  enclosing container. In the plain mode it has no PID, mount or network namespace.
- **An ordinary user's process sandboxes share that user.** They share per-user limits and can
  signal each other. Use them for work you trust, or require `separate-users`.
- **Without delegated cgroups,** process memory is a sampled budget, not a hard cap.
- **Wasm sandboxes share one sidecar,** with no per-sandbox CPU rate.
- **Containers share the host's kernel,** and Podman has no host firewall.
- **Failover waits for an operator.** No timer declares a host lost, so a lost host's sandboxes
  stay down until someone fences it and confirms.
- **A compromised fleet certificate authority** cuts every node off until each one re-enrolls.

## Next steps

- [Threat model](https://docs.hermitbox.dev/v0.2.4/reference/threat-model.md): adversaries, boundaries and the file behind each one.
- [Process isolation](https://docs.hermitbox.dev/v0.2.4/reference/process-tier.md): the process tier's two modes and its limits.
- [Kernel network policy for process sandboxes](https://docs.hermitbox.dev/v0.2.4/reference/bpf.md): egress in the kernel.
