Skip to content

safekeys/deployment-packaging [built] ​

Reproducible, hardened packaging so Safekeys can run on a real host: container images for the control plane and sidecar, a production Compose file, and systemd units that carry the OS isolation the architecture promises. Production refuses every development shortcut — dev-mode OpenBao, a hardcoded root token, an ad-hoc signing seed, and the insecure local keystore.

Status: built

Why this exists ​

The software MVP works end to end, but "works on the author's laptop" and "safe to run on a VPS" are different claims. Deployment packaging closes the gap without touching the agent-facing protocol: the token and folder formats do not change, only how the authority and the sidecar are built, confined, and started. It is also where the architecture's process-isolation promise stops being prose and becomes enforceable configuration — the sidecar's separate OS user, seccomp-style system-call filtering, and AppArmor confinement land here, not in application code.

The guiding rule is deny-by-default applied to operations: a production unit must be unable to select a development key path even by accident, and a hardening regression must fail a test rather than pass silently.

Design decisions ​

systemd-single-vm-first [accepted] ​

Decision: Ship systemd units plus a production Compose file targeting a single hardened VM as the reference deployment; defer Kubernetes manifests.

Rationale: The system map's own footprint is "2–3 small VMs or one small Kubernetes namespace", and the sidecar's trust boundary is the host, which systemd expresses directly. Adding a cluster orchestrator early would multiply configuration surface without adding a security property, and the agent-facing interface is unaffected either way, so Kubernetes can land later behind the same images and units.

Alternatives considered:

  • Kubernetes manifests now — rejected: No cluster exists to justify them, and network policies and pod security contexts would duplicate the host-level confinement that is the actual isolation mechanism.

os-isolation-via-systemd [accepted] ​

Decision: Fold the sidecar's OS isolation into the systemd unit's hardening directives, with an AppArmor profile where the host supports it, rather than deferring it as separate work.

Rationale: The system map already specifies seccomp/AppArmor confinement and a separate user; the unit is exactly where those are expressed and where they can be asserted by a test. Leaving it out would ship a deployment whose stated guarantee the artifact does not enforce.

socket-shared-group [accepted] ​

Decision: Change the sidecar socket from 0600 to group-access (sidecar user plus a dedicated shared group, group-only mode) so agent processes running as a distinct user can connect.

Rationale: The separate-os-user decision requires agents to be a different user from the sidecar, but a 0600 socket is reachable only by the sidecar's own user — the two are contradictory, and today it works only because development runs everything as one account. A narrow shared group restores the intended least privilege: agents may connect, nothing else local may. This refines the separate-user decision rather than reversing it.

publish-by-digest [accepted] ​

Decision: Publish CI-built images to a registry and have production pin them by digest.

Rationale: A host that builds from source runs whatever that host compiled that day; a digest pin makes the running artefact identical to the tested one and gives rollback without a rebuild. Local Dockerfiles still build without any registry, so contributors are unaffected.

signing-key-holding-pattern [accepted] ​

Decision: Deployment provisions the Ed25519 signing seed as a root-owned credential delivered to the control plane only; HSM or secure-element custody remains the Phase 1 target.

Rationale: The key-custody-hsm ADR requires HSM backing from Phase 1 and forbids a bare key file in production as the end state. Hardware is not yet built, so this flow makes the interim explicit, auditable, and never agent-adjacent instead of pretending the problem is solved.

credentials-as-files [accepted] ​

Decision: Every credential is resolved from a file when a *_FILE variable is set, falling back to the environment only otherwise; the production profile refuses the environment path outright for the signing key and the key-store token.

Rationale: Environment variables are readable from /proc/<pid>/environ, appear in container inspect output, and are inherited by every child process the sidecar spawns for injection. Since the deployment already has a file-based mechanism (systemd LoadCredential, Compose secrets), making files the preferred source costs nothing and removes a class of exposure that would otherwise be inherited by consumer processes. The production profile makes the preference enforceable rather than advisory, so the convention cannot be forgotten on a real host.

How it works ​

Build the service images (build-images) ​

Multi-stage Dockerfiles produce minimal, non-root images for the control plane and the sidecar.

  1. Setup — A builder stage compiles a static, CGO-free Go binary for each service; a runtime stage copies only the binary and CA certificates.
  2. Setup — Each image declares a fixed non-root UID/GID, a read-only-friendly layout, and no shell or package manager in the runtime layer.
  3. Validate — The build asserts that no image layer contains a signing key, KEK, API key, or secret.
  4. Observe — Local images are tagged for Compose; CI publishes them for a real host.

Publish images by digest (publish-images) ​

CI builds and pushes the images so a host runs exactly what was tested.

  1. Send — CI builds both images from the committed Dockerfiles.
  2. Record — Images are pushed to a registry and referenced by immutable digest, never a moving tag.
  3. Validate — The deploy manifest pins the digest, so a pull cannot silently change the artefact.
  4. Observe — A previous digest can be re-run for rollback without rebuilding.

Deploy to a single hardened VM (deploy-single-vm) ​

A reference install on one host — users, directories, secrets, and start order.

  1. Setup — The install creates a dedicated sidecar OS user distinct from any agent user, plus a shared group whose sole purpose is granting access to the sidecar socket.
  2. Setup — Secrets (control-plane signing seed, API key, OpenBao token) are placed as root-owned 0600 material and delivered to services as systemd credentials or Compose secrets.
  3. Setup — systemd units start the key store, then the control plane, then the sidecar, with dependency ordering and restart policy expressed in the units themselves.
  4. Validate — The units carry the confinement directives and pass the asserted hardening threshold.
  5. Observe — An agent process running as its own user, in the shared group, resolves a token through the socket; no other local user can connect.

Provision a production key store (provision-prod-keystore) ​

OpenBao runs as a persistent, sealed-at-rest server — not the in-memory dev server.

  1. Setup — OpenBao is configured for persistent storage with TLS, and a real init produces sealed unseal shares rather than a fixed root token.
  2. Setup — The transit engine is enabled and the KEK is created; the KEK never leaves the store.
  3. Authenticate — The control plane and sidecar receive narrowly scoped tokens limited to the transit operations they need, not the root token.
  4. Observe — A missing or sealed key store denies resolution rather than falling back to a local KEK.

Provision the token signing key (provision-signing-key) ​

The Ed25519 signing seed is a root-only credential until HSM custody lands in Phase 1.

  1. Setup — An operator generates an Ed25519 seed and installs it as a root-owned 0600 credential on the control-plane host, never in a shell profile, image layer, or Compose environment block.
  2. Setup — The unit loads the seed as a systemd credential or Compose secret and exposes it only to the control-plane process.
  3. Validate — The sidecar never receives the seed; it holds public keys only.
  4. Observe — HSM or secure-element custody remains the Phase 1 target; this flow is the explicit, auditable holding pattern, not a replacement for it.