Repository navigation
Conversation
…when it expires Importing a repository signing key accepted any v4 Ed25519 key with a key that may sign, and the signer was the newest subkey with the signing flag, whatever its expiry or revocation: InRelease and Release.gpg were signed with a key apt refuses (EXPKEYSIG, REVKEYSIG). The certificate's self-signatures now decide, each verified with the primary key and the newest of its kind holding: the import refuses a key whose primary key is expired or revoked, with the reason, and skips an expired or revoked signing subkey (refusing the key when none that may sign is left). The signer is chosen among the keys valid now, so a key that expires after its import stops signing: the repository's other keys sign the index, and with none left the index is not made and its files answer 503 with the reason. The admin API returns a key's expiry (expires_at) and the signing keys panel shows it, and marks expired keys. Fixes #768 Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_012e6DJaQXxhrXDgeHFf6ZA1
The unit test of a key's shown expiry read the clock again for the expected value, a second later than the key was made when the two reads fell on either side of a second. The expected expiry is now the key's own creation time plus its lifetime, in the integration test too, which also makes another short-lived key when a slow machine let the first one expire before its import, and checks the signature of the key about to expire only on an index that was fetched before it did. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_012e6DJaQXxhrXDgeHFf6ZA1
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #768
Problem
Importing a repository signing key accepted any v4 Ed25519 key with a key that may sign, and
signer()took the newest subkey with the signing flag. Neither looked at expiry or revocation, soInReleaseandRelease.gpgwere signed with a key apt refuses (EXPKEYSIG,REVKEYSIG) andapt-get updatefailed for every client.What changes
Reading the certificate (
crates/server/src/indexes/signing.rs,Certificate). Validity is read from the key's own signatures, and only from ones that verify with the primary key; a signature that is merely present (another key's certification, a forged revocation) says nothing.Import. A key whose primary key is expired or revoked is refused with the reason (
the key expired on 2024-01-31 00:00 UTC,the key is revoked). Expired and revoked signing subkeys are skipped: the newest valid one signs, else the primary key if it may sign. When none is left the import is refused, naming each subkey and why.Signing.
signer()chooses among the keys valid now, on every signature. It still signs with Ed25519 only: if the key it would fall back to is of another algorithm, the key does not sign.A key that expires after it was imported (the decision the issue leaves open):
key.asc/key.gpg. The server logs a warning naming the key and the reason.InRelease,Release,Release.gpg,Packages,key.asc) answer503with a body naming the key and the reason, and the server logs an error. Package uploads and downloads go on. Adding a key (generated or imported) brings the index back.EXPKEYSIG.never expires,expires <date>(a warning badge within 30 days) orexpired <date>. An expired key beside a valid one gets a warning notice; when every key has expired, a danger notice says nothing signs and what to do.Admin API and UI.
GET/POST /admin/repositories/{name}/signing-keysreturnexpires_at(nullfor never): when the primary key expires, or the last of the keys that may sign. It is read from the stored certificate, so there is no migration and keys stored before this change show it too. The panel (web/src/components/SigningKeysPanel.tsx) shows it.Docs and changelog.
docs/apt.md(Signing keys) describes all of the above; fragmentdocs/changes/2.2.0/768.fixed.md. The issue was inBacklogand is moved to2.2.0, the next release.Tests
indexes::signing): expired primary, revoked primary, expired subkey, revoked subkey (each with a primary key that may sign, which takes over, and one that may not, which is refused), a key expiring later (accepted, expiry reported),signer_atno longer choosing a subkey or key that expired since the import, the newest self-signature holding whatever its position, and forged revocations and expiries being ignored.crates/server/tests/apt.rs,signing_keys_expire): the admin API refuses expired and revoked keys with the reason and returnsexpires_at; a key expiring during the test drops out ofInReleaseandRelease.gpg; with only that key left the index files answer 503 with the reason while uploads and downloads work; adding a key restores the index.SigningKeysPanel.test.tsx): the expiry labels and both notices.The import tests and the integration test fail on
main(the expired key is imported, 201 instead of 400) and pass here.Checked by hand against GnuPG 2.4.4: keys made with
gpg(expired primary, revoked primary, expired and revoked subkeys, an expiry extended with--quick-set-expire, future expiries) are refused or accepted asgpg --list-keysrates them, with the same expiry dates; the keys the unit tests build are rated the same bygpg --show-keys; andgpgvreports a good signature for each accepted key.Not in this pull request
.github/scripts/apt-e2e.sh(realapt-get) has no step for this, and I did not run it or the Playwright suite.Generated by Claude Code