Skip to content

feat(release): sign each archive for cargo binstall - #2765

Merged
thiras merged 3 commits into
mainfrom
feat/binstall-signatures
Oct 29, 2026
Merged

thiras merged 3 commits into
mainfrom
feat/binstall-signatures

Conversation

@thiras

@thiras thiras commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What

Follows #2764, which added the binstall metadata.

cargo binstall reads no checksum manifest. It verifies each archive against its own minisign signature, file = "{ url }.minisig". This PR makes binstall verify what it installs:

  • Manifests: the four binary crates get [package.metadata.binstall.signing] with algorithm = "minisign", pubkey set to the key line of crates/cli/minisign-thiras.pub, and file = "{ url }.minisig".
  • scripts/sign-release.sh:
    • It reads the binstall pubkey from the tag's manifests (what crates.io will serve). It refuses before the password prompt when the crates disagree or name none.
    • It signs SHA256SUMS and every archive in one minisign -S run, so there is still one password prompt. Without -x, minisign writes <file>.minisig for each file.
    • It verifies each <archive>.minisig under the binstall key and refuses before any upload on a mismatch.
    • It uploads the archive signatures with the rest. The stray-signature warning knows about them.
  • scripts/publish-crates.sh: refuses a release in which any archive has no .minisig. A crates.io version can never be replaced, so publishing without them would leave binstall building that version from source permanently.
  • check-binstall-metadata.sh: also checks the signing section in every crate:
    • the same key everywhere, and that key is one of crates/cli/minisign*.pub;
    • algorithm and file as above;
    • the key on one exact pubkey = "<key>" line, the only form sign-release.sh's sed reads.
  • Docs:
    • RELEASING.md § The minisign keys: the pubkey field holds one key, not a set, so it follows whoever signs. A release by another maintainer, or the first after a key rotation, changes it in all four manifests before tagging.
    • SECURITY.md: binstall trusts crates.io for the key, not KEYS.

Reviewer notes

  • What binstall does when a signature is missing. I measured this against the published v0.2.0, which has no archive .minisig. binstall refuses the archive ("could not GET ….tar.gz.minisig: 404") and falls back to cargo install from source. It never installs an unsigned archive. Merging this before a release is signed the new way therefore degrades installs to source builds; it never installs unverified bytes.
  • Multi-maintainer limit. binstall takes one pubkey per crate version, unlike decdn self-update, which accepts any embedded key. With one maintainer key today this costs nothing, and the RELEASING.md section covers the hand-off.

Verification

  • binstall end to end with the real format (cargo-binstall 1.26.1). I used a throwaway minisign key and fake archives signed with the same multi-file minisign -S -m SHA256SUMS a.tar.gz b.tar.gz call the script makes, served over HTTPS (--root-certificates) and installed from a manifest carrying the signing section:
    • good signature: installed, and the binary runs;
    • archive with one byte appended: Failed to verify signature, nothing installed;
    • manifest naming another key: The signature was created with a different key than the one provided, nothing installed.
  • sign-release.sh: scripts/tests/test_sign_release_publish.py has 14 passing tests (4 new). Its minisign shim now models multi-file -S, default .minisig names and -P <key>. The new tests: archives the binstall key can't verify are refused with no upload; crates naming different keys, or none, are refused before -S; the key comes from the tag's tree, not the working tree. The existing stable-release test now also asserts the single -S call, the per-archive -V -P calls and the uploaded .minisig names.
  • The real tree: sign-release.sh's lookup block, run on the committed tree, returns RWQFaucN…ESn, the key line of minisign-thiras.pub.
  • publish-crates.sh: I ran the new check block on a signed and an unsigned asset list. It passes the first and names b-1-w.zip for the second.
  • Guard: passes on the repo. Giving one crate a different key fails it with both the not-a-maintainer-key and differs-between-crates errors. 33 guard tests pass.
  • uvx --with pyyaml pytest .github/scripts/tests scripts/tests: 351 passed. shellcheck is clean on both scripts. pre-commit run on the changed files passes; the cargo-deny RUSTSEC-2026-0387 finding is pre-existing and warn-only.
  • After the next release: cargo binstall --strategies crate-meta-data decdn-cli on a clean machine. This is the first real signed install.

Always:

  • pre-commit run (changed files)
  • CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features (no Rust source changed; left to CI)
  • cargo nextest run (no Rust source changed; left to CI)
  • PR title type and lowercase subject

Only if touched:

  • User-visible change: CHANGELOG.md entry added

🤖 Generated with Claude Code

@thiras thiras self-assigned this Oct 29, 2026
@thiras
thiras force-pushed the feat/binstall-signatures branch from 60d5905 to ab12966 Compare October 29, 2026 20:42
@github-code-quality

github-code-quality Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust, Solidity

Rust / code-coverage/cargo-llvm-cov

main 55cd383 feat/binstall-signat... 69de5d3 +/-
77% 77% 0%
View coverage of the 3 most impacted files.
File main 55cd383 feat/binstall-signat... 69de5d3 +/-
crates/protocol/src/framing.rs 93% 92% -1%
crates/client/src/lib.rs 89% 89% 0%
crates/node/src...s/client/mod.rs 91% 91% 0%

Solidity / code-coverage/forge

main 55cd383 feat/binstall-signat... 69de5d3 +/-
92% 92% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 29, 2026 21:59 UTC

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@thiras
thiras force-pushed the feat/binstall-signatures branch 2 times, most recently from 358996d to 0b04edf Compare October 29, 2026 21:21
cargo binstall reads no checksum manifest: it verifies each archive against
its own minisign signature. sign-release.sh now signs every archive with the
maintainer minisign key in the same minisign run as SHA256SUMS.minisig (one
password prompt) and uploads <archive>.minisig beside it.

The four binary crates' [package.metadata.binstall.signing] names that key,
so binstall refuses an archive whose signature is missing or does not verify
(a missing one falls back to a source build). sign-release.sh reads the key
from the tag's manifests, which are what crates.io serves, refuses before
signing when the crates disagree or name none, and refuses before uploading
when an archive does not verify under it. publish-crates.sh refuses a release
with an unsigned archive, since a crates.io version cannot be replaced.

check-binstall-metadata.sh also holds the signing section to one shape: the
same key in every crate, a key line of crates/cli/minisign-*.pub, written on
the one line form sign-release.sh reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras force-pushed the feat/binstall-signatures branch from 0b04edf to 3760e7c Compare October 29, 2026 21:30
binstall lets an override's `signing` replace the base table for that
target, and nothing checked one: a Windows override naming another key
would publish green and fail every Windows install for good. The guard now
refuses `signing` in any override, finds `pubkey` assignments in every form
(dotted, inline, quoted) across every crates/*/Cargo.toml, the set
sign-release.sh's sed reads, and reads the bytes so a CRLF line fails as it
does in sed.

sign-release.sh verifies every minisign signature with -H: without it a
legacy-format signature, which neither decdn self-update nor binstall
accepts, passed. It reads the tag's keys and the archive list before the
GPG step, so a key mismatch stops before either passphrase prompt, and
skips blank SHA256SUMS lines.

publish-crates.sh runs check_binstall_metadata.py in its worktree at the
tag, since CI is not guaranteed to have run on the tagged commit, and takes
the archives it requires signatures for from SHA256SUMS rather than the
release listing, so a missing archive is refused too.

Tests: the gh and minisign shims refuse missing signature files and model
-H and legacy signatures; new cases cover a rerun with stale signatures, a
legacy signer, a blank SHA256SUMS line, and publish-crates' asset checks and
guard run. Docs: RELEASING.md and SECURITY.md fixes the review listed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras marked this pull request as ready for review October 29, 2026 21:41
@thiras

thiras commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Review round (code, tests, comments, silent failures), addressed in fcdaceb:

  • A signing table inside an override went unchecked. binstall's merge_overrides lets an override's signing replace the base table for that target. So signing = { pubkey = "<other>" } under the Windows override passed the guard, and sign-release.sh never saw it. Windows installs of that crates.io version would fail permanently. The guard now:
    • refuses signing in any override;
    • finds pubkey assignments in any form (bare, dotted, inline, quoted) in every crates/*/Cargo.toml, the same set sign-release.sh's sed reads;
    • reads the raw bytes, so a CRLF line fails here as it does in sed.
  • Legacy signatures passed. Without -H, minisign -V accepts the legacy format. Neither binstall nor decdn self-update accepts it. All three verifications now pass -H. I checked with minisign 0.11: a -l signature passes -V and fails -V -H. The two verifications whose output is captured also drop -q, so the error reads "Legacy (non-prehashed) signature found" instead of blaming the key.
  • The guard now runs at the tag. publish-crates.sh runs check_binstall_metadata.py in its worktree at the tag before the first upload, since CI is not guaranteed to have run on the tagged commit. It also takes the archive list from SHA256SUMS rather than the release's asset list, so a missing archive is refused too.
  • sign-release.sh ordering: the tag's keys and the archive list are read before the GPG step, so a key mismatch stops before either passphrase prompt. A blank line in SHA256SUMS is skipped.
  • Tests:
    • The gh and minisign shims now refuse missing signature files and model -H and legacy signatures.
    • New cases: a rerun with stale signatures, a legacy signer, a blank SHA256SUMS line, and refusals asserting nothing was GPG-signed.
    • New file scripts/tests/test_publish_crates_assets.py covers the asset checks and the guard run at the tag.
    • New guard cases: signing inside an override, each pubkey form, CRLF, a missing algorithm, and pubkey in a crate without binstall metadata.
    • The tests for new behaviour fail against the previous scripts. The full tooling suite passes (389 tests).
  • Docs:
    • RELEASING.md: the minisign requirement (the prehashed format), Python 3.11 for publish-crates.sh, nine .asc files (it said five), the DECDN_MINISIGN_KEY row, and the hand-off/rotation/removal rules for pubkey.
    • SECURITY.md: the key line wording, a recipe for comparing the published pubkey with the tag, and --skip-signatures.
    • "manifest" now says SHA256SUMS or Cargo.toml as meant.

Not changed:

  • Checking archive signatures in publish-crates.sh. It would mean downloading every archive (around 500 MB); sign-release.sh verifies them, and publish-crates.sh checks they are attached.
  • The key-file glob spelling. The docs follow the minisign-<maintainer>.pub naming, and the code matches more loosely on purpose.

Copilot AI balanced review requested due to automatic review settings October 29, 2026 21:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Two adjacent literals in a list read like a missing comma. Each one that
forms a single value now says so: an explicit `+` where it is a list
element, parentheses where it is part of a tuple.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras merged commit 37a69f3 into main Oct 29, 2026
39 checks passed
@thiras
thiras deleted the feat/binstall-signatures branch October 29, 2026 22:11
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.

2 participants