Skip to content

feat(cli): verify a minisign signature in uteke upgrade (#1327) - #1462

Merged
ajianaz merged 10 commits into
developfrom
feat/upgrade-verify-minisign-1327
Oct 15, 2026
Merged

ajianaz merged 10 commits into
developfrom
feat/upgrade-verify-minisign-1327

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

What

Stage 2 of #1327. uteke upgrade now authenticates the release before it trusts anything in it.

uteke upgrade (crates/uteke-cli/src/commands/upgrade.rs)

  • Fetches checksums-sha256.txt and checksums-sha256.txt.minisig (4 KiB cap), verifies the signature over the raw checksums bytes, then reads the expected hash from those same verified bytes. All of this happens before the archive download.
  • Verification uses crate minisign-verify 0.3.0 (one new crate, no dependencies of its own) against the embedded RELEASE_PUBLIC_KEYS, with allow_legacy=false.
  • The signature's trusted comment must be exactly uteke <tag>. The crate authenticates the trusted comment through the global signature (checked against its source and by experiment), so one release's signed files cannot be served as another's.
  • A missing, malformed or wrong-key signature is a hard failure. There is no silent fallback to checksum-only.
  • Stable releases only. The target tag must be exactly vX.Y.Z. Pre-release suffixes and build metadata are refused before any download. GitHub's /releases/latest already excludes pre-releases; this enforces it in code too.
  • No downgrades. latest must be strictly newer than the running version by semver (numeric, pre-release ordering per semver); older is refused, equal is "already up to date". A running pre-release or dev build may upgrade to a newer stable.
  • UTEKE_UPGRADE_SKIP_CHECKSUM=1 still skips the checksum and now the signature too, with an updated loud warning. It does not skip the stable-tag or downgrade checks.

Offline signing (owner signs, never CI)

  • scripts/sign-release.sh vX.Y.Z downloads the checksums and the cosign bundle, runs cosign verify-blob against the release workflow identity and aborts if it fails or is missing. It shows the verified checksums, asks y/N, signs with minisign (minisign prompts for the password itself; the script never reads it), verifies against scripts/uteke-release.pub, then uploads checksums-sha256.txt.minisig. It supports --dry-run and --force.
  • scripts/uteke-release.pub holds the public key (key id 96924B76E31B048B). The secret key is password-protected and stays on the owner's machine.

Docs: SECURITY.md, AGENTS.md (new release step 6), docs/install.md, docs/cli-reference.md, CHANGELOG.

Why

#1327: the checksums came from the same release as the archive, so they only detected corruption. Someone who could replace release assets could replace both. With a signature made by a key that never lives on GitHub, replacing assets is no longer enough.

Decisions by the owner: minisign with an embedded public key, signed offline; fail closed; stable releases only; no downgrades. Cosign keyless stays for manual verification per SECURITY.md.

Testing

  • cargo test --workspace --locked: all pass (uteke-cli 135 unit + integration tests). cargo fmt --all -- --check and cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
  • cargo audit: no vulnerabilities (the 2 allowed warnings were already there).
  • cargo run -p docgen && git diff --exit-code docs/: no diff.
  • Cargo.lock: the diff is only the minisign-verify entries (7 lines); cargo build --locked works.
  • Signature tests, using fixtures made with a throwaway key whose secret key was deleted (only public material is committed), asserting exact errors: valid; data tampered; another tag; another key; garbage, empty, truncated and whitespace-only text; a legacy signature; a trusted comment with a trailing or doubled space. I re-verified the fixtures with minisign -V.
  • Wiring tests: verified_expected_hash never yields a hash without a valid signature, and returns the exact hash for the archive name from a verified file. authenticate_checksums fails closed on fetch errors.
  • Version tests: semver ordering (0.9.0 < 0.10.0, rc.2 < rc.10, pre-release < release), unparseable tags, and the stable-only cases.
  • bash scripts/tests/sign-release.test.sh: 13 checks with stub gh and cosign and a throwaway key. They cover failing cosign, a missing bundle, a missing cosign, answering n, an existing signature, a bad tag, an unknown flag, and the --dry-run happy path that signs and verifies without uploading. It is not wired into CI because no existing job fits cheaply; the command is in AGENTS.md step 6.
  • Two independent adversarial security reviews. The first found a missing downgrade check and a script that signed unverified files; both fixed. The re-review of the fixes found no hole.
  • The real signing key was never used in tests.

Rollout notes

  • uteke upgrade fails closed for any release without a .minisig. That includes v0.21.0 and the window between a release being tagged and the owner running sign-release.sh. The signature check runs before the archive download, so that window wastes no 128 MiB download.
  • The minisign signature is checked by uteke upgrade only. install.sh, install.ps1 and Homebrew do not verify it (Homebrew relies on the formula SHA256s).
  • Rotating the key needs a new uteke release, because existing binaries cannot learn a new key.

…grade (#1327)

Embed the release public key and verify checksums-sha256.txt.minisig over
the raw checksums bytes before trusting any hash. The trusted comment must
be 'uteke <tag>' so an older signed release cannot be replayed. A missing or
invalid signature is a hard failure; UTEKE_UPGRADE_SKIP_CHECKSUM skips it
too, with an updated warning.
…hive download (#1327)

Compare versions numerically (semver, pre-release aware) and refuse an older
release; unparseable tags are an error. Fetch and authenticate the checksums
before downloading the archive, through a fail-closed authenticate_checksums.
New fixtures: legacy signature, trailing-space and double-space trusted
comments (the throwaway key was regenerated; all fixtures re-signed).
…ash from verified checksums only (#1327)

Reject any non-stable target tag (pre-release, build metadata, malformed)
before the prompt and any download, with no override. A pre-release running
binary can still upgrade to a newer stable. The expected archive hash now
comes from verified_expected_hash, which authenticates the checksums first,
and is unit-tested. Adds the whitespace-only signature case.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant