custosd fleet upgrades. Distribution (install.sh plus release
tarballs under CUSTOS_RELEASE_BASE) handles first install; this is the upgrade of
already-running hosts.
Controlled push: an admin selects a published version for one host or the whole fleet. The
release workflow maintains releases.json beside the artifacts, and the control plane exposes
that catalog at GET /daemon/releases so clients never need a free-text version. The control
plane pushes the selected release over the existing authenticated daemon websocket; the daemon
downloads, verifies, and swaps its own binary via a root systemd step. Idempotent at every layer
— a host already on the target is a no-op.
Flow
-
Trigger.
POST /hosts/{id}/upgradeorPOST /upgrade(admin,{"version":"vX.Y.Z"}). The control plane recordshosts.desired_versionand pushes aTypeUpgrade{Version, SHA256, BaseURL}envelope, signed with its signing key and bound to the host, to online hosts. Offline hosts get it on reconnect. Daemons drop an upgrade whose signature does not verify. -
Stage (daemon, unprivileged).
client.handleUpgrade→stageUpgrade: downloadcustosd_<v>_manifest.jsonand.sigfrom the release directory, verify the signature against the release keys compiled into the daemon, download the arch tarball, and check the tarball and the extractedcustosdagainst the manifest digests. Only then are the binary, manifest and signature written to/var/lib/custos/update/, and the daemon exits so systemd restarts it. -
Apply (root). The unit has
ExecStartPre=+custosd apply-update; the+runs it as root though the service isUser=custos. Everything in the staging directory is treated as untrusted, so it re-verifies from scratch:- verifies the manifest signature with the keys compiled into the installed binary;
- refuses the version if it is below the host’s security floor;
- copies the staged binary, without following symlinks, into a root-owned temp file next to
/usr/local/bin/custosd, and checks that copy against the signed digest; - runs the copy’s
versioncommand and requires exactlycustosd <version>; - backs up the current binary to
.prev, renames the copy into place, and raises the floor.
-
Converge. The daemon reports
Versionin itsAuthon reconnect →hosts.agent_version.
Trust
Root only installs a binary whose manifest was signed by a key ininternal/release/keys.go. A compromised control plane, release host, network path, or custos
user can delay or block an update but cannot get a different binary run as root. The private key
lives only in CI; see Release signing.
The SHA256 map in the upgrade message is kept for daemons released before manifest signing,
which still verify against it. Current daemons take every digest from the signed manifest.
Security floor
Each manifest carries asecurity_floor: the lowest version hosts may run once they have seen
that release. apply-update keeps the highest floor it has installed in the root-owned
/etc/custos/security-floor and refuses any version below it, so downgrades work normally above
the floor, but a host never goes back to a release with a known vulnerability. The binary also
carries its own floor from build time, so a freshly installed host is protected before its first
update.
apply-update enforces the higher of that file and the floor built into the installed binary, so
editing the file can only lower a host to its binary’s own floor. To go below that on one host,
install the older binary by hand as root (for example from /usr/local/bin/custosd.prev).
custosd uninstall --purge removes the file.
Triggering an upgrade
GET /daemon/releases returns the published release catalog, so clients never need to supply a
free-text version. Every layer is idempotent — a host already on the target version is a no-op, and
an offline host receives the upgrade on its next connect.