Verified against what upstream published
There are two digests in a mirror and only one of them means anything. The hash of what arrived is true of any bytes at all, including a hostile mirror’s; the hash upstream PUBLISHED is a claim you can hold those bytes to. LibWorld records both, separately, and never lets the first be read as the second.
The claim comes from metadata you already fetch
Nothing extra is downloaded to make this work. Every ecosystem publishes its digests in the index the mirror fetches anyway: the #sha256= fragment on each link of a PEP 503 page, dist.integrity in an npm packument, cksum on each line of the cargo sparse index. Those are parsed as the index is cached, and looked up when the artifact itself is fetched — a separate request, often minutes or a restart later, which is why the claims are written down rather than held in memory.
A package that fails this check would have failed on every client afterwards. The difference is that the mirror would have gone on serving it in the meantime, and a cached bad artifact is served faster than a good one.
apt is a signature, and it is a chain
Debian and Ubuntu do not sign individual packages. They sign the Release file, the Release file carries the hash of every index, and each index carries the hash of every .deb in it. Verify the top and follow the links and a package is verified against a GPG signature; check only the package’s hash against an unverified index and you have verified nothing.
LibWorld walks the whole chain. gpgv — the verify-only tool, against exactly the keyring you name and never the ambient one — checks InRelease or Release plus Release.gpg; the Release’s hashes check each Packages index; the index’s hashes check each package. Only SHA256 entries are read: a mirror that accepts MD5 when SHA256 is present has the security of MD5.
A live archive republishes its indexes every few hours, so an index that disagrees is very often a rotation rather than an attack. A mismatch therefore re-fetches the Release, re-checks its signature, and tries once more. A rotation fails once; a substitution fails both times, and the refusal says it re-checked.
What a mismatch does, and what absence does
Bytes that contradict upstream’s own digest are refused BEFORE they are stored, at every setting except off. A mirror that caches them and then reports the problem has already become the thing serving them.
Absence is the only thing the policy setting governs. attested, the default, verifies whenever a claim exists and allows an artifact that has none — because a mirror whose index has not been fetched yet must not start refusing pulls. required refuses an unattested artifact outright, which is what makes "everything in this catalog was checked" a true sentence on an air-gapped mirror.
The catalog records WHICH claim was checked, per artifact, not merely that one was. So apt:Packages and npm:dist.shasum are distinguishable, and the second is recorded as the sha1 it is rather than promoted to something stronger.
What it costs
Stated plainly, because a claim with no stated cost is the one nobody re-checks.
A weak claim is still recorded as weak rather than upgraded. npm packages published before integrity existed carry only a sha1 shasum; LibWorld reports it as sha1 and does not count it as a strong check.
Verification is only as good as the metadata route. If a client fetches an artifact by a URL the mirror has never seen an index for, there is no claim to check it against — under the default policy that artifact is stored unverified, and the catalog says so by leaving its provenance blank.
For apt, a keyring is something YOU configure. Without one the chain still verifies index and package hashes against the Release, which is integrity without authenticity — and a hostile upstream is internally consistent too. /backends reports which of the two is in force rather than leaving it to be assumed.