Removing SHA-1 for signatures in Fedora
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 thatHope these are all reasonable things to wish for.
- the need for it is communicated early,
- all the relevant places are timely identified,
- maintainers have a plenty of time to resolve it for good or opt out,
- and the users are affected as late and as smoothly as possible.
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.
Posted Mar 15, 2022 22:21 UTC (Tue)
by khim (subscriber, #9252)
[Link] (7 responses)
Can anyone explain what I'm missing?
Posted Mar 16, 2022 3:08 UTC (Wed)
by nevyn (guest, #33129)
[Link] (1 responses)
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.
Posted Mar 16, 2022 17:48 UTC (Wed)
by hkario (subscriber, #94864)
[Link] (4 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.
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.
Posted Mar 16, 2022 22:20 UTC (Wed)
by khim (subscriber, #9252)
[Link] (3 responses)
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. What does it change? Yes, it affects not the raw low-level Approach doesn't change, target does.
Posted Mar 17, 2022 11:28 UTC (Thu)
by hkario (subscriber, #94864)
[Link] (2 responses)
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.
Posted Mar 21, 2022 4:56 UTC (Mon)
by mathstuf (subscriber, #69389)
[Link] (1 responses)
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)
Basically, it sounds like a simple boolean is just not rich enough to convey signature validity.
Posted Mar 21, 2022 19:03 UTC (Mon)
by hkario (subscriber, #94864)
[Link]
Those interfaces are used for systems that handle CAdES or PAdES, not S/MIME, SSH and TLS.
Posted Mar 16, 2022 4:35 UTC (Wed)
by pabs (subscriber, #43278)
[Link] (1 responses)
Posted Mar 16, 2022 17:49 UTC (Wed)
by neverpanic (subscriber, #99747)
[Link]
Posted Mar 16, 2022 9:11 UTC (Wed)
by taladar (subscriber, #68407)
[Link] (10 responses)
Also, am I missing something or are they forgetting about the elephant in the room when it comes to SHA-1 use, git.
Posted Mar 16, 2022 10:17 UTC (Wed)
by pbonzini (subscriber, #60935)
[Link] (8 responses)
Posted Mar 16, 2022 11:49 UTC (Wed)
by foom (subscriber, #14868)
[Link] (7 responses)
https://git-scm.com/docs/signature-format
Posted Mar 16, 2022 12:00 UTC (Wed)
by pbonzini (subscriber, #60935)
[Link] (6 responses)
Posted Mar 16, 2022 13:35 UTC (Wed)
by foom (subscriber, #14868)
[Link] (5 responses)
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.
Posted Mar 16, 2022 14:27 UTC (Wed)
by epa (subscriber, #39769)
[Link] (4 responses)
Posted Mar 16, 2022 17:24 UTC (Wed)
by neverpanic (subscriber, #99747)
[Link] (1 responses)
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.
Posted Mar 16, 2022 23:51 UTC (Wed)
by nix (subscriber, #2304)
[Link]
Posted Mar 16, 2022 22:43 UTC (Wed)
by NYKevin (subscriber, #129325)
[Link] (1 responses)
1. Preimage attacks, in which the adversary is given a digest, and wants to compute some plaintext that hashes to that 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.
Posted Mar 17, 2022 8:24 UTC (Thu)
by nim-nim (subscriber, #34454)
[Link]
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.
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.
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:
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:
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.
Posted Mar 17, 2022 23:59 UTC (Thu)
by jccleaver (guest, #127418)
[Link]
Posted Mar 23, 2022 6:41 UTC (Wed)
by AdamW (subscriber, #48457)
[Link]
Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
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.
Removing SHA-1 for signatures in Fedora
libcrypto
, but higher-level libssl
(and other such libraries).Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
> Verified (be suspicious if signed after 2022-01)
Removing SHA-1 for signatures in Fedora
The thing is that basically no signature includes a trustworthy timestamp that allows you to perform verification at any other time than *now*.
Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
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.
Removing SHA-1 for signatures in Fedora
Removing SHA-1 for signatures in Fedora
Breaks listing or upgrading SHA-1 RPMs
update-crypto-policies --set LEGACY
Breaks listing or upgrading SHA-1 RPMs
Breaks listing or upgrading SHA-1 RPMs