git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Hash algorithm analysis

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jun 12, 2018, 00:45 UTC
Message-ID
<CA+55aFyVOeNQPMRj=+qpGY8Ti-tqp9OC6MkfQ9o4OLAfsX14Vw@mail.gmail.com>
In-Reply-To
<878t7kx5t3.fsf@evledraar.gmail.com>

On Mon, Jun 11, 2018 at 4:27 PM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:

Show 10 quoted lines
> >
> > And no, I'm not a cryptographer. But honestly, length extension
> > attacks were how both md5 and sha1 were broken in practice, so I'm
> > just going "why would we go with a crypto choice that has that known
> > weakness? That's just crazy".
>
> What do you think about Johannes's summary of this being a non-issue for
> Git in
> https://public-inbox.org/git/alpine.DEB.2.21.1.1706151122180.4200@virtualbox/
> ?

I agree that the fact that git internal data is structured and all meaningful (and doesn't really have ignored state) makes it *much* harder to attack the basic git objects, since you not only have to generate a good hash, the end result has to also *parse* and there is not really any hidden non-parsed data that you can use to hide the attack.

And *if* you are using git for source code, the same is pretty much true even for the blob objects - an attacking object will stand out like a sore thumb in "diff" etc.

So I don't disagree with Johannes in that sense: I think git does fundamentally tend to have some extra validation in place, and there's a reason why the examples for both the md5 and the sha1 attack were pdf files.

That said, even if git internal ("metadata") objects like trees and commits tend to not have opaque parts to them and are thus pretty hard to attack, the blob objects are still an attack vector for projects that use git for non-source-code (and even source projects do embed binary files - including pdf files - even though they might not be "as interesting" to attack). So you do want to protect those too.

And hey, protecting the metadata objects is good just to protect against annoyances. Sure, you should always sanity check the object at receive time anyway, but even so, if somebody is able to generate a blob object that hashes to the same hash as a metadata object (ie tree or commit), that really could be pretty damn annoying.

And the whole "intermediate hashed state is same size as final hash state" just _fundamentally_ means that if you find a weakness in the hash, you can now attack that weakness without having to worry about the attack being fundamentally more expensive.

That's essentially what SHAttered relied on. It didn't rely on a secret and a hash and length extension, but it *did* rely on the same mechanism that a length extension attack relies on, where you can basically attack the state in the middle with no extra cost.

Maybe some people don't consider it a length extension attack for that reason, but it boils down to much the same basic situation where you can attack the internal hash state and cause a state collision. And you can try to find the patterns that then cause that state collision when you've found a weakness in the hash.

With SHA3 or k12, you can obviously _also_ try to attack the hash state and cause a collision, but because the intermediate state is much bigger than the final hash, you're just making things *way* harder for yourself if you try that.

              Linus
Previous: David LangNext: brian m. carlson
Message 8 of 66 in “State of NewHash work, future directions, and discussion”
  1. brian m. carlsonJun 9, 2018
  2. Ævar Arnfjörð BjarmasonJun 9, 2018
  3. Hash algorithm analysisbrian m. carlson, Jun 9, 2018
  4. Jonathan NiederJun 11, 2018
  5. Linus TorvaldsJun 11, 2018
  6. Ævar Arnfjörð BjarmasonJun 11, 2018
  7. David LangJun 12, 2018
  8. Linus TorvaldsJun 12, 2018
  9. brian m. carlsonJun 11, 2018
  10. Gilles Van AsscheJun 12, 2018
  11. brian m. carlsonJun 13, 2018
  12. Gilles Van AsscheJun 15, 2018
  13. brian m. carlsonJul 20, 2018
  14. Jonathan NiederJul 21, 2018
  15. Ævar Arnfjörð BjarmasonJul 21, 2018
  16. brian m. carlsonJul 21, 2018
  17. Johannes SchindelinJul 21, 2018
  18. Linus TorvaldsJul 21, 2018
  19. brian m. carlsonJul 21, 2018
  20. Eric DeplagneJul 22, 2018
  21. brian m. carlsonJul 22, 2018
  22. Eric DeplagneJul 22, 2018
  23. Johannes SchindelinJul 26, 2018
  24. Joan DaemenJul 22, 2018
  25. Adam LangleyJul 22, 2018
  26. Johannes SchindelinJul 26, 2018
  27. demerphqJul 23, 2018
  28. Sitaram ChamartyJul 23, 2018
  29. demerphqJul 23, 2018
  30. Linus TorvaldsJul 23, 2018
  31. Stefan BellerJul 23, 2018
  32. Jonathan NiederJul 23, 2018
  33. Edward ThomsonJul 24, 2018
  34. Linus TorvaldsJul 24, 2018
  35. Jonathan NiederJul 24, 2018
  36. Junio C HamanoJul 24, 2018
  37. brian m. carlsonJul 24, 2018
  38. Johannes SchindelinJul 30, 2018
  39. Dan ShumowJul 30, 2018
  40. Jonathan NiederAug 3, 2018
  41. Joan DaemenSep 18, 2018
  42. Jonathan NiederSep 18, 2018
  43. Linus TorvaldsSep 18, 2018
  44. 0/2 document that NewHash is now SHA-256Ævar Arnfjörð Bjarmason, Jul 25, 2018
  45. 1/2 doc hash-function-transition: note the lack of a changelogÆvar Arnfjörð Bjarmason, Jul 25, 2018
  46. 2/2 doc hash-function-transition: pick SHA-256 as NewHashÆvar Arnfjörð Bjarmason, Jul 25, 2018
  47. Junio C HamanoJul 25, 2018
  48. Jonathan NiederJul 25, 2018
  49. Junio C HamanoJul 25, 2018
  50. 2/2 doc hash-function-transition: pick SHA-256 as NewHashÆvar Arnfjörð Bjarmason, Jul 26, 2018
  51. Jonathan NiederAug 3, 2018
  52. Junio C HamanoAug 3, 2018
  53. Linus TorvaldsAug 3, 2018
  54. Linus TorvaldsAug 3, 2018
  55. Ævar Arnfjörð BjarmasonAug 3, 2018
  56. Jonathan NiederAug 4, 2018
  57. brian m. carlsonAug 3, 2018
  58. brian m. carlsonJul 25, 2018
  59. Ævar Arnfjörð BjarmasonJun 11, 2018
  60. Johannes SchindelinJun 21, 2018
  61. brian m. carlsonJun 21, 2018
  62. Duy NguyenJun 11, 2018
  63. brian m. carlsonJun 12, 2018
  64. Jonathan NiederJun 11, 2018
  65. brian m. carlsonJun 12, 2018
  66. Jonathan NiederJun 12, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.