Repository navigation
Description
Problem
A decdn binary has no way to learn that it is stale, and no way to replace itself. Today the only update paths are:
cargo install --locked decdn-cliagain,docker pull,- re-running the sponsored one-liner (
https://up.decdn.org/decdn.sh/decdn.ps1), which reinstalls into~/.local/bin/decdnonly when the onramp's pinned release (sponsord_onramp_decdn_release) moves and the marker in~/.decdn/installer/decdnno longer matches.
Someone who ran the one-liner once and then types decdn get … directly keeps the old binary forever. That matters more here than for most CLIs: pre-mainnet, wire-breaking changes are allowed and the testnet is redeployed rather than migrated (CLAUDE.md § Pre-mainnet). After a fleet upgrade, a stale client fails with whatever the mismatch surfaces as (a refused StreamRequest, an ABI mis-decode, a NotFound), not with "your decdn is out of date". The next release is likely v0.2.0 with #2482 breaking the lane signer, so this will bite the current one-liner users (see decdn/sponsord#83 for the pin dance it forces on the onramp side).
Proposal
Add self-update to the decdn CLI, in two layers:
decdn self-update(explicit). Resolve the latest stable GitHub release, downloadSHA256SUMS+SHA256SUMS.ascand thedecdn-<version>-<target>archive for the running target, verify, and replace the running binary in place.- Update check on run (automatic). At most once per day (stamp under
~/.decdn/), after the command's real work, check the latest release and print one line:decdn <new> is available; run \decdn self-update`(or apply it whenself_update.auto = true/DECDN_SELF_UPDATE=auto). Never block ageton the check, never check in--json/non-tty output unless asked, andself_update.check = falseturns it off entirely. Aget` that was started should finish on the binary it started with.
Verification is the hard part
The release pipeline signs only SHA256SUMS (GPG, key in KEYS; SECURITY.md § Verify a binary archive). Individual archives carry no signature. So the client must:
- embed the maintainer signing key(s) at build time (from
KEYS, or a fingerprint allowlist) and verifySHA256SUMS.ascbefore trusting any checksum; a release that does not verify is refused, not warned about; - verify the archive against the signed manifest, extract, and only then swap the binary;
- refuse downgrades (
new <= running) and pre-releases unless--pre-releaseis given, so a compromised or stale "latest" cannot roll users back; - treat GitHub as an untrusted mirror: nothing it serves is trusted until the signature checks out.
Open question: a full OpenPGP verifier (sequoia-openpgp, pgp) is a heavy dependency for the client crate graph that .github/scripts/check_crate_edges.py keeps lean. The alternative is to add a second, client-oriented signature to the release pipeline (minisign / raw Ed25519 over SHA256SUMS, produced by sign-release.sh from a dedicated key published in KEYS-adjacent form) and have the CLI embed that public key. That keeps GPG as the human-facing channel and gives the binary a ~0-dep verifier. Needs a decision before implementation; the second option also needs a RELEASING.md + SECURITY.md update and a key-rotation story (the embedded key must be able to vouch for its successor).
Ownership of the installed binary
Only replace a binary we own. Detect the install channel and act accordingly:
| Installed via | Behaviour |
|---|---|
sponsored installer (~/.local/bin/decdn + marker in ~/.decdn/installer/) or a previous self-update |
replace in place, then rewrite the installer marker (<SHA256SUMS digest> <target>) so the next one-liner run does not reinstall over it (decdn/sponsord crates/sponsord-onramp/assets/decdn.sh fetch_bin) |
cargo install (~/.cargo/bin) |
refuse, print cargo install --locked decdn-cli |
| container image | refuse, print docker pull … |
| distro package / unknown path, or not writable | refuse, name the path and the reason |
Windows cannot replace a running .exe; use the rename-then-replace pattern (e.g. the self-replace crate) and make sure a crash mid-swap leaves a working binary (write to a sibling temp file, fsync, atomic rename).
Out of scope
decdn-node: operators deploy it throughdevops/(Ansible / Helm / Compose) and must not have a daemon replacing itself under a supervisor.- A protocol-level "minimum client version" signal from nodes. Worth a separate ADR discussion if version skew keeps hurting after this lands; this issue only closes the gap between "a new release exists" and "the user knows".
Acceptance
decdn self-updateon a one-liner install moves~/.local/bin/decdnto the latest signed release anddecdn --versionreports it; the installer marker matches and re-running the one-liner saysdecdn <tag> is already installed.- A tampered
SHA256SUMS, a bad.asc, or an archive that does not match the manifest leaves the running binary untouched and exits non-zero with the reason. - A
cargo installbinary refuses with the right command. - The daily check adds no latency to
decdn getand is silent withself_update.check = false. - Config knobs follow the usual surfacing (config schema,
decdn configshow/validate summary,DEFAULT_CONFIG, env + CLI flag, CHANGELOG). - Unit tests in their own
<name>.rsfiles (CONTRIBUTING.md § Unit test placement); signature-verification tests use a test key, never the maintainer keys. - README § Install, SECURITY.md, and RELEASING.md describe the new channel and, if chosen, the second signature.
Related: #2466, #2476, #2482, #2487, decdn/sponsord#83.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsDone
Activity
refactor(cli): tighten the self-update helpers (#2537)
build(release): refuse to sign with a placeholder minisign key (#2537)
ci: let check-image-name.sh read release.yml to the end (#2537)
docs(release): one minisign key per maintainer (#2537)
build(release): embed the first maintainer minisign key (#2537)
fix(cli): address the review of the update notice and the key rules (#…