[repo] Legatus v0.1: protocol v1, enrollment, mTLS, the signature check, the Linux target #1

Manually merged
mnovak merged 9 commits from feature/v0.1 into main 2026-11-17 12:36:06 +01:00
Owner

Legatus v0.1 foundations (Fabrica docs/32_coherence.md, T3a): protocol v1, enrollment, mTLS, the signature check, and the Linux (systemd) target.

What

  • legatus-protocol (pure): EnrollmentCode (lgt1-…: server, root SHA-256, 128-bit secret, checksum), EnrollmentBook (single use, digest only), messages (enroll, hello, job, report, renew; strict, bounded), JobGuard (expired, future, too long, replayed), Registry (current/pending serial, revoked), verify_release + check_artifact (minisign by a pinned team key over the exact manifest bytes; team, app, version, artifact must match the job; size and SHA-256), check_entry (archive paths).
  • legatus-linux: release dirs, current switched by symlink + rename(2), systemctl restart, health (unit active and a local URL, twice in a row), auto rollback, pruning, hostile-tar unpacking.
  • legatus: TLS that trusts only the pinned Domi root (by hash at enrollment, then the stored root), mTLS with the agent's own key, a small bounded HTTP/1.1 client, enroll, the job loop, renewal, CLI; install/install.sh; tests/linux (real systemd in a container).

Tests (first, 58 on Windows + 13 on a Linux kernel): protocol 32 (enrollment 8, certificates 6, release 9, jobs 9); linux 13 (unpack 5 everywhere; switch/rollback 8 Linux-only, run on Linux 6.6 in the x86_64 emulator, systemd faked); agent 21 (pipeline 9, end to end over real TLS 12). Mutation check: disabling the server-certificate check or the artifact hash makes 3 e2e tests fail.

Self-review (adversarial)

  • Could a compromised Fabrica server make an agent run something? It can send jobs, but the manifest must be signed by a release key pinned at enrollment; keys are never changed by later messages. Tested: wrong key, garbled/missing signature, a good signature over another manifest, a signed manifest for another team/app/version (incl. a downgrade in disguise).
  • Could an attacker on the network enroll in place of the server? The code pins the root's SHA-256; a server under another root fails the handshake before the secret is sent (tested: the impostor sees no request).
  • Replay: job ids are remembered until expiry and survive restarts; old certificates after renewal or re-enrollment are refused by the registry (tested end to end).
  • Health URL is local-only (no SSRF via a job); unit names, versions, artifact names are checked before they touch paths or systemctl; tar refuses links, devices, .., absolute paths.
  • The agent runs as root (deploy needs systemctl and /var/lib); hardening is later.
  • TLS 1.3 race: a client-certificate refusal arrives as the alert or a reset; tests accept both (fixed a flake).
  • Not verified: tests/linux/run.sh with real systemd (no Docker/Podman/WSL on this PC); the installer end to end (Fabrica must serve it); the server side (Fabrica, T3b).
Legatus v0.1 foundations (Fabrica docs/32_coherence.md, T3a): protocol v1, enrollment, mTLS, the signature check, and the Linux (systemd) target. **What** - `legatus-protocol` (pure): `EnrollmentCode` (`lgt1-…`: server, root SHA-256, 128-bit secret, checksum), `EnrollmentBook` (single use, digest only), messages (enroll, hello, job, report, renew; strict, bounded), `JobGuard` (expired, future, too long, replayed), `Registry` (current/pending serial, revoked), `verify_release` + `check_artifact` (minisign by a pinned team key over the exact manifest bytes; team, app, version, artifact must match the job; size and SHA-256), `check_entry` (archive paths). - `legatus-linux`: release dirs, `current` switched by symlink + `rename(2)`, `systemctl restart`, health (unit active and a local URL, twice in a row), auto rollback, pruning, hostile-tar unpacking. - `legatus`: TLS that trusts only the pinned Domi root (by hash at enrollment, then the stored root), mTLS with the agent's own key, a small bounded HTTP/1.1 client, `enroll`, the job loop, renewal, CLI; `install/install.sh`; `tests/linux` (real systemd in a container). **Tests (first, 58 on Windows + 13 on a Linux kernel)**: protocol 32 (enrollment 8, certificates 6, release 9, jobs 9); linux 13 (unpack 5 everywhere; switch/rollback 8 Linux-only, run on Linux 6.6 in the x86_64 emulator, systemd faked); agent 21 (pipeline 9, end to end over real TLS 12). Mutation check: disabling the server-certificate check or the artifact hash makes 3 e2e tests fail. **Self-review (adversarial)** - Could a compromised Fabrica server make an agent run something? It can send jobs, but the manifest must be signed by a release key pinned at enrollment; keys are never changed by later messages. Tested: wrong key, garbled/missing signature, a good signature over another manifest, a signed manifest for another team/app/version (incl. a downgrade in disguise). - Could an attacker on the network enroll in place of the server? The code pins the root's SHA-256; a server under another root fails the handshake before the secret is sent (tested: the impostor sees no request). - Replay: job ids are remembered until expiry and survive restarts; old certificates after renewal or re-enrollment are refused by the registry (tested end to end). - Health URL is local-only (no SSRF via a job); unit names, versions, artifact names are checked before they touch paths or `systemctl`; tar refuses links, devices, `..`, absolute paths. - The agent runs as root (deploy needs systemctl and /var/lib); hardening is later. - TLS 1.3 race: a client-certificate refusal arrives as the alert or a reset; tests accept both (fixed a flake). - **Not verified:** `tests/linux/run.sh` with real systemd (no Docker/Podman/WSL on this PC); the installer end to end (Fabrica must serve it); the server side (Fabrica, T3b).
mnovak added 9 commits 2026-11-17 12:34:36 +01:00
mnovak manually merged commit 21b11cc3ef into main 2026-11-17 12:36:06 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/Legatus#1