Commit Graph
3 Commits
Author SHA1 Message Date
yetone d6a6865b1f update: a file from usemagpie.ai has its attestation from usemagpie.ai, GitHub's API after (ArcticLampyrid on X)
The site's cron keeps each release's SLSA bundles on R2 as
/files/<tag>/attestations.jsonl (728f3de40, 5e51e241c), but the updater
still asked api.github.com for every file, 60 an hour unsigned, and with
Update source set to the site alone it never checked an attestation at all.

attestation() now takes the asset. A file the feed names on the site
(Site/files/<tag>/<file>) has its release's bundles read from the same
site first; GitHub's API is asked as before when the site misses: a pruned
tag's 302 to GitHub's release (not followed; that asset doesn't exist),
any other status, a body with no bundle, or the site unreachable.

The trust model is unchanged. The site is only transport: its bundles go
through the same verifyBundle (embedded Sigstore root, release.yml of
yetone/magpie-releases, the digest from the ed25519-signed SHA256SUMS).
A site bundle that fails sends the updater to GitHub's API, where a valid
bundle holds; if that API can't be read it is a refusal, not unknown, so a
tampered mirror plus a blocked GitHub can't go through as "unattested".
Update source "site alone": the site's bundles are checked, GitHub never
asked; a miss is unknown as before. Update source "GitHub": the API alone.
docs/reference.md and the start page (en, zh, ja) say so; no
docs/subsystems page covers updates. llms-full.txt regenerated.

Run (mote):
- go test -count=1 ./internal/update/ ok; go vet darwin, GOOS=linux
  -tags nogui, GOOS=windows ok; gofmt -l clean.
- node --test site/*.test.mjs 120/120.
- New tests (attest_site_test.go, fixture = the site's real
  v0.1.3986/attestations.jsonl): the site serves it and GitHub isn't asked;
  site-alone source attested; another digest refused; misses (302, 404,
  502, html, empty, cut mid-line, site down) go to GitHub; site-alone miss
  stays unknown; a tampered site bundle refused with GitHub 403/503/404 and
  with site-alone, and passes on GitHub's valid bundle; wrong identity
  refused; GitHub source and github.com files never ask the site. No test
  reaches the network (TestMain points the site at 127.0.0.1:1).
- Broken by hand, each red: never asking the site (4 tests), taking a site
  bundle unchecked (3), following the redirect (1), a failing site bundle
  plus unreadable GitHub kept unknown (2).
- Live once (a throwaway test, not committed): usemagpie.ai's real
  v0.1.3986 bundles attested magpie-cli-android-arm64 with the API pointed
  at a dead address; pruned v0.1.3985 (302) fell back to api.github.com
  and attested.

Not tried: a full app update from the site end to end; Windows and Linux
runs of the package (the change is OS-independent).
2026-11-13 12:49:24 +08:00
yetone bbce1fc1ab update: the updater checks a download's GitHub build attestation too (ArcticLampyrid on X)
Release CI attests every file (SLSA provenance through Sigstore, v0.1.3891
on). The updater now fetches the bundle for a file's signed SHA-256 from
api.github.com/repos/yetone/magpie-releases/attestations/sha256:<digest>
before it downloads the file, and verifies it with sigstore-go against the
Sigstore trusted root embedded in the binary (attest_root.json, public
good instance): certificate chain, certificate timestamp, Rekor entry,
issuer token.actions.githubusercontent.com, subject release.yml of
yetone/magpie-releases on main or a v* tag, source repository
yetone/magpie-releases, and the digest among the statement's subjects. It is
in addition to the ed25519 check over SHA256SUMS, which still runs first
and still works offline and from the R2 mirror; the attestation is asked
about the digest that signed list gives, so both speak of the same bytes.

When the attestation can't be had (a failed read means "unknown", but an
outage of GitHub must not take updates away):
- a bundle that is there and fails (signature, identity, digest, a chain
  outside the trusted root), GitHub answering 404, or an empty list: the
  file is refused. GitHub was asked and says these bytes weren't built by
  that workflow.
- GitHub unreachable, rate limited (60/hour anonymously), 5xx, a body that
  isn't JSON, or Settings' update source set to the site alone (which never
  goes to GitHub): the update goes on, since the ed25519 check has held, and
  the log says the file went unattested and why. Someone who can only drop
  the API call downgrades an update to the ed25519 check, never below it.
- releases before 0.1.3891 and a MAGPIE_UPDATE_FEED of your own are not
  asked.
The bundle checks itself, so the API call goes through source.Do and may use
a mirror.

Cost: go.mod gains sigstore-go v1.1.4 and its tree (go.sum +350 lines).
The embedded root has to be renewed (gh attestation trusted-root, first
line) when Sigstore rotates its keys; docs/reference.md says so. Until then
a chain under a new key fails as "not attested" and is refused: a known
cost, in the doc.

Run (mote, sandbox HOME via testenv): go test ./internal/update (ok),
site node tests (112 of 114; docker-tags and the sponsors README test fail
because mote-run -C site cannot see ../README.md, unrelated), gofmt -l
empty, go vet darwin, GOOS=linux -tags nogui and GOOS=windows on
internal/update, go build ./... on all three. Fixture: the real answer
api.github.com gave for v0.1.3925's SHA256SUMS (testdata/attest), verified
offline; the whole run reaches no network.
New tests: TestAttestationOfARealBundleHolds, ...OfAnotherDigestRefused,
...TamperedRefused, ...EditedPayloadRefused, ...WrongIdentityRefused (repo,
workflow, ref, source repo, issuer each), ...NoneListedRefused,
...UnknownGoesOnAndSaysSo (403, 429, 502, HTML, nothing listening),
...OnlyWhereItIsOwed, TestVerifyMarksAttestedReleases,
TestDownloadRefusedWithoutAttestation.
Broken by hand: identity check swapped for WithoutIdentitiesUnsafe turns
WrongIdentityRefused red on all five cases; the attestedFile call removed
from download turns DownloadRefusedWithoutAttestation red (the file was
fetched). The first full run of the package, before TestMain pointed the
attestation API at a closed port, had TestSourceSiteAndAutomaticUseTheSite
reach the real GitHub with a made-up digest and be refused: now closed.
Not tried: a real update end to end (needs a release newer than the
running binary; the unit path covers download), Windows box, the
GUI, full suite (starts after the tag).
Docs: docs/reference.md, start.html (en, zh, ja) and llms-full.txt say what
the app checks now.
2026-11-13 00:01:01 +08:00
yetone c4f7ba9d3a update: only a release whose SHA256SUMS carries the release key's signature is installed (danny0dong on X)
The updater took a file and its SHA-256 from the same feed answer, so
whoever could change /api/latest could swap both; only the Mac app also
checked its signing team. Now release CI (yetone/magpie-releases) signs
"magpie release <version>\n" + SHA256SUMS with an ed25519 key held as that
repo's UPDATE_SIGNING_KEY secret and publishes SHA256SUMS.sig (release
assets: 16 -> 17). The site worker carries the list and signature in the
feed; internal/update/signed.go checks them against the public key built
into the binary, takes each file's hash from the signed list and refuses a
missing or bad signature or a feed hash that differs. Versions from
0.1.3862 require it; older ones and binaries older than the key update as
before. MAGPIE_UPDATE_FEED lifts the requirement for local test servers.
mirror-release waits for 17 assets; docs/reference.md and code-standards
say 17 and describe the transition.

Run: go test internal/update, internal/cli, internal/gui -run Update|WhatsNew
(ok); node --test site/*.test.mjs (116 ok); gofmt; go vet darwin, linux
nogui, windows on internal/update. Broken by hand: signature check skipped
(tamper and other-key tests red), feed-hash comparison skipped (swapped
hash and feed tests red), worker not attaching signed (worker test red).
The embedded key is checked against a sample signed by the real key with
openssl, as CI does. Signing script run against a throwaway key.
Not tried: a real signed release before this tag; install.sh does not
verify the signature.
2026-11-12 16:43:23 +08:00