[CentOS] yum/RPM and Trust on First Use

Gordon Messmer
2015-12-19T10:12:00Z

On 12/15/2015 07:05 PM, Alice Wonder wrote:
> The first time yum installs a package, it asks to import the GPG key
> used to sign the packages. Most people accept without validating the key.

While that is true, it is important to note that yum will only import
keys that are already installed on disk, in /etc/pki/rpm-gpg.  Which
means that only keys that were *previously* installed from a trusted
source can be added to the trust database. Initially, that set comes
from your install media.  Assuming that you verified the sum of the
media you used for installation, this is a reasonably secure mechanism.

> This is potentially exploitable because most repositories are http

http repositories don't impact the security of this mechanism in any
way.  If you're worried about the package verification process, the big
risk that exists in the current implementation (assuming that you trust
your install media) is that users are allowed to install repositories
that are configured with both gpgcheck=0 AND an http:// URL.  That
combination could lead to a compromise through a MITM attack, but only
if a third-party repository is added, and that repo doesn't provide any
security at all.

> The DNS record could be DNSSEC secured (I believe Fedora already uses
> DNSSEC - some of their servers anyway) and yum could refuse to ask if
> the fingerprint of the key it is importing does not match the DNSSEC
> secured fingerprint.
...
> When yum is first asked to import a key, it refuses if it can not
> DNSSEC validate the fingerprint.

And what should it do at sites where there's no DNSSEC validation
available?  Are they unable to install packages?

Should it fall back to its current behavior?  I think that's an
important question, because if you're trying to improve security in the
face of a MITM attack, you have to be able to demonstrate that security
is actually better *during an attack*.  If a MITM can simply cause the
client to fall back to its current behavior in order to launch a
hypothetical attack, your solution isn't suitable.

> Furthermore when a signing key has been compromised (happened with
> Fedora once) changing the DNS record would prevent the key from being
> imported in the future, and could even prevent packages signed by that
> key from being installed in the future even if the key is already
> imported.

If you're going to verify the key against a DNS record for every package
you install, forever, why have a GPG keyring at all?