libdnf icon indicating copy to clipboard operation
libdnf copied to clipboard

Support hash in `gpgkey=` URLs

Open DemiMarie opened this issue 5 years ago • 3 comments

Currently, DNF does not provide a reliable way to authenticate the contents of remote gpgkey= URLs. DNSSEC doesn’t always work (for instance, if libdnf is behind an HTTP proxy) and introduces substantial extra attack surface.

Fortunately, the fragment part of a URL can contain arbitrary data that is not sent to the server. In this case, libdnf can check a cryptographic hash against the downloaded data. One example would be gpgkey=http://example.com/something.gpg#sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU.

DemiMarie avatar Nov 23 '20 20:11 DemiMarie

Wouldn't it be easier to just add a gpgfingerprint= option so that we can have an array of fingerprints to match the array of gpg key files?

Conan-Kudo avatar Nov 24 '20 12:11 Conan-Kudo

These are not mutually exclusive. The hash has two major advantages:

  • It works for all data, not just GPG keys.
  • It protects against exploitable vulnerabilities in GPG’s public key parsers, such as a recent buffer overflow.

DemiMarie avatar Nov 24 '20 15:11 DemiMarie

To elaborate, parsing a general key is significantly more complex than parsing a signature, and is therefore more likely to have exploitable vulnerabilities. I would be fine with a gpgkeyhash= key, though.

DemiMarie avatar Jan 12 '21 18:01 DemiMarie