From 12fb09b0ad11c0d9305d606b3b4fced8ba04d385 Mon Sep 17 00:00:00 2001 From: aur-build Date: Wed, 18 Nov 2026 10:16:12 +0000 Subject: I9: the pipeline stops trusting paths the build could have placed, plus README and the invariant index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three things. **A real hole, closed.** `collect` scans the build's srcdir for `*.pkg.tar.zst`, and `ingest` copies whatever those paths resolve to into the content-addressed store — from where the bytes are served from our repo and signed with our key. The paths are generated by our own scan, but their *targets* are not: a PKGBUILD that drops a symlink called `evil.pkg.tar.zst` pointing at the signing keyring, the database, or anyone's home directory would have its target copied in, published and signed by us. The chroot is supposed to be the layer that prevents that, and the chroot tier is gated — but two protection layers must not be load-bearing on each other, and the control plane should not depend on isolation for the safety of its own secrets. `collect` now rejects symlinks and rejects anything whose canonicalized target escapes the build's own staging directory, failing the build closed with the path in the message. `i9_a_build_cannot_smuggle_bytes_in_from_outside_its_own_staging_dir` acts the attack out — the shim plants a symlink to the database file — and asserts the build fails, the store is byte-for-byte untouched, and nothing publishes. This is the last §2 invariant that had no named test; docs/INVARIANTS.md says plainly which part of I9 this covers and which part belongs to the gated chroot tier. **README.md**, written for the person who has to operate this at 3am: the rule everything else follows, the quick start, the layout, how the shim harness makes the whole pipeline testable without root or network, the ops commands, the route table, and the §14 constraints stated as the hard edges they are. **docs/INVARIANTS.md**, mapping I1-I12 to the named tests that hold them, with corroborating tests listed, and an explicit note on the two invariants enforced by the schema (the partial unique index for I7, the append-only triggers for I10/I7) so a future code path cannot forget them. Also recorded in DECISIONS.md: metrics served without a session and why, retention recording a purge instead of deleting the row, and the real-chroot tier being explicitly skipped with what stands in for it and how to actually run it. .gitignore already covered .pi/ but the goal-tracker files were tracked from before the rule existed; untracked now so they stop appearing in every diff. --- docs/DECISIONS.md | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'docs/DECISIONS.md') diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index c681c05..76c46c7 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -107,3 +107,79 @@ rewrite. A `static Mutex` around `publish()` gives the same guarantee with less machinery; the critical section is the db file rewrite, never a build. The lock poison is cleared deliberately: atomic publish means a panic cannot have left a half-written db, so wedging the queue would be worse than continuing. + +## The pipeline refuses symlinks in the srcdir, even though a chroot should make that moot + +`collect` scans the build's srcdir for `*.pkg.tar.zst`, and `ingest` copies +whatever those paths resolve to into the content-addressed store — from where +the bytes are served from our repo and signed with our key. The paths are ours +(the scan generates them) but their *targets* are not: a PKGBUILD that drops a +symlink named `evil.pkg.tar.zst` pointing at the signing keyring, the database, +or anyone's home directory would have its target copied in and published. + +**Choice.** `collect` rejects any entry that is a symlink, and any entry whose +canonicalized target escapes the build's own staging directory. The build fails +closed with the path in the message. `tests/invariants.rs::i9_a_build_cannot_smuggle_bytes_in_from_outside_its_own_staging_dir` +acts the attack out through a shim hook rather than arguing it is unlikely. + +**Cost.** A legitimate build that stages a package outside its srcdir and +symlinks it in now fails. That is a build we want to fail: it is telling us the +recipe does something we cannot see the whole of. + +**Why this is not a substitute for the chroot.** I9's real enforcement is +isolation, and that tier is gated. This is the narrower claim that the control +plane does not *depend* on isolation for its own secrets — the layers should not +be load-bearing on each other. + +## Metrics are served without a session + +Everything else in the UI is behind a password. `/metrics` is not, because a +Prometheus scraper has no session to present, and the alternative — teaching the +scraper to log in and hold a cookie — puts a credential in a monitoring config +to protect numbers. + +**Choice.** `/metrics` returns counts only: queue depth, review debt and its age +histogram, build success rate, WAL size, index size, stale counts by reason, +staging usage. No package names, no versions, no audit detail, no paths. The +bind address is loopback by default, which is where that is safe; anyone exposing +it further is exposing their own choice of numbers, not their recipe history. + +**Cost.** A visitor on the host can see how busy the server is. If that ever +matters, the fix is a scrape token, not a session. + +## Retention records a purge instead of deleting the row + +The schema exists so that "which bytes produced this installed package" stays +answerable years later (§11a). Disk cannot be kept forever, so something has to +give, and the honest option is to let the *bytes* go while the *record* stays. + +**Choice.** Eviction deletes the package, signature, build log and cached +sources of releases beyond the keep window — as a unit, because a package whose +log is gone but whose bytes remain is full price for no explanation — and sets +`purged_at` on the release and its artifact rows. The digest and size survive, so +the database says "these bytes existed, hashed to this, and were dropped at T" +rather than continuing to claim a file that is no longer there. Shared +content-addressed files are reference-checked against every *retained* release +first: two releases built from the same source share one cached archive, and +aging one out must not corrupt the other. + +**Cost.** A `purged_at` column on two tables, and a UI that has to say "bytes no +longer held" rather than offering a download that 404s. + +## The real-chroot integration tier is recorded as skipped, not silently absent + +§16a gates the tier that needs root, network and devtools. On this host the +tier was not run: it requires a privileged Arch chroot (`mkarchroot` over the +real mirror database), a signing key with a real passphrase, and outbound +network to the AUR, none of which the environment provides. + +**What stands in its place.** The shim tier drives the *unmodified* pipeline +against fake tools that produce real archives, and the crash tests kill real +processes with real signals. The parts the gated tier would exercise that the +shims cannot: `mkarchroot`'s actual root construction, `makechrootpkg`'s +copy-on-write snapshot semantics, GPG's passphrase handling, and the behaviour +of a PKGBUILD that escapes its sandbox in ways a symlink does not capture. + +**How to run it.** Install devtools, create a signing key, set `signing_key_id` +and leave `path_prepend` unset so the real tools are found on `PATH`, then +subscribe to a real pkgbase and drive it through `aur-build serve`. -- cgit v1.2.3