|
|
Subscribe / Log in / New account

Removing SHA-1 for signatures in Fedora

By Jake Edge
March 15, 2022

Disruptive changes are not much fun for anyone involved, though they may be necessary at times. Moving away from the SHA-1 hash function, at least for cryptographic purposes, is probably one of those necessary disruptive changes. There are better alternatives to SHA-1, which has been "broken" from a cryptographic perspective for quite some time now, and most of the software components that make up a distribution can be convinced to use other hash functions. But there are still numerous hurdles to overcome in making that kind of a switch as a recent discussion on the Fedora devel mailing list shows.

How to?

On March 8, Alexander Sosedkin posted a lengthy message asking for help in "planning a disruptive change" to switch Fedora away from SHA-1. Currently, SHA-1 is disabled for TLS, he said, but SHA-1 use is more widespread than that; cryptographic signatures for packages may use SHA-1 and other libraries, such as OpenSSL, are still using the older hash algorithm in some cases. But Fedora does not need to be first on doing the switch:

Good news is, RHEL-9 is gonna lead the way and thus will take a lot of the hits first. Fedora doesn't have to pioneer it. Bad news is, Fedora has to follow suit someday anyway, and this brings me to how does one land such a change.

He does not think this kind of change can be done in a single Fedora release cycle, in part because finding and fixing all of the uses of SHA-1 is going to require breaking things: "the only realistic way to weed out its reliance on SHA-1 signatures from all of its numerous dark corners is to break them. Make creation and verification fail in default configuration." But because Fedora has fairly short release cycles (six months or so between releases), even doing that will not give developers enough time to fix the problems—if they are even brought to light.

Maintainers need time to get bugs, look into them, think, analyze, react and test --- and that's just if it fails correctly! Unfortunately, it's not just that the error paths are as dusty as they get because the program counter has never set foot on them before. Some maintainers might even find that picking a different hash function renders their code non-interoperable, or even that protocols they implement have SHA-1 hardcoded in the spec. Or that everything is ready, but real world deployments need another decade. Or that on-disk formats are just hard to change and migrate.

He suggested several possible approaches, but did not think that simply announcing the change would be enough to cause all of the changes needed, likening it to the bypass announcements in the The Hitchhiker's Guide to the Galaxy. Breaking the creation and use of SHA-1 signatures in, say Fedora 37 Rawhide, backing it out for the release, then doing so again for Fedora 38 (without the back-out), might be one way. Another might be to break it in Rawhide and leave it that way, but unbreak it for the first release. "But these are all rather... crude?" He would rather find a smoother process, preferably one that had been used before.

Breaking things

Zbigniew Jędrzejewski-Szmek was not in favor of breaking things in order to flush out the problem areas. "We should make newer hashes the default, and we can make tools print a warning if sha1 is used where it shouldn't, but please don't break things on purpose." He also noted that SHA-1 is perfectly reasonable to use in non-cryptographic settings. Beyond that, existing signatures that use SHA-1 need to be verifiable "essentially forever" and signatures using it will be provided going forward—Fedora cannot dictate signature policies to others—so being able to check them will always be important. The situation is similar to self-signed TLS certificates, where disallowing them completely "will only result in users jumping to different tools".

The focus of the effort is only on blocking cryptographic signatures using SHA-1, Simo Sorce said; that means "Certificates, TLS session setup, DNSSEC (although a lot of signatures are still SHA-1 based there ...), VPNs session establishment, PGP, etc..." While he did recognize that verifying SHA-1 signatures would still need to be supported by Fedora, he said that by default it should be blocked. Verifying signatures on older content should be reserved for local data, not things coming over the network:

This is only reasonable for stuff like emails, where you may have a reasonable expectation that the archived messages have not been tampered with after the fact. Allowing verification of signatures with SHA-1 for any "online" communication would be pointless.

Neal Gompa was concerned that "breaking" SHA-1 verification might also "break Fedora's *own* GPG keys and the GPG keys of preferred third party repositories". He encountered a problem of that sort when a similar change was made for CentOS, but Demi Marie Obenour said that all of the official RPM packages back to at least Fedora 25 have SHA-256 signatures. Gompa listed several third-party repositories, RPM Fusion, Google, Copr, and Microsoft, that might be affected; it turns out that Fedora's Copr repository was affected by the CentOS 9 change that Gompa mentioned, as reported more fully by Gary Buhrmaster. There is a bug report tracking the switch to use SHA-256 signatures for Copr going forward.

Sosedkin disagreed with Jędrzejewski-Szmek's idea that warnings would suffice; "Cryptographic libraries aren't in position to do any meaningful logging, and even if they did, it'd be gleefully ignored until we break things." He was skeptical that there was any other way to make this kind of change, though backward compatibility is important: "Yes, you can still make a modern Fedora do RC4 or DES, with just a little bit of extra configuration. No, we must phase things out of defaults, there's no way around this."

The configuration he is referring to is to change the setting in /etc/crypto-policies/config and then run update-crypto-policies as described in a feature added for Fedora 21. There are three pre-defined settings available: LEGACY, DEFAULT, and FUTURE. Those will reconfigure various libraries to different levels of cryptographic strength. Since the policy option was added, support for more libraries has been added, and the policies themselves updated for Fedora 28 and for Fedora 33.

RHEL 9

Daniel P. Berrangé asked what has been learned from the under-development RHEL 9, which will help lead the way for Fedora. He asked about the number and percentage of RHEL 9 packages that were affected by the switch in order to get a better idea what the impact will be for Fedora. "Assuming RHEL-9 has dealt with the problems, Fedora should inherit those fixes, which gives us a good base for the most commonly used / important packages in Fedora." He suggested that perhaps there might only be "a few important remaining packages" that need to be evaluated, leaving the others to potentially fail, given that there is the LEGACY fallback.

Sosedkin seemed skeptical of that approach. He noted that RHEL 9 is not yet widely available, so the number of broken packages for it is still unknown. Furthermore, RHEL has roughly 10% of the packages that Fedora carries, so "leaving the 90% of the packages you've labelled 'less important' to be 'fixed after the fact' is gonna be a disaster." He reiterated that he did not think a single cycle would be sufficient time to handle the problems.

While the 90% of Fedora packages will not have been tested as part of RHEL 9, Berrangé said, that does not mean they are likely to be affected by this change. "Only a relatively small subset will do anything crypto related, and most of that just be HTTPS and completely outsourced to a crypto library." He thought it possible that only a few of those packages will be using cryptographic signatures with SHA-1, and even less "will be considered important enough to be blockers for this change".

An explicit example of the kinds of problems that will be encountered was pointed out by Alexander Bokovoy. The Kerberos network-authentication protocol requires the use of SHA-1 "due to interoperability issues and also due to compliance with RFCs". He noted a March 4 bugzilla entry that reported the problem; the "fix" for RHEL 9 will be to override any restrictions on SHA-1 in OpenSSL for Kerberos, while other options "will be discussed upstream". Fedora will pick up that fix, of course, but it does show that these kinds of problems will crop up unexpectedly.

Warnings

Berrangé also brought up the idea of using "a scary warning message" on stderr or in the system logs. That could be turned on for a release cycle to see which bugs get reported. Sosedkin said that warnings to the log files would result in zero bugs being filed, while stderr reports would simply result in bugs about "'$CRYPTOLIB has no business messing up my stderr/stdout', which we'll promptly close by reverting the changes".

Fedora project leader Matthew Miller agreed with the thought, though it was "a little more cynically-phrased than I'd put it". He suggested logging the problem and having a tool that specifically looked for those log messages, "we could do something like a Test Day where people could send in reports". While Sosedkin still thought that logging from cryptographic libraries was "risky territory", it was a better approach than logging to stderr; "Especially if it accompanies a drawn-out multicycle change, it could be a noticeable impact dampener."

The problem with logging, however, is that it may not be available to the library, depending on the execution environment of the program, Berrangé said:

Security policies applied to [processes] (SELinux, seccomp, namespaces or containerization in general) can easily prevent ability to use journald, syslog, or opening of log files, leading to messages not being visible. At worst, with seccomp an attempt to use the blocked feature may lead to an abort of the application.

Sosedkin was concerned that applications might be reopening the stderr file descriptor in strange ways, resulting in "writing our scary messages who knows where", but Berrangé said that is fairly unlikely precisely because various libraries already print warnings and errors to stderr when needed. "Even glibc will print to stderr when it sees malloc corruption, and stuff in stderr will end up in the systemd journal for any system services."

SSH?

Older SSH protocols use SHA-1, so Richard W.M. Jones wondered if the change would cause problems using SSH. "This broke before, requiring us to advise users to set the global policy for the machine to LEGACY (thus ironically weakening crypto for everything)." He also noted that he has some "ancient network equipment" that requires the LEGACY setting on Fedora in order to be able to connect to it. He asked if the changes Sosedkin wants to make will further impact SSH.

SSH uses SHA-1 as a hash-based message authentication code (HMAC), Sosedkin said, "which doesn't rely on collision resistance", so no change needs to be made. Obenour agreed that using SHA-1 as an HMAC is reasonable, though there are alternatives that perform better; "There are no known attacks on HMAC-SHA-1".

Goals

Along the way, Sosedkin listed his objectives in raising the issue:

I want to know, ultimately, how can I break it for devs but not the users so that
  1. the need for it is communicated early,
  2. all the relevant places are timely identified,
  3. maintainers have a plenty of time to resolve it for good or opt out,
  4. and the users are affected as late and as smoothly as possible.
Hope these are all reasonable things to wish for.

As yet, it does not seem that there is a clear plan that would meet those goals. It is a difficult problem, but one that seems likely to recur over time. Cryptographic algorithms and protocols change over time, generally because weaknesses are found in them; once they become entrenched in a distribution, and the internet itself, they are hard to excise. Finding a way to remove SHA-1 smoothly—as smoothly as possible, at least—will be a useful thing to figure out. It seems likely that more discussion will be required to get there.



to post comments

Removing SHA-1 for signatures in Fedora

Posted Mar 15, 2022 22:21 UTC (Tue) by khim (subscriber, #9252) [Link] (7 responses)

Can anyone explain what I'm missing?

  1. We have special tool made just to handle that case.
  2. We want to get what that tool is designed to provide (programs are broken for developers, not users).
  3. Yet we refuse to use it, because… umm… why exactly it's not supposed to be used?

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 3:08 UTC (Wed) by nevyn (guest, #33129) [Link] (1 responses)

Fedora recompiles everything each release, so having a new symbol (and maybe new config. options) just to remove sha1 as a default allowed signature still affects all users using all Fedora binaries.

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 11:30 UTC (Wed) by khim (subscriber, #9252) [Link]

That's self-inflicted wound: just create a separate shim libraries and use them to compile programs which misbehave with SHA1 disabled.

Third-party apps (which you couldn't test) wouldn't be affected. And you may even do what Android does: certain other, new, libraries would be incompatible with these shims. That way developers would be forced to stop using them if they want new features.

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 17:48 UTC (Wed) by hkario (subscriber, #94864) [Link] (4 responses)

That's because the behaviour of the symbols isn't changing to make developers lives easier.
It's changing because with the exception of verifying signatures you can prove were made way, way back, you should really not trust SHA-1 signatures.

It doesn't matter if my mail client was compiled 10 years ago, I don't want it to trust SHA-1 signatures today because they could have been forged yesterday.

The other problem is that the RHEL-9 change doesn't remove SHA-1 hash, or any symbols associated with it, it forbids the combination of SHA-1 and public key cryptography.

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 22:20 UTC (Wed) by khim (subscriber, #9252) [Link] (3 responses)

> It doesn't matter if my mail client was compiled 10 years ago, I don't want it to trust SHA-1 signatures today because they could have been forged yesterday.

You can not have your cake and eat it, too. Deal with it.

Either API, which may your mail client uses, was extensible exough and it would transparently switch to SHA-512 or something… or it wasn't flexible and you need to change source and recompile it.

There are no silver bullet or magic wand which may solve that dilemma.

It's the same story as with Y2K change.

> The other problem is that the RHEL-9 change doesn't remove SHA-1 hash, or any symbols associated with it, it forbids the combination of SHA-1 and public key cryptography.

What does it change? Yes, it affects not the raw low-level libcrypto, but higher-level libssl (and other such libraries).

Approach doesn't change, target does.

Removing SHA-1 for signatures in Fedora

Posted Mar 17, 2022 11:28 UTC (Thu) by hkario (subscriber, #94864) [Link] (2 responses)

> Either API, which may your mail client uses, was extensible exough and it would transparently switch to SHA-512 or something… or it wasn't flexible and you need to change source and recompile it.

You're completely missing the issue.

The problem is not what my client creates. It's about what my client will accept from the network. And my client was able to accept SHA-256 and SHA-512 10 years ago, the problem is that what it gets doesn't depend on my client, it's completely up to the sender.

What's changing, is the set of algorithms the underlying cryptographic library will accept when verifying the signatures. Now that set doesn't include SHA-1, just like it didn't include MD4 and MD5. The difference being that SHA-1 was far more widespread than MD5 so deprecating it is much more complex.

Or to put it other way, just like certificates have expiry dates on them, so do hashes. Just because a certificate worked yesterday doesn't mean it will work today. It just isn't as clear-cut with hashes.

Removing SHA-1 for signatures in Fedora

Posted Mar 21, 2022 4:56 UTC (Mon) by mathstuf (subscriber, #69389) [Link] (1 responses)

> Or to put it other way, just like certificates have expiry dates on them, so do hashes.

It seems like the API for verifying signatures needs to be richer then. Allow verifying anything, but have it decorated with an "expiry date" kind of tag so that you can get tags like:

> Verified (trusted)
> Verified (be suspicious if signed after 2022-01)

Basically, it sounds like a simple boolean is just not rich enough to convey signature validity.

Removing SHA-1 for signatures in Fedora

Posted Mar 21, 2022 19:03 UTC (Mon) by hkario (subscriber, #94864) [Link]

There has been interfaces to perform certificate verification at a given time for decades now.
The thing is that basically no signature includes a trustworthy timestamp that allows you to perform verification at any other time than *now*.

Those interfaces are used for systems that handle CAdES or PAdES, not S/MIME, SSH and TLS.

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 4:35 UTC (Wed) by pabs (subscriber, #43278) [Link] (1 responses)

It would be great to have a way to turn off SHA-1 on a system so that things depending on SHA-1 could be discovered and fixed.

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 17:49 UTC (Wed) by neverpanic (subscriber, #99747) [Link]

Working on it, stay tuned.

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 9:11 UTC (Wed) by taladar (subscriber, #68407) [Link] (10 responses)

Removing SHA-1 should only be a secondary goal here in my opinion. The primary goal should be the introduction of a mechanism that makes removal of insecure cryptographic algorithms in general easier in the future in software affected by making uses and implementations easier to discover as well as making algorithms configurable where they are used and flexible where they are part of some standard.

Also, am I missing something or are they forgetting about the elephant in the room when it comes to SHA-1 use, git.

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 10:17 UTC (Wed) by pbonzini (subscriber, #60935) [Link] (8 responses)

git does not use SHA1 for signing, only as a message digest.

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 11:49 UTC (Wed) by foom (subscriber, #14868) [Link] (7 responses)

Git's signatures are pretty-much worthless if sha1 is considered fully broken, because all that's signed is name, email, time, message, and the sha1 hash of the commit or tree object the signature is for.

https://git-scm.com/docs/signature-format

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 12:00 UTC (Wed) by pbonzini (subscriber, #60935) [Link] (6 responses)

If you have a non-malicious commit and would like to distribute a forged commit with different contents, you would need a second preimage attack, which is a very different thing from all current practical (or almost-practical) attacks on SHA-1. All such attacks are collision attacks, and would only be usable by maintainers that are themselves malicious.

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 13:35 UTC (Wed) by foom (subscriber, #14868) [Link] (5 responses)

So, the collision issue arises when one (malicious) entity authors some content, and another (trusted) entity reads and validates the content, and then signs it using a sha1 hash.

In that case, the trusted entity can be tricked into signing a sha1 hash created by the malicious one, with an intentional collision: one signed content which is innocent/expected, and another with the same hash -- and thus same signature -- that is malicious, and appears to have been signed.

This seems like a completely feasible attack scenario for git. Someone contributes an innocent looking change, which gets approved by the maintainer and a signed tag for release.

Of course, a mitigating factor is that not that many (if any) people even rely on git signatures in the first place as a way of validating content. Much more common is to fetch from a trusted host over tls, and implicitly trust the resulting content.

And another is that git switched to a Sha1 variant which is supposedly more collision resistant, but I don't know how safe that actually is.

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 14:27 UTC (Wed) by epa (subscriber, #39769) [Link] (4 responses)

It sounds as though the maintainer could defeat that attack by adding some random data to the commit message before signing. Or perturb the timestamp, perhaps by cherry-picking the change into a new commit, which can then be signed. That makes life more awkward for the original contributor when merging back, but only slightly.

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 17:24 UTC (Wed) by neverpanic (subscriber, #99747) [Link] (1 responses)

Some work is being done to add better collision resistance to GitHub/Git despite its use of SHA-1: https://github.blog/2017-03-20-sha-1-collision-detection-.... I couldn't immediately find a reference to their work with upstream on the mailing list, but I have also not done an extensive search.

Yes, it should also go, and it sounds like the Git developers are working on this. However, it would not be affected by this particular change, since from the OpenSSL library's point of view, Git's use of SHA-1 looks like a message digest only.

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 23:51 UTC (Wed) by nix (subscriber, #2304) [Link]

The reason why you can't find any recent references to this work is that it's done: the collision-detecting SHA-1 implementation you cite has been the default in git for years now, and the only available implementation for a year or so (it's slower than accelerated implementations, but the actual slowdown in practical git use is a percent or two at most: insignificant).

Removing SHA-1 for signatures in Fedora

Posted Mar 16, 2022 22:43 UTC (Wed) by NYKevin (subscriber, #129325) [Link] (1 responses)

Traditionally, hashes are designed to be secure against three kinds of attack:

1. Preimage attacks, in which the adversary is given a digest, and wants to compute some plaintext that hashes to that digest.
2. Second-preimage attacks, in which the adversary is given both a plaintext and a digest, and wants to create a different plaintext with the same digest.
3. Collision attacks,in which the adversary is given nothing, and wants to create two plaintexts with the same digest.

These properties are generally regarded as sufficient, in the sense that "most" (or preferably all) direct attacks against a cryptographic scheme which relies on a hashing algorithm will necessarily be reducible to one of those three attacks. That is, if you can perform attack X, for arbitrary X, then you can convert X into one of (1), (2), and (3), provided the cryptographic system is properly designed. As a consequence, if the hash function is secure against (1), (2), and (3), then it is also secure against X, for any value of X.

The problem is, when we no longer have security against (3), we have to start worrying about other attacks that can be reduced to (3) but can't necessarily be reduced to (1) or (2). My concern is that, if we start doing this sort of ad-hoc adjustment ("add a few random bytes here, perturb a few nonce bytes there..."), that does not actually recreate security against collision attacks, and therefore there may be more complicated attacks which are capable of defeating the modified scheme (e.g. a "tamper-resistant collision attack" which is not equivalent to a full second-preimage or preimage attack, but is instead a superset of regular collision attacks where we allow some limited modifications to the first plaintext, outside of the adversary's control, which the adversary gets to see before they create their second plaintext).

My other concern is that cryptography is hard and the adversaries are probably smarter than I am.

Removing SHA-1 for signatures in Fedora

Posted Mar 17, 2022 8:24 UTC (Thu) by nim-nim (subscriber, #34454) [Link]

> My other concern is that cryptography is hard and the adversaries are probably smarter than I am.

They don’t need to be smarter, they just need to luck on a bug and understand its security implications. That’s what scary about defense/attack : the defender needs to perform a perfect job, the attacker just needs some luck once.

Removing SHA-1 for signatures in Fedora

Posted Mar 17, 2022 8:25 UTC (Thu) by rwmj (subscriber, #5474) [Link]

The primary goal should be the introduction of a mechanism that makes removal of insecure cryptographic algorithms in general easier in the future in software affected by making uses and implementations easier to discover as well as making algorithms configurable where they are used and flexible where they are part of some standard.

This is sort of what crypto-policies does. In fact this SHA-1 change is done by changing the system crypto policy, and I don't think very much else changed if anything.

Breaks listing or upgrading SHA-1 RPMs

Posted Mar 17, 2022 8:32 UTC (Thu) by rwmj (subscriber, #5474) [Link] (2 responses)

One thing that isn't clear about this change is that it breaks listing out and upgrading installed RPMs that are using SHA-1 signatures. So it's not only a question of whether third party repos are still using SHA-1, but whether third party repos have ever used SHA-1 signatures and those packages could still be installed.

The way around this is (and indeed any other SHA-1 related problem) is:

update-crypto-policies --set LEGACY

but this is a huge hammer, reducing security across the whole system. This might become the new "disable SELinux" which took years and years to overcome. I asked the developers to look again and see if we can make safer tools:

https://bugzilla.redhat.com/show_bug.cgi?id=2064740

For me the RPM / SHA-1 change particularly affected libguestfs which wants to analyze the RPMs in old guests (eg. RHEL < 5). We worked around it by turning off RPM signature validation, which is (arguably) bad, but it's only for examining already installed RPMs so I guess it'll be OK.

Breaks listing or upgrading SHA-1 RPMs

Posted Mar 17, 2022 23:59 UTC (Thu) by jccleaver (guest, #127418) [Link]

Yeah, the RPM signature incompatibility between EL5 and EL6 was ugly, and a pain during that entire transition for people that were heavily using RPMs for configuration and deployment, with SRPMs going back and forth.

Breaks listing or upgrading SHA-1 RPMs

Posted Mar 23, 2022 6:41 UTC (Wed) by AdamW (subscriber, #48457) [Link]

IIRC it is possible to implement something more finely grained than just "pick DEFAULT or LEGACY" with the crypto-policies system, but it's more complicated and difficult. This again is similar to SELinux, where it's usually a much better idea to create a custom policy than just switch to permissive mode, but doing so is more than a single command so people just use the big hammer...


Copyright © 2022, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds