# Threat model

This page says what Hermitbox defends, against whom, and where each defence lives in the code.
It is for reviewers, human or automated, judging whether a change weakens Hermitbox, and for
anyone deciding which tier to trust with which work. The [security model](https://docs.hermitbox.dev/v0.3.2/concepts/security.md)
is the short version.

Hermitbox isolates untrusted sandbox workloads from the host, from each other, and from fleet
credentials. The sections below define the adversaries, trust boundaries, invariants and accepted
limits on `main`. Each mechanism names the file that implements it. Any change that moves a
boundary updates this page in the same pull request, and says why.

## What Hermitbox protects

- **The host from its sandboxes.** A workload can't read or write the host's files, credentials
  or other sandboxes' data, and can't reach the host's own services. It can't take more memory,
  CPU or processes than the host admits for it.
- **Sandboxes from each other.** One tenant's sandbox can't read, signal, dial or impersonate
  another's, through the host, the edge or a shared port.
- **A sandbox's data, snapshots and secrets.** Data is never copied out through a link, and a
  restore never damages the current data. A snapshot is never lost as the only copy. A secret
  value never appears in a record, label, log, view or error.
- **The fleet's control.** Only an enrolled node with its own key talks to control, and only
  control calls a node. A copy of a sandbox never runs twice. A node runs only a signed
  `hermitboxd`.
- **The public API and edge.** A credential reaches only what it was issued for, and only the
  edge's fronts face the internet.

## Adversaries

- **Code inside a sandbox.** Assume it is fully hostile, including root inside its container or
  guest where the tier gives that. It controls everything in its data directory, its image, its
  guest kernel on the `vm` tier, and whatever its agent reports about it.
- **Another tenant's sandbox** on the same node or elsewhere in the fleet.
- **A network attacker** between nodes, control, edge, object store and clients.
- **The holder of a leaked credential** of limited scope: a project API key, a sandbox
  capability, a file URL, a presigned URL, an enrollment token or the edge token.
- **A malicious or tampered release or upstream artifact:** a daemon offered by a compromised
  control plane, a substituted bundle, an image a tenant chose.
- **A request trying to relax the host's policy:** a spec or public request asking for less
  isolation, another image, another user, or a capability the host doesn't give.

Out of scope: the host's own root, the operator and whoever holds the operator token or the fleet
CA key, physical access, and bugs in the kernel itself. The exception is where Hermitbox chooses a
tier because of them (the `vm` tier's own kernel; [tiers.md](https://docs.hermitbox.dev/v0.3.2/reference/tiers.md) on choosing one).

## Trust boundaries

### Sandbox and host

What crosses: exec, files, logs, stats, port forwarding and the agent's own reports; the data
directory, written by the workload and read by `hermitboxd`; images and specs. Host policy lives in
the host's configuration, not in requests ([`src/config.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/config.rs)), and each
backend fills every isolation setting from it.

| Tier | What enforces the boundary |
| --- | --- |
| `container` | All capabilities dropped, no-new-privileges, never privileged, private IPC, PID limit, Docker restart policy `no` ([`src/runtime/docker/container.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/docker/container.rs)); images only from host `allowed_images` prefixes ([`src/config/validate.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/config/validate.rs)); the root-installed nftables table ([`src/isolation.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/isolation.rs)) |
| `gvisor` | The container tier's settings under the engine's pinned `runsc` ([`src/runtime/docker/gvisor.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/docker/gvisor.rs), [`deploy/gvisor.json`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/deploy/gvisor.json)); never served by runc |
| `process` | Landlock ABI 3 filesystem policy, required in full ([`agent/src/process_policy.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/agent/src/process_policy.rs)); a seccomp filter denying mount, ptrace, bpf, namespace creation, keyrings, io_uring and UID or capability changes ([`agent/src/process_policy/filter.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/agent/src/process_policy/filter.rs)); rlimits; a uid pool where the host allows it ([`src/runtime/process/journal.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/process/journal.rs)); namespaces through an unmodified bubblewrap where the host allows them ([`src/runtime/process/namespaces.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/process/namespaces.rs)); a cgroup of its own where controllers are delegated ([`src/runtime/process/resources.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/process/resources.rs)); eBPF network policy where the host allows it ([`src/bpf.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/bpf.rs)) |
| `wasm` | A virtual kernel in a pinned agentOS sidecar, dropped to its own worker uid with no-new-privileges; only the explicit data mount enters the guest ([`src/runtime/wasm.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/wasm.rs), [`src/runtime/wasm/boot.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/wasm/boot.rs)) |
| `vm` | A Firecracker guest with its own kernel under KVM; the monitor confined by Landlock and seccomp as an ordinary user, or by the unchanged jailer with a uid of its own per VM as root ([`agent/src/vm_monitor.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/agent/src/vm_monitor.rs), [`src/runtime/vm/machine.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/vm/machine.rs)); root VM authority only in the separate worker service ([`src/runtime/vm/worker.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/vm/worker.rs)) |

Never trusted from the sandbox side:

- **Its data directory.** Every walk `hermitboxd` or the agent makes is descriptor-relative with
  `O_NOFOLLOW` at each step, refuses special files, and never leaves the directory
  ([`src/tree.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/tree.rs), [`agent/src/files.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/agent/src/files.rs),
  [`src/tarball.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/tarball.rs)).
- **Its guest kernel.** On the `vm` tier the host's packet helper decides every flow again, so a
  guest that drops its own rules gains nothing ([`src/runtime/vm/network.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/vm/network.rs)).
  Disks a guest wrote are checked and repaired only by confined tools on a staged copy
  ([`src/runtime/vm/disk.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/vm/disk.rs)).
- **Its claims about who owns a socket.** Before sending any bytes, the process tier's port proxy
  proves from kernel evidence that the server socket belongs to the supervisor's tree. A shared
  UID or matching port is never proof ([`agent/src/process_peer.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/agent/src/process_peer.rs)).
- **Its private runtime state.** Process journals and agent signing keys live outside every data
  grant, snapshot and export ([`src/runtime/process/journal.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/process/journal.rs),
  [`src/manager/agent_keys.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/manager/agent_keys.rs)).

### Sandbox and sandbox

- **Containers** are kept from each other's addresses by the bridge's inter-container switch, and
  from each other's published ports by the nftables table ([`src/isolation.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/isolation.rs)).
  They share the host kernel and can share a numeric uid ([host-capabilities.md](https://docs.hermitbox.dev/v0.3.2/reference/host-capabilities.md)).
- **Process sandboxes** can't read each other's data or `/proc` (Landlock). With separate UIDs they
  can't signal each other. With kernel network policy, a host address reaches only the sandbox's
  own sockets ([bpf.md](https://docs.hermitbox.dev/v0.3.2/reference/bpf.md)); without it they share the host's network and must be mutually
  trusted ([process-tier.md](https://docs.hermitbox.dev/v0.3.2/reference/process-tier.md)).
- **Wasm sandboxes** share one sidecar, which is a shared fault domain ([agentos.md](https://docs.hermitbox.dev/v0.3.2/integrations/agentos.md)).
- **VMs** each have their own kernel; as root each monitor has a uid pair no other VM holds.
- **Credentials** are bound to one sandbox: a capability names its sandbox and epoch
  ([`agent/src/auth.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/agent/src/auth.rs)); a project key's routes answer 404 for another
  project's ids ([api.md](https://docs.hermitbox.dev/v0.3.2/reference/api.md)). A fork gets its own agent key, and a fork with memory reseeds
  its random generator from host entropy ([vm.md](https://docs.hermitbox.dev/v0.3.2/guides/virtual-machines.md)).

### Sandbox and network

- **Egress.** `network: none` is the boundary on every tier. Hostname policy (`egress`) runs only
  through gateways `hermitboxd` owns:
  - a dedicated bridge and root firewall for containers
    ([`src/runtime/docker/egress.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/docker/egress.rs));
  - eBPF redirects for process sandboxes
    ([`src/runtime/process/network.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/process/network.rs));
  - guest rules plus host gateways on the `vm` tier.

  Address rules (`egressAddresses`) are the process tier's, with kernel policy. A tier or node that
  doesn't announce a policy refuses it by name; `gvisor` and `wasm` refuse hostname egress
  ([tiers.md](https://docs.hermitbox.dev/v0.3.2/reference/tiers.md)).
- **Gateways** resolve once, refuse a name if any answer is non-public, an address of this host,
  or one the sandbox's rules refuse, and dial that resolution only
  ([`src/runtime/egress/gateway.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/egress/gateway.rs)).
- **Always refused:** this host's own addresses, link-local and cloud metadata addresses, and
  other nodes' sandbox and API ports on private addresses ([`src/isolation.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/isolation.rs),
  [bpf.md](https://docs.hermitbox.dev/v0.3.2/reference/bpf.md), [vm.md](https://docs.hermitbox.dev/v0.3.2/guides/virtual-machines.md)).
- **Outbound on a sandbox's behalf.** Agent URL transfers and control's webhooks pin a public DNS
  answer, refuse private ones and redirects, and keep TLS verification
  ([`agent/src/transfer_target.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/agent/src/transfer_target.rs),
  [`control/src/webhook-target.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/webhook-target.ts)).
- **Ingress** reaches a sandbox only on ports `hermitboxd` published for it, from the edge or control.

Never trusted from the network side: DNS answers, proxy variables in the sandbox, raw IP targets,
a guest's own firewall.

### Node and control

- **Mutual TLS.** The node API and every fleet link are TLS 1.3 only, with no 0-RTT and hybrid
  `X25519MLKEM768` as the sole key-exchange group ([`src/tls.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/tls.rs),
  [`control/src/tls.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/tls.ts)). A client certificate must chain to
  the host's `client_ca`, carry `clientAuth` and name an allowed client
  ([`src/api/tls.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/api/tls.rs)). A node's key is made on the node and never sent
  ([`src/fleet/enroll.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/fleet/enroll.rs), [`src/fleet/identity.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/fleet/identity.rs)).
  Joining trusts the fleet CA only once it matches the token's hash
  ([`src/fleet/token.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/fleet/token.rs), [`src/cli/join.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/cli/join.rs)), and
  enrollment or renewal naming another CA is refused. Control pins each node's current client
  certificate and uses session ids and sequence numbers to catch two hosts sharing one identity
  ([`control/src/node-endpoint.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/node-endpoint.ts),
  [`control/src/registry.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/registry.ts)).
- **Epochs and fencing.** Control raises a placement's epoch only by compare-and-set
  ([`control/src/ledger.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/ledger.ts)). Every mutating node verb checks it with
  `check_epoch` ([`src/manager/error.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/manager/error.rs)):
  - start, suspend, exec, export, snapshot and restore need exactly the copy's epoch;
  - stop, kill and delete accept it or newer;
  - a superseded copy refuses everything except stop, kill and delete.

  A fence stops a copy, keeps its data, and never starts it again
  ([`src/manager/fence.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/manager/fence.rs)). A move fills the new copy before it
  fences the old one ([`control/src/rehoming.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/rehoming.ts)), and the edge
  closes connections from older epochs ([`edge/src/routes.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/edge/src/routes.ts)).
- **Execution lease.** A node restarts or resumes on its own only while its last heartbeat's lease
  lasts ([`src/manager/fleet.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/manager/fleet.rs), [`src/manager/restarts.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/manager/restarts.rs)).
  No timer declares a host lost: an operator confirms it after fencing it outside Hermitbox
  ([operations.md](https://docs.hermitbox.dev/v0.3.2/guides/operate.md)). The opt-in object-store lease adds a watchdog that
  freezes (`cgroup.freeze`) and kills a leased cgroup when its term ends. Control then displaces a
  copy only after winning a conditional fence in the store
  ([`src/store_lease/guard.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/store_lease/guard.rs),
  [`control/src/store-lease.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/store-lease.ts), [store-lease.md](https://docs.hermitbox.dev/v0.3.2/reference/store-lease.md)).
- **Never trusted from control:** a request for weaker isolation than host policy, an image outside
  `allowed_images`, an unannounced field (refused with `422`), or an upgrade that fails the checks
  below. Control decides what runs; it can't decide how weakly.
- **Never trusted from a node:** a heartbeat for another node, a certificate that isn't that node's
  pinned one, or observations for a placement it doesn't hold ([protocol.md](https://docs.hermitbox.dev/v0.3.2/reference/protocol.md)).

### Edge, sandbox and client

- **Edge to control** uses the private `/edge/v1` with a bearer edge token compared in constant
  time ([`control/src/edge-api.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/edge-api.ts)).
- **Sandbox capabilities** are `pa1.` tokens the node signs with ML-DSA-65 (FIPS 204). They name
  one sandbox, one epoch and a scope (`sandbox`, `routes` or `file`). They live at most five
  minutes, with 30 seconds of clock skew ([`agent/src/auth.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/agent/src/auth.rs)). The edge
  verifies them offline before any wake ([`edge/src/sandbox-token.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/edge/src/sandbox-token.ts),
  [`edge/src/sandbox-proxy.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/edge/src/sandbox-proxy.ts)). A route-only capability can list
  port assignments but can't run commands or read data; a file URL is one path and one method for
  at most a minute ([agent.md](https://docs.hermitbox.dev/v0.3.2/reference/sandbox-agent.md)). The project key never reaches a sandbox.
- **Client to API.** A project key is a bearer key stored only as its SHA-256
  ([`control/src/keys.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/keys.ts)), and reaches only its own project. The operator
  API listens apart, on loopback by default, behind the operator token
  ([`control/src/operator-api.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/operator-api.ts),
  [`control/src/config.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/config.ts)). Authenticated requests are audited before
  they change state, without headers, bodies or query strings ([`control/src/audit.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/audit.ts)).
- **The edge** binds its public fronts on purpose ([`edge/src/config.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/edge/src/config.ts));
  its metrics stay on loopback. It terminates TLS only for agent and exposed-port hostnames;
  ordinary TLS routes pass through untouched.

### Releases, joins and bundles

- **Upgrades** ([`src/upgrade/trust.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/upgrade/trust.rs)). Before anything is
  downloaded, a node checks three things:
  - the offered version is `MAJOR.MINOR.PATCH` and no older than its own;
  - the offer carries an ML-DSA-65 signature (FIPS 204), by one of the public keys compiled in from
    [`deploy/release-keys.pem`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/deploy/release-keys.pem) (a release key and a recovery key);
  - the signature covers exactly `hermitboxd release`, the version and the lowercase sha256, one
    per line.

  It then keeps the download only if its sha256 matches and it prints the offered version. It
  rolls back if the new binary doesn't reconcile and beat in time
  ([`src/upgrade.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/upgrade.rs)). Only a debug build also takes the key
  `HERMITBOXD_TEST_RELEASE_KEY` names. A control plane or its fleet CA can pass a signature on but
  can't make one.
- **Joins and installs.** The CLI verifies the fleet bootstrap and the server asset manifest with
  the same compiled keys; the fleet CA authenticates transport only
  ([`cli/src/join-trust.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/cli/src/join-trust.ts), [`cli/src/bundle-trust.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/cli/src/bundle-trust.ts)).
  Preview builds carry a separate identity that can't replace production keys ([install.md](https://docs.hermitbox.dev/v0.3.2/get-started/install.md)).
- **Pinned upstream.** The VM descriptor comes from the signed installation, never a workload. It
  pins its bundle by size, SHA-256 and a per-file inventory checked before any program runs
  ([`src/runtime/vm/policy.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/vm/policy.rs), [`src/runtime/vm/bundle.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/vm/bundle.rs)).
  The agentOS distribution is checksum-pinned ([`src/config/wasm.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/config/wasm.rs)); gVisor
  and bubblewrap are pinned releases; Rust dependencies are locked and checked by
  [`deny.toml`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/deny.toml).
- **Tenant images** are untrusted input: allowed only by host prefixes, and on the `vm` tier each
  layer is checked against its digest and converted by confined tools ([vm.md](https://docs.hermitbox.dev/v0.3.2/guides/virtual-machines.md)).

### Storage and object store

- Exports and snapshots go to presigned URLs, used once and never logged or stored; their query
  strings are redacted wherever they are printed ([`src/protocol/transfer.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/protocol/transfer.rs)).
- A restore is checked against the sha256 control recorded, unpacked with links, devices and
  traversal refused, assembled in `data.restoring/` and swapped in whole
  ([`src/store/restore.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/store/restore.rs), [`src/tarball.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/tarball.rs)).
- The store lease trusts the store's `Date` and linearizable conditional writes, and nothing else
  ([store-lease.md](https://docs.hermitbox.dev/v0.3.2/reference/store-lease.md)). Archive contents are never trusted.

## Invariants a change must keep

1. **A request never relaxes the host's hardening.** Capabilities, mounts, images, users, network
   rules and limits come from host configuration ([`src/config.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/config.rs)); a request
   can't remove a deployment requirement ([`control/src/public-model.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/public-model.ts)).
2. **A requested isolation or capability is given or refused, never weakened in silence.** A named
   tier is never substituted, and a mutation is never retried on another tier
   ([`src/runtime/router.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/runtime/router.rs), [`src/manager/tiers.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/manager/tiers.rs)).
   Required features are checked on create and on an unchanged wake
   ([`control/src/workload-capabilities.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/workload-capabilities.ts)).
   Unannounced guarantees read false ([`control/src/guarantees.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/guarantees.ts)).
3. **No walk follows a link** out of a sandbox's data ([`src/tree.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/tree.rs)).
4. **No secret value in a record, label, log, view or error.** Secret values have no `Debug` and
   never enter the spec digest ([`src/protocol/spec.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/protocol/spec.rs)). Control seals
   them at rest ([`control/src/sealed-secrets.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/sealed-secrets.ts)). Signing
   keys stay out of records and responses ([`agent/src/auth.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/agent/src/auth.rs)).
5. **No listener on a public address unless it is meant to be.** An unauthenticated listener can
   bind only loopback or a private address (`private_or_loopback` in [`src/config.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/config.rs)).
   Workload ports are private; the edge's fronts are the intended public ones.
6. **Certificate checks are never loosened.** mTLS stays TLS 1.3 with client certificates, and no
   HTTPS call turns off certificate or hostname verification. The one unverified fetch, the fleet
   CA at join, is checked against the token's hash before anything uses it.
7. **A mutating verb checks the epoch** through `check_epoch`.
8. **A restore never touches current data before it is whole.**
9. **A snapshot's deletion never drops the only copy.** Rest uploads before it releases local data,
   and keeps it if the upload fails ([`control/src/sandboxes.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/sandboxes.ts)).
   A node's local snapshots upload before its copy is deleted
   ([`control/src/transfers.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/transfers.ts)). A template's snapshot can't be
   deleted while a version uses it.
10. **Verbs that aren't safe to repeat aren't retried.** Node verbs are idempotent and exec takes an
    `Idempotency-Key` ([`src/manager/exec.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/manager/exec.rs)). An exec with an uncertain
    outcome is never replayed ([`control/src/operations.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/operations.ts)). A
    container start whose answer timed out is inspected, never repeated ([tiers.md](https://docs.hermitbox.dev/v0.3.2/reference/tiers.md)).
11. **Copyleft code is never linked.** `deny.toml` admits permissive licences; GPL and LGPL programs
    run as separate executables; every licence is in [decisions.md](https://docs.hermitbox.dev/v0.3.2/decisions.md) before use.
12. **Only signed `hermitboxd` runs on a node,** and never an older one (`src/upgrade/trust.rs`).

## Known limits and accepted risks

- **The process tier shares the host kernel.** A kernel escape from a process sandbox escapes its
  enclosing container. In the plain mode it has no PID, mount or network namespace.
- **Shared-UID process sandboxes** (an ordinary-user install) share per-UID limits and can signal
  each other and same-user services. Use them only for mutually trusted work; creation can require
  `separate-users`.
- **Without kernel network policy,** Internet-enabled process sandboxes can dial the host's and
  neighbours' listeners, separate UIDs or not. An Internet-enabled process sandbox never has
  `private-network`.
- **Without delegated cgroups,** process memory is a sampled budget, not a hard cap.
- **Wasm** shares one sidecar with no per-VM CPU rate; host service limits bound it as a whole.
- **Containers** share the host kernel; rootless Docker is refused at `data-owner-mapping`; Podman
  has no host firewall.
- **The `vm` tier** needs x86_64 and KVM that `hermitboxd`'s user can open. Elsewhere it is off and a
  `vm` request is refused. A move between two VM nodes is untested ([vm.md](https://docs.hermitbox.dev/v0.3.2/guides/virtual-machines.md)).
- **The store lease** is an opt-in prototype with stated assumptions, not a hard real-time fence.
  Without it, failover waits for an operator's confirmed fence.
- **A compromised fleet CA** cuts nodes off until each re-enrolls; dual CA trust isn't implemented.
- **The edge sees agent and exposed-port traffic in clear,** since it terminates that TLS.
- **Not post-quantum today:**
  - public WebPKI certificates: ECDSA P-384 via ACME, until public CAs and browsers support ML-DSA;
  - SSH host and user keys: ECDSA P-384 ([`agent/src/tools/ssh.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/agent/src/tools/ssh.rs)),
    until OpenSSH supports ML-DSA keys;
  - public HTTPS fronts ([`edge/src/sandbox-proxy.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/edge/src/sandbox-proxy.ts),
    [`cli/src/up-acme-config.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/cli/src/up-acme-config.ts)) allow `P-384` as a classical
    fallback for older clients;
  - outbound clients to third-party hosts keep legacy TLS 1.3 curves behind `X25519MLKEM768` and
    `P-384`, for external registries that negotiate neither.

  These are post-quantum: release, bundle, join, sandbox capability and fleet CA, node and client
  certificates are ML-DSA-65 (FIPS 204). Every fleet and node TLS 1.3 link requires hybrid
  `X25519MLKEM768` and `ML-DSA-65` alone ([`src/tls.rs`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/src/tls.rs),
  [`control/src/tls.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/tls.ts), [`control/src/ca.ts`](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/control/src/ca.ts)).
  Sandbox SSH requires hybrid post-quantum key exchange and refuses classical-only KEX:
  `mlkem768x25519-sha256` on OpenSSH 9.9+, or `sntrup761x25519-sha512@openssh.com` on OpenSSH
  9.0–9.8.

## Report a vulnerability

Report a weakness privately, as [SECURITY.md](https://github.com/hermitbox/hermitbox/blob/cdd62e6c07e07c2b649b726729b4d8da6b25a737/SECURITY.md) says. Don't open a public issue.
