rpm-software-management / yum

[DEPRECATED] YUM package manager
GNU General Public License v2.0
127 stars 87 forks source link

Bug fix: handle multiple signing keys gracefully. #128

Closed ericdand closed 3 years ago

ericdand commented 3 years ago

As-is today, yum does not handle repository signing pubkeys properly:

  1. It only marks the first key in an imported keyring as trusted, even if there are multiple keys in the keyring, but it still imports all the keys.
  2. It only checks the first signature on a repo, even if there are multiple signatures.

As a result of these two flaws, if a key is imported as the second (or third, or fourth, or ...) key in a keyring and then later becomes the first key in the signature (perhaps the old first key expired, and the second key became the new first key), yum will always fail to verify the signature, even though it has the key and GPG tells it it's valid, since it never marked the key as trusted when it first imported it. It will also never re-import the key or mark it as trusted, even if the upstream keyring is updated to have that key first, since it already imported the key (it just neglected to mark it as trusted).

The changes in this PR should make yum properly support signing key expiry and rotation, and repos which use multiple signing keys.

james-antill commented 3 years ago

Pretty sure the idea was originally there would only be single keys in certain places, which is why you can have CA keys etc. Most of this never made it to production anyway, and the patch seems fine (probably better to distinguish between other sigs being unknown vs. actually bad/invalid ... but still better than what we do now).