3 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 9cde4abf2e fix(build): refuse a recorded base package older than a newer pocket lists
The host checked that each package a first build of base recorded is
the archive's, but root in the recording build VM chose which signed
lists to hand back: it could return only the release pocket's and
record an older version than -updates or -security have. Now:

- a recording must hand back resolute-updates' and resolute-security's
  signed InRelease files with lists for the architectures whose lists
  have the recorded packages (another archive's InRelease, such as
  archive.ubuntu.com's on arm64, doesn't count), and every non-empty
  list each InRelease it hands back gives for those architectures, in
  every component (packages_lists_missing);
- a recorded package that the release pocket, -updates or -security
  lists a newer version of, for its architecture, is refused, naming
  the package, both versions and the suite (packages_not_newest);
  -backports doesn't count, as apt installs from it only when asked;
- a list's SHA-256 is checked against the verified InRelease files
  before it's read, so only signed lists are parsed;
- apt.sh's recording takes phased updates
  (APT::Get::Always-Include-Phased-Updates), so apt installs the newest
  version the lists have.

- internal/ubuntu: CompareVersions, dpkg --compare-versions in Go
  (epoch, upstream, revision, ~ and letters' order; ErrVersion for one
  that isn't a version); Release.Lists gives the matching lists with
  their paths, ListsFor, List.Arch, Backports, RequiredSuites.
- internal/build: signedEntries returns a signed (entries, each
  package's architectures, the newest version by architecture and name
  and its suite); verified, complete, checkNewest, newer; readArchiveList
  returns an archiveList.
- Messages: packages_lists_missing, packages_not_newest.
- Tests: CompareVersions' table (Debian policy's ordering and dpkg's
  cases, invalid versions); ListsFor and Backports on Ubuntu's real
  InRelease; a recording refused for an older version than -updates
  has, for a missing -updates or -security InRelease, a missing list,
  another archive's -security, a missing backports list; kept for the
  newer version, a newer one in backports, an older one in -security;
  checkNewest's table. The gpg-made fixtures are signed again by a new
  test key, with Packages-newer, Packages-security and InRelease-newer,
  -security, -security-amd64 and -backports added.
- Docs: images.md's Base's packages, design.md's trust note (the
  pocket choice closed; what root in the recording VM still chooses).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 16:50:31 -07:00
w3cjandClaude Opus 5.5 29740acb21 fix(build): refuse a stale mirror's old signed archive state for base's packages
Ubuntu's InRelease files carry no Valid-Until, so a mirror that stopped
updating, a hostile one, or anyone on an http path to one, could serve
an older, validly signed state of the archive, and a first build of
base would record its old packages for every later build of the key.
Now the host refuses a verified InRelease older than the archive state
the pinned cloud image was built from: every pocket but the release's
must be dated no more than a day before the pin's release-YYYYMMDD, and
the release pocket, which Ubuntu froze at release, no earlier than that
day (ubuntu.Released, 2026-04-23). The refusal names the mirror
(packages_stale_mirror) or Ubuntu's archive when none is set
(packages_stale), and nothing is kept.

From the security audit of both checks:
- only resolute, -updates, -security and -backports are accepted, never
  -proposed;
- verify tries at most 4 signature packets, as each hashes the whole
  signed text (a CPU bound on what the build VM or a mirror sends).

- internal/ubuntu: Release.Stale, Released, the suites accepted,
  maxSignatures.
- internal/build: signedEntries reads the pin (state.ReadUbuntuPin) and
  refuses a stale InRelease; taken keeps the mirror to name it.
- Messages: packages_stale, packages_stale_mirror.
- Tests: Stale's table (each pocket a day either side, the release
  pocket at Released, a release that isn't a date); -proposed and
  backports; more signatures than tried; a recording with an old
  InRelease refused, naming the mirror or the archive; a good set kept
  with the release pocket's InRelease (gpg-made fixtures InRelease-old,
  InRelease-release). Coverage baselines raised: build, ubuntu.
- Docs: design.md's trust note (the stale-mirror gap closed, what root
  in the recording VM still chooses), images.md's Base's packages,
  settings.md's mirror section, troubleshooting.md's Base gets old
  package lists, maintaining.md (moving Released with the series).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 15:14:48 -07:00
w3cjandClaude Opus 5.5 de28721978 fix(build): check base's recorded packages on the host against Ubuntu's signed archive lists
A first build of base gave back each package it downloaded with apt's
entry for it, and the host took the build VM's word that each entry was
apt's: anything with root in that VM before apt.sh end could record a
package with a made-up entry, which every later build of the key
replayed. Now the build also hands back the InRelease files and package
lists apt used, and the host checks them itself before it keeps
anything:

- each InRelease is clearsigned by Ubuntu's archive key, pinned in
  assets/layers/ubuntu-archive.gpg ("Ubuntu Archive Automatic Signing
  Key (2018)", F6ECB3762474EDA9D21B7022871920D1991BC93C, from
  keyserver.ubuntu.com by fingerprint, checked against the Ubuntu
  security team's list), and one of 26.04's suites;
- each package list has the SHA-256 and size a verified InRelease gives
  one of its Packages lists;
- each recorded .deb's SHA-256 is in one of those lists, as the package,
  version, architecture and size apt's entry says, and the set keeps
  the archive's own entry.

- internal/ubuntu/pgp.go verifies clearsigned messages (RFC 4880's
  cleartext signatures: text signatures, dash-escaping, trailing
  whitespace, nothing before or after); archive.go's VerifyRelease and
  Release.Lists read a verified InRelease (ArchiveKeyring).
- assets/layers/apt.sh: record copies apt's *_InRelease and *_Packages
  lists to out/<n>.InRelease and out/<n>.Packages; base's build keeps
  lists uncompressed (Acquire::GzipIndexes "false").
- internal/build: take accepts the lists (an InRelease at most 4 MiB and
  all of them 32 MiB, a list 512 MiB with lines of 1 MiB and entries of
  4 MiB, all lists 2 GiB, no name twice), signedEntries and
  archiveEntry check them; cache carries devvm's own files for the key.
- Tests: Ubuntu's real resolute-updates InRelease verified, and refused
  when changed, framed differently or signed by another key; clearsigned
  parsing (dashes, CR LF, trailing whitespace, a binary signature
  refused); InRelease fields; a recording refused for a forged
  InRelease, a list no InRelease gives, a .deb no signed list has,
  another package's entry, missing lists, a list or an InRelease twice,
  a line over 1 MiB; a good set kept
  with the archive's entry (gpg-made fixtures in
  internal/build/testdata/archive); apt.sh's record giving back the
  lists.
- Docs: images.md's Base's packages, design.md's trust note (the
  recording VM's made-up packages closed), settings.md's mirror
  section, maintaining.md's archive key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 14:57:10 -07:00