Gentoo Archives: gentoo-dev

From: Rich Freeman <rich0@g.o>
To: gentoo-dev <gentoo-dev@l.g.o>
Subject: Re: [gentoo-dev] proposal: use only one hash function in manifest files
Date: Wed, 06 Apr 2022 01:33:55
Message-Id: CAGfcS_mH44-PemSDnCKvGhefss_25yW=LsfvDORQi18Ffmg28w@mail.gmail.com
In Reply to: Re: [gentoo-dev] proposal: use only one hash function in manifest files by Sam James
1 On Tue, Apr 5, 2022 at 8:05 PM Sam James <sam@g.o> wrote:
2 > > On 5 Apr 2022, at 22:13, Jonas Stein <jstein@g.o> wrote:
3 > >
4 > >> In other words, what are we actually getting by having _both_ SHA2-512
5 > >> and BLAKE2b for every file in every Manifest?
6 > >
7 > > Implementations are often broken and we have to expect zero day attacks on hashes and on signatures. Hence it does not hurt to have a second hash.
8 >
9 > I don't think this is the case. They're not broken often, it's a very very big deal when they do, and we'd also have far bigger problems in such a case (as already pointed out, TLS would be an issue, but also GPG signatures, git commit hashes, ...).
10
11 Our security fails currently if EITHER SHA2-512 or a hardened version
12 of SHA-1 are defeated. Our top gpg signature is bound to a git commit
13 record by SHA2-512, and the git commit record is bound to everything
14 else in the repository (including the manifest objects) by SHA-1,
15 because git hasn't transitioned away from that (as far as I'm aware it
16 is still a work in progress - the SHA-1 algorithm it uses is hardened
17 against known attacks).
18
19 That said, I think there is still an argument for having two hashes in
20 the manifests. If we have two independent manifests, then if either
21 SHA-1 or SHA2-512 are defeated all we need to do is update git+gpg to
22 the patched version (which no doubt would be rushed into a release
23 quickly), and then do a commit to the repo and sign it with the Gentoo
24 key. The new commit would have a full set of new hashes using a
25 secure hash function, and then a back-reference to the previous commit
26 using SHA-1 (assuming we didn't rebase the entire tree and lose all
27 our historical gpg signatures - we might consider creating a new repo
28 and saving a historical one). That would have new hashes all the way
29 from the top commit down to all the objects it references, so the top
30 commit would now be secure. When signed with an updated gpg the
31 signature would be attached with a secure hash. So now we're secure
32 again. If we're concerned about old signatures getting recycled in
33 preimage attacks we could of course revoke the key and issue a new
34 one.
35
36 What we don't need to do is redo all the manifests, and that is
37 important because we don't actually have the ability to redo those
38 centrally. Anybody can add a commit to the repo and re-sign it, but
39 we'd need all the maintainers to go through and generate new manifests
40 for anything that is fetch-restricted, or aggressively treeclean.
41
42 So it isn't that having two hashes can't fail, but rather that if it
43 does fail it is easier to recover.
44
45 >
46 > >
47 > > It is very likely that we can not trust in X for a while in the next years, but it is very unlikely that two different implementations are affected.
48 > >
49 >
50 > I don't think it is likely that e.g. SHA512 will be broken in the next few years, no, but if it is going to be, we have far bigger issues and we'd need to have double algorithms in our whole stack, which we don't have.
51
52 I agree that this is an unlikely scenario, so it is a judgement call
53 as to whether the ease of recovery in the event of a failure is worth
54 the cost to maintain the second hash. I agree that we'd need double
55 algorithms in the whole stack to prevent a failure, but in the current
56 state we do have advantages for recovering from a failure after the
57 fact.
58
59 It seems that the likely scenario is that we get advance warning of
60 weaknesses in a hash function, but without a practical exploit being
61 readily available. In that case we could do a more orderly
62 transition. We'd still save time with the double hashed manifests,
63 and whether this makes a difference is hard to say.
64
65 >
66 > > Additionally calculating a second hash does not cost anything.
67 >
68 > It does have a cost at both Manifest-generation time and emerge-time.
69
70 This is certainly true, though if the current algorithm is reading the
71 files twice we could at least fix that.
72
73 I don't really have a strong opinion here. I just wanted to point out
74 the recovery benefit of having two hashes on just the manifests, given
75 that it isn't easy to access all the distfiles. I also wanted to
76 point out that we have SHA-1 exposure today, at least in git.
77
78 --
79 Rich

Replies

Subject Author
Re: [gentoo-dev] proposal: use only one hash function in manifest files "Jason A. Donenfeld" <zx2c4@g.o>