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

Re: SHA1 collisions found

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Feb 26, 2017, 17:38 UTC
Message-ID
<20170226173851.wxv7j7zibmzpo726@genre.crustytoothpaste.net>
In-Reply-To
<20170225220944.fl7fxirtdtcko4xl@glandium.org>
On Sun, Feb 26, 2017 at 07:09:44AM +0900, Mike Hommey wrote:
Show 26 quoted lines
> On Sat, Feb 25, 2017 at 02:26:56PM -0500, Jeff King wrote:
> > I looked at that earlier, because I think it's a reasonable idea for
> > future-proofing. The first byte is a "varint", but I couldn't find where
> > they defined that format.
> > 
> > The closest I could find is:
> > 
> >   https://github.com/multiformats/unsigned-varint
> > 
> > whose README says:
> > 
> >   This unsigned varint (VARiable INTeger) format is for the use in all
> >   the multiformats.
> > 
> >     - We have not yet decided on a format yet. When we do, this readme
> >       will be updated.
> > 
> >     - We have time. All multiformats are far from requiring this varint.
> > 
> > which is not exactly confidence inspiring. They also put the length at
> > the front of the hash. That's probably convenient if you're parsing an
> > unknown set of hashes, but I'm not sure it's helpful inside Git objects.
> > And there's an incentive to minimize header data at the front of a hash,
> > because every byte is one more byte that every single hash will collide
> > over, and people will have to type when passing hashes to "git show",
> > etc.

The multihash spec also says that it's not necessary to implement varints until we have 127 hashes, and considering that will be in the far future, I'm quite happy to punt that problem down the road to someone else[0].

Show 14 quoted lines
> > I'd almost rather use something _really_ verbose like
> > 
> >   sha256:1234abcd...
> > 
> > in all of the objects. And then when we get an unadorned hash from the
> > user, we guess it's sha256 (or whatever), and fallback to treating it as
> > a sha1.
> > 
> > Using a syntactically-obvious name like that also solves one other
> > problem: there are sha1 hashes whose first bytes will encode as a "this
> > is sha256" multihash, creating some ambiguity.
> 
> Indeed, multihash only really is interesting when *all* hashes use it.
> And obviously, git can't change the existing sha1s.

Well, that's why I said in new objects. If we're going to default to a new hash, we can store it inside the object format, but not actually expose it to the user.

In other words, if we used SHA-256, a tree object would refer to the SHA-1 empty blob as 1114e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 and the SHA-256 empty blob as 1220473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813, but user-visible code would parse them as e69d... and 473a... (or as sha1:e69d and 473a, or something).

There's very little code which actually parses objects, so it's easy enough to introduce a few new functions to read and write the prefixed versions within the objects, and leave the rest to work in the same old user-visible way (or in the way that you've proposed).

Note also that we need some way to distinguish objects in binary form, since if we mix hashes, we need to be able to read data directly from pack files and other locations where we serialize data that way. Multihash would do that, even if we didn't expose that to the user.

[0] And for the record, I'm a maintenance programmer, and I dislike it when people punt the problem down the road to someone else, because that's usually me.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204
Previous: Mike HommeyNext: Jason Cooper
Message 96 of 136 in “SHA1 collisions found”
  1. Joey HessFeb 23, 2017
  2. Junio C HamanoFeb 23, 2017
  3. Junio C HamanoFeb 23, 2017
  4. David LangFeb 23, 2017
  5. Jakub NarębskiFeb 23, 2017
  6. Jeff KingFeb 23, 2017
  7. Joey HessFeb 23, 2017
  8. Linus TorvaldsFeb 23, 2017
  9. Joey HessFeb 23, 2017
  10. Linus TorvaldsFeb 23, 2017
  11. Jeff KingFeb 23, 2017
  12. Linus TorvaldsFeb 23, 2017
  13. Jeff KingFeb 23, 2017
  14. Linus TorvaldsFeb 23, 2017
  15. Jeff KingFeb 23, 2017
  16. Øyvind A. HolmFeb 23, 2017
  17. Joey HessFeb 23, 2017
  18. Joey HessFeb 23, 2017
  19. Morten WelinderFeb 23, 2017
  20. Geert UytterhoevenFeb 24, 2017
  21. Jeff KingFeb 23, 2017
  22. David LangFeb 23, 2017
  23. David LangFeb 23, 2017
  24. David LangFeb 23, 2017
  25. Linus TorvaldsFeb 23, 2017
  26. Linus TorvaldsFeb 23, 2017
  27. Joey HessFeb 23, 2017
  28. Linus TorvaldsFeb 23, 2017
  29. Junio C HamanoFeb 23, 2017
  30. Duy NguyenFeb 24, 2017
  31. brian m. carlsonFeb 25, 2017
  32. René ScharfeFeb 27, 2017
  33. brian m. carlsonFeb 28, 2017
  34. Ian JacksonFeb 24, 2017
  35. ankostisFeb 24, 2017
  36. Junio C HamanoFeb 24, 2017
  37. David LangFeb 24, 2017
  38. Junio C HamanoFeb 24, 2017
  39. Stefan BellerFeb 24, 2017
  40. Junio C HamanoFeb 24, 2017
  41. Junio C HamanoFeb 24, 2017
  42. ankostisFeb 24, 2017
  43. Junio C HamanoFeb 24, 2017
  44. ankostisFeb 25, 2017
  45. Jason CooperFeb 26, 2017
  46. brian m. carlsonFeb 26, 2017
  47. Linus TorvaldsFeb 26, 2017
  48. Ævar Arnfjörð BjarmasonFeb 26, 2017
  49. Jeff KingFeb 26, 2017
  50. Transition plan for git to move to a new hash functionIan Jackson, Feb 27, 2017
  51. Markus TrippelsdorfFeb 27, 2017
  52. Ian JacksonFeb 27, 2017
  53. Tony FinchFeb 27, 2017
  54. brian m. carlsonFeb 28, 2017
  55. Ian JacksonMar 2, 2017
  56. brian m. carlsonMar 4, 2017
  57. Ian JacksonMar 5, 2017
  58. brian m. carlsonMar 5, 2017
  59. Philip OakleyFeb 24, 2017
  60. Jeff KingFeb 24, 2017
  61. Linus TorvaldsFeb 25, 2017
  62. Linus TorvaldsFeb 25, 2017
  63. Jeff KingFeb 25, 2017
  64. Junio C HamanoFeb 26, 2017
  65. Junio C HamanoFeb 25, 2017
  66. Jason CooperFeb 26, 2017
  67. Jeff KingFeb 26, 2017
  68. brian m. carlsonFeb 26, 2017
  69. Brandon WilliamsMar 2, 2017
  70. Jeff KingMar 3, 2017
  71. Ian JacksonMar 3, 2017
  72. Jeff KingMar 3, 2017
  73. Linus TorvaldsMar 2, 2017
  74. Junio C HamanoMar 2, 2017
  75. Linus TorvaldsMar 2, 2017
  76. Joey HessMar 2, 2017
  77. Linus TorvaldsMar 2, 2017
  78. Mike HommeyMar 3, 2017
  79. Linus TorvaldsMar 3, 2017
  80. Jeff KingMar 3, 2017
  81. Stefan BellerMar 3, 2017
  82. David LangFeb 25, 2017
  83. Stefan BellerFeb 25, 2017
  84. Jeff KingFeb 25, 2017
  85. David LangFeb 25, 2017
  86. Jeff KingFeb 25, 2017
  87. David LangFeb 25, 2017
  88. Jacob KellerFeb 25, 2017
  89. Jacob KellerFeb 25, 2017
  90. grarpampFeb 25, 2017
  91. Ian JacksonFeb 24, 2017
  92. Ian JacksonFeb 25, 2017
  93. brian m. carlsonFeb 25, 2017
  94. Jeff KingFeb 25, 2017
  95. Mike HommeyFeb 25, 2017
  96. brian m. carlsonFeb 26, 2017
  97. Jason CooperFeb 24, 2017
  98. ankostisFeb 25, 2017
  99. Jakub NarębskiFeb 24, 2017
  100. Santiago TorresFeb 24, 2017
  101. Jakub NarębskiFeb 24, 2017
  102. Øyvind A. HolmFeb 24, 2017
  103. Jeff KingFeb 24, 2017
  104. Jakub NarębskiFeb 24, 2017
  105. Lars SchneiderFeb 25, 2017
  106. Jeff KingFeb 26, 2017
  107. Junio C HamanoFeb 26, 2017
  108. Thomas BraunFeb 26, 2017
  109. Jeff KingFeb 26, 2017
  110. Geert UytterhoevenFeb 27, 2017
  111. Jeff KingFeb 27, 2017
  112. Morten WelinderFeb 27, 2017
  113. Jeff KingFeb 23, 2017
  114. Linus TorvaldsFeb 23, 2017
  115. Jeff KingFeb 23, 2017
  116. 1/3 add collision-detecting sha1 implementationJeff King, Feb 23, 2017
  117. Stefan BellerFeb 23, 2017
  118. Jeff KingFeb 24, 2017
  119. Linus TorvaldsFeb 24, 2017
  120. Jeff KingFeb 24, 2017
  121. 2/3 sha1dc: adjust header includes for gitJeff King, Feb 23, 2017
  122. 3/3 Makefile: add USE_SHA1DC knobJeff King, Feb 23, 2017
  123. HW42Feb 24, 2017
  124. Jeff KingFeb 24, 2017
  125. Linus TorvaldsFeb 23, 2017
  126. Junio C HamanoFeb 28, 2017
  127. Junio C HamanoFeb 28, 2017
  128. Jeff KingFeb 28, 2017
  129. Dan ShumowMar 1, 2017
  130. Linus TorvaldsFeb 28, 2017
  131. Shawn PearceFeb 28, 2017
  132. Linus TorvaldsFeb 28, 2017
  133. Dan ShumowFeb 28, 2017
  134. Marc StevensFeb 28, 2017
  135. Linus TorvaldsFeb 28, 2017
  136. Jeff KingMar 1, 2017

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.