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

Re: Starting to think about sha-256?

From
Linus Torvalds <torvalds@osdl.org>
Date
Aug 28, 2006, 18:46 UTC
Message-ID
<Pine.LNX.4.64.0608281137530.27779@g5.osdl.org>
In-Reply-To
<20060828183252.GC2950@coredump.intra.peff.net>
On Mon, 28 Aug 2006, Jeff King wrote:
Show 11 quoted lines
>
> On Mon, Aug 28, 2006 at 10:56:01AM -0700, Linus Torvalds wrote:
> 
> > However, the "earlier will override" is very much what you want from a 
> > security standpoint: remember that the git model is that you should 
> > primarily trust only your _own_ repository. So if you do a "git pull", the 
> 
> This concept breaks down somewhat if you are pulling from two
> repositories (one good and one evil). If I pull from the evil repo
> first, that will become my "earlier" object, and I will never get the
> colliding object from the good repo.

Sure. But if you are pulling from an untrusted source, you'd better at least check the result.

In fact, that's partly why "git pull" will do a diffstat after the pull. Exactly to force people to at least be minimally aware of what they pulled. And "gitk ORIG_HEAD.." is a great thing to always run when you pull from somebody you don't know and trust really well.

Of course, that all was done mostly not because I don't "trust" the people I work with, but more because I didn't always trust that they'd do the right thing with git (ie they'd screw up the repo not because they were evil, but because they made a mistake).

So even if you pull from an "evil" repo first, and you somehow get a "bad" object, the point is, the bad object _should_ be the one that overrides.

Why? Because once you find out that the evil repo was bad (which you'll eventually find simply because it caused some bug - if the evil repo only helps you, it's obviously not evil at all), what you need to do is reset to _before_ the evil repo happened, do a "git repack -a -d" and finally a "git prune" to clean out all the bad cruft, and then pull the good repo without pulling the bad one first.

After that, you apologize to everybody for screwing up and pulling from somebody you didn't trust, and then ask them to re-clone (or give them the appropriate "git reset" + "git repack -a" + "git prune" + "git pull" sequence so that they can fix their existing repos).

The point being, a hash attack is really no worse than an attack that fools you into applying a really bad diff (regardless of SCM), and it's a hell of a lot harder to do. Both a hash attack and a diff attack mean that the person merging data should either trust his source or inspect the end result.

Anybody who just blindly accepts data from untrusted sources is screwed in so many other ways that the hash attack simply isn't even on the radar.

		Linus
Previous: Jeff KingNext: Jeff King
Message 11 of 19 in “Starting to think about sha-256?”
  1. Jeff GarzikAug 27, 2006
  2. Krzysztof HalasaAug 27, 2006
  3. Linus TorvaldsAug 27, 2006
  4. Krzysztof HalasaAug 27, 2006
  5. Johannes SchindelinAug 27, 2006
  6. Linus TorvaldsAug 27, 2006
  7. David LangAug 28, 2006
  8. Linus TorvaldsAug 28, 2006
  9. Linus TorvaldsAug 28, 2006
  10. Jeff KingAug 28, 2006
  11. Linus TorvaldsAug 28, 2006
  12. Jeff KingAug 28, 2006
  13. Krzysztof HalasaAug 28, 2006
  14. Linus TorvaldsAug 28, 2006
  15. Krzysztof HalasaAug 28, 2006
  16. Linus TorvaldsAug 28, 2006
  17. Johannes SchindelinAug 28, 2006
  18. Linus TorvaldsAug 28, 2006
  19. Florian WeimerAug 29, 2006

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.