News for hackers. Stuff that matters.
Re:Linus' reply on Git and SHA-1 collision by notfed on Thursday February 23, 2017 @10:33PM (#13720694)
Pertinent facts for the worried:

1) Git doesn't rely on SHA-1 for security. It relies on HTTPS, and a web of trust.

2) Even if git did rely on SHA-1, there's no imminent threat. What happened today was a SHA-1 collision, not a preimage attack. If a collision costs 2^n, a preimage attack costs 2^(2n).

3) Even if someone managed to pull off a preimage attack, creating a "poisonous" version of one your git repository's objects, they'd still have to convince you pull from their repo. This requires trust.

4) Even if you pulled it in, your git client would simply ignore their "poison" object, because it would say, "oh, no thanks, I already have that object". At worst, the code simply wouldn't work. No harm would be done.

When it comes to git, an attacker's time is better spent creating a secret buffer overflow than wasting millions of dollars on a SHA-1 collision.

Re:Linus' reply on Git and SHA-1 collision by Perseids on Friday February 24, 2017 @05:28AM (#13722500)
I don't like the living-on-the-edge-attitude that Linus and others here promote regarding Sha1 in git. First, attacks only get faster over time. What costs millions today is likely to be achievable on commodity hardware in the coming years. Second, attacks only get more flexible over time. A contrived collision on MD5 in 2004 got perfected to a single block collision in 2010 [1]. Third, devising an update strategy and rolling it out takes time. I can't guess how much hardwired use of Sha1 is in Github.

Fourth, people use git in creative ways. Linus may think it is a cardinal sin to commit binary blobs in a git repository, but I can't imagine I'm the only one using git as a poor man's backup and file sharing solution.

And last but not least, relying on Sha1 takes effort of constantly asserting its use in Git is still secure. Support request to that end will skyrocket from now on, both of the constructive kind, like the technically concerned coworker ("but isn't git insecure now that Sha1 is broken"), and of the regulatory kind ("if you use Sha1, MD5, … please fill out these extra forms explaining why your process is still eligible for certification with ISO norm foobar").

Since we have to migrate away from Sha1 at some point in the future, I'd like it to be sooner rather than later.

[1] See Wikipedia for a timeline and references: https://en.wikipedia.org/wiki/MD5#History_and_cryptanalysis

Re:Linus' reply on Git and SHA-1 collision by maligree on Friday February 24, 2017 @08:51AM (#13723600)
"On the edge"

"A contrived collision on MD5 in 2004 got perfected to a single block collision in 2010 [1]" so they'd have at least years to fix it were they using md5?

He says they'll migrate, but it's no reason to go crazy. If anything, calmness of this sort is what we need more of (this industry, anyway... we go crazy about stuff way too much).

Re:Linus' reply on Git and SHA-1 collision by Florin_Andrei on Friday February 24, 2017 @06:58PM (#13729088)
As someone who has done "security" full time before - there's nothing worse than the "Security By Jumping Up And Down Like An Excited Monkey" policy.

Fix what's broken, no doubt. But stay rational and look at the problem from all perspectives.

Re:Linus' reply on Git and SHA-1 collision by patrec on Friday February 24, 2017 @01:03PM (#13725963)
Sha1 was already a questionable idea in 2005 when git came out, because it was then already understood to have fundamental flaws.

https://www.schneier.com/blog/archives/2005/02/cryptanalysis...

Re:Linus' reply on Git and SHA-1 collision by bicolao on Friday February 24, 2017 @07:22AM (#13722923)
> I don't like the living-on-the-edge-attitude that Linus and others here promote regarding Sha1 in git. First, attacks only get faster over time. What costs millions today is likely to be achievable on commodity hardware in the coming years.

If it helps, the git devs recognized that SHA-1 would be replaced at some point and have been preparing to move away from it. It's just a lot of work on basically one volunteer. A non-SHA-1 prototype might show up in a year or two, hopefully.

Re:Linus' reply on Git and SHA-1 collision by jefurii on Friday February 24, 2017 @04:14PM (#13727954)
> Fourth, people use git in creative ways. Linus may think it is a cardinal sin to commit binary blobs in a git repository, but I can't imagine I'm the only one using git as a poor man's backup and file sharing solution.

git-annex (written by Joey Hess from the email) is a way to manage binary blobs using Git, but IIRC it uses SHA256.

Re:Linus' reply on Git and SHA-1 collision by icebraining on Monday February 27, 2017 @04:15AM (#13742935)
Yes, that's the default. It's configurable up and down, though (from SHA-1 to SHA-3).
Re:Linus' reply on Git and SHA-1 collision by throwaway7767 on Friday February 24, 2017 @06:02AM (#13722609)
> 1) Git doesn't rely on SHA-1 for security. It relies on HTTPS, and a web of trust.

Some security-focused developers sign git tags and/or commits, specifically to have things verifiable end-to-end and not having to trust HTTPS and all the middle men that entails.

Would that not be a case where git relies on SHA1 for security? Someone could replace a tag or commit with a malicious version that verifies fine since it has the same hash the original developer signed.

> 3) Even if someone managed to pull off a preimage attack, creating a "poisonous" version of one your git repository's objects, they'd still have to convince you pull from their repo. This requires trust.

In the case of signed commits/tags, this opens projects up to malicious action by hosting companies and others. Usually signed commits and tags are used specifically to avoid that exposure, because the developers don't trust the infrastructure.

> 4) Even if you pulled it in, your git client would simply ignore their "poison" object, because it would say, "oh, no thanks, I already have that object". At worst, the code simply wouldn't work. No harm would be done.

That only protects existing checkouts that already have fetched that commit. What about new checkouts, or older checkouts that haven't been updated yet?

Not disputing that this SHA1 collision does not signal any immediate emergency, just pointing out that git is used in different ways by different people, and some of those uses very much do depend on git's SHA1 for security.

Re:Linus' reply on Git and SHA-1 collision by cben on Sunday February 26, 2017 @05:45AM (#13736620)
Another case where git uses SHA1 is submodules. You audit libfoo's well-regarded v1.3.3.7 release, commit badc00fee, decide it's suits your need and use that commit as a submodule in your project. You assume resolving the submodule will always give you same code (or fail).

Alas, libfoo author has been corrupted by The Adversary and later arranges for same hash to resolve to different code. (currently we're talking of collision not 2nd preimage, but libfoo's author could have been planning it all along, before your audit.)

["libfoo" here is fictional, I'm not refering to any of the projects actually named that.]

Similar things happen when Git hashes are exchanged by any side channel. The ability to use strong hashes as pointers to content inside any other data is the whole beauty of Merkle DAGs. Git submodules just happen to be one such channel that's part of git, but I think it's important to accept that git commit hashes are widely used outside git itself.

P.S. I see git-evtag already covers submodules. Nice.

Re:Linus' reply on Git and SHA-1 collision by kyrias on Friday February 24, 2017 @07:12AM (#13722865)
Regarding tags, https://github.com/cgwalters/git-evtag seems like a really interesting idea.
Re:Linus' reply on Git and SHA-1 collision by sneak on Friday February 24, 2017 @04:14PM (#13727956)
or, you know, this could just be fixed in git by using a proper hash function that allows you to trust your merkle tree.
Re:Linus' reply on Git and SHA-1 collision by _pmf_ on Friday February 24, 2017 @06:12AM (#13722650)
> Some security-focused developers sign git tags and/or commits, specifically to have things verifiable end-to-end and not having to trust HTTPS and all the middle men that entails.

This is a completely orthogonal, separate layer of security that has nothing to do with this particular issue.

Re:Linus' reply on Git and SHA-1 collision by tokenizerrr on Friday February 24, 2017 @06:27AM (#13722709)
Maybe quote the second line as well?

> Would that not be a case where git relies on SHA1 for security? Someone could replace a tag or commit with a malicious version that verifies fine since it has the same hash the original developer signed.

What's your response to this? To me it seems like this would be a serious issue.

Re:Linus' reply on Git and SHA-1 collision by _pmf_ on Friday February 24, 2017 @06:59AM (#13722815)
You're right.
Re:Linus' reply on Git and SHA-1 collision by orblivion on Friday February 24, 2017 @02:16AM (#13721710)
I control a fleet of servers. I have a saltstack or ansible script. One of the steps in provisioning a new server is to pull library X from github.com.

One day Egor Homakov finds a new hack and finds his way into access to the master branch for library X. As a prank, he force pushes a change to master.

Being aware of such a possibility, instead of setting up my script to pull from master or even a specific tag, perhaps I pull from a specific sha1sum. That way I know I'm getting the exact version I want. That's today. Tomorrow, when preimage SHA-1 attacks are cheap, it will no longer save me.

Re:Linus' reply on Git and SHA-1 collision by stonogo on Friday February 24, 2017 @02:43AM (#13721806)
Sounds like sentence three is where you got it wrong. You should be pulling your software to a development host, building it after verification, and uploading the deployment package to an artifact repository inside your security perimeter. Sentence three becomes 'pull library X from my artifact server.'

There is no way to securely deploy a package directly from the internet. The sooner you understand that, the sooner you'll be able to sleep through needless catastrophes like this hypothetical attack -- or leftpad.js.

Re:Linus' reply on Git and SHA-1 collision by Perseids on Friday February 24, 2017 @04:04AM (#13722164)
> There is no way to securely deploy a package directly from the internet.

Fetching a file from the internet and verifying it against a hash or signature is the only way to securely deploy a package from the internet. This is exactly one of the use cases theses cryptographic primitives are built for. Don't blame the users when they utilize the tools the way they are supposed to be, blame the tools when they fail when doing so.

And by the way, if you ever need to run `apt-get upgrade` or `apt-get install` on your production server from a public mirror, then you are guilty of "deploying a package directly from the internet", too. (My apologies and congratulations if don't.)

Re:Linus' reply on Git and SHA-1 collision by raverbashing on Friday February 24, 2017 @04:50AM (#13722340)
apt-get can (and do) check signatures of repos

But yeah, you could put an unverified repos to be used

Re:Linus' reply on Git and SHA-1 collision by Perseids on Friday February 24, 2017 @05:47AM (#13722565)
For the argument at hand (Can you deploy anything on a production server from a third party that is only verified cryptographically?) signatures and hashes fulfill the same function (and btw I also wrote "verifying it against a hash or signature" above). More to the point, under the hood GPG signatures only sign a hash of the file in question anyway. Verifying a file via a GPG signature is strictly less secure than verifying it by its hash (assuming you use the same hash function as the signature).
Re:Linus' reply on Git and SHA-1 collision by lmm on Friday February 24, 2017 @05:02AM (#13722406)
Git has tag signing, surely there's a way to clone a specific tag and check the signature against a specific GPG key fingerprint?
Re:Linus' reply on Git and SHA-1 collision by nhaehnle on Friday February 24, 2017 @06:22AM (#13722689)
Tag signatures only cover the mapping from tag name to commit hash. In other words, specifying a manually-verified commit hash is actually more secure.

Tag signatures are mostly worthless now from a crypto point of view -- with the caveat that you can still get some value from them if you still trust sha1 to be secure against second-preimage attacks.

Re:Linus' reply on Git and SHA-1 collision by heartsucker on Friday February 24, 2017 @06:19AM (#13722678)

    git checkout 0.1.0
    git tag -v 0.1.0
Re:Linus' reply on Git and SHA-1 collision by amingilani on Friday February 24, 2017 @04:01AM (#13722153)
Either way he'd be pulling from Github.com at some point, whether in the build environment or production. He won't ever know that the repository was compromised.

Besides, some people use Heroku simply to deploy their rails or node apps, and they don't have an artefacts server.

Re:Linus' reply on Git and SHA-1 collision by dozzie on Friday February 24, 2017 @03:23AM (#13721999)
> I control a fleet of servers. I have a saltstack or ansible script. One of the steps in provisioning a new server is to pull library X from github.com.

Ansible gives larger and easier to exploit attack vectors than git.

And then, with pulling semi-random things from internets you have much bigger problems with your deployment procedure. You should never ever download a git repository with software, instead you should be using package system supplied by your operating system.

Re:Linus' reply on Git and SHA-1 collision by mverwijs on Friday February 24, 2017 @04:00AM (#13722150)
> you should be using package system supplied by your operating system

2005-me vehemently agrees with you.

Re:Linus' reply on Git and SHA-1 collision by amingilani on Friday February 24, 2017 @04:02AM (#13722157)
Package managers allow you to download from git repositories too. He'd suffer from the same attack vector.
Re:Linus' reply on Git and SHA-1 collision by dozzie on Friday February 24, 2017 @04:04AM (#13722162)
Erm... Which ones?
Re:Linus' reply on Git and SHA-1 collision by shasheene on Friday February 24, 2017 @04:15AM (#13722209)
I believe Homebrew on macOS uses it for formulae (Ruby scripts to actually download and build the application)
Re:Linus' reply on Git and SHA-1 collision by dozzie on Friday February 24, 2017 @04:26AM (#13722249)
Well, I don't hear too often about a fleet of servers running MacOS (because this branch of comments started with provisioning in a fleet of servers).

Also, from rants I hear about Homebrew and its breaking random libraries on upgrades, I don't think it should be mentioned as it was state-of-the-art or something.

Re:Linus' reply on Git and SHA-1 collision by amingilani on Friday February 24, 2017 @05:30AM (#13722506)
Re:Linus' reply on Git and SHA-1 collision by dozzie on Friday February 24, 2017 @06:32AM (#13722723)
And which of these are "package systems supplied by your operating system"?
Re:Linus' reply on Git and SHA-1 collision by sqeaky on Friday February 24, 2017 @02:52PM (#13727135)
While I agree that the OS package should be used first and foremost, it just often doesn't have the required software. (Even after adding extra repos that it might support)

You are picking on the useless details. Those are all commonly used package managers in production environments. They often provide software that simply never gets packaged with the OS. They likely always will, because they have more focused design goals.

A better way to argue this would be point out that specific ways to use the package managers better. For example: bundlr supports saving all the required packages offline. This provides the opportunity to do a security review and save the packages locally/internally rather than always trusting the whatever is on the Internet.

Re:Linus' reply on Git and SHA-1 collision by dozzie on Friday February 24, 2017 @03:10PM (#13727372)
> While I agree that the OS package should be used first and foremost, it just often doesn't have the required software. (Even after adding extra repos that it might support)

OS-supplied packages don't grow on magical trees. If you don't have the necessary software in official repositories (or if it's your software), you can package it yourself. Deployment then becomes a breeze, and you save yourself otherwise completely useless process of recompiling things over and over again.

> You are picking on the useless details.

Quite the contrary. Those details make important difference.

> Those are all commonly used package managers in production environments. They often provide software that simply never gets packaged with the OS.

Apart from Homebrew, which is for workstations (hardly anybody runs macOS servers), none of these "package managers used in production environments" provide you a complete way to rebuild your software. You can be fine for a while if you stay away from modules that are interfaces to C or C++ libraries and from tools from other languages (e.g. I have used Python's Sphinx to document Erlang daemons quite successfully), but once you hit that, deployment starts to be PITA, because you'll need to remember to install all the required libraries, -dev packages, compilers, and what not.

On the other hand, DEB or RPM with artifacts will just automatically pull the required libraries, and its build dependencies give a dedicated and standard place for the necessary build tools.

Your comment supports my opinion that today's programmers usually don't want to be bothered with learning things that have been working for sysadmins for twenty years already.

Re:Linus' reply on Git and SHA-1 collision by Xylakant on Friday February 24, 2017 @03:17PM (#13727473)
Gentoos emerge and FreeBSD port are package managers that preferably build from source. At least emerge also accepts git sources, with tags and commit specifiers. I haven't used bsd in a while on a prod system, but I'd not be surprised if port gained the same functionality - after all whether you're pulling a tarball and use a checksum for integrity checking or hand the task off to git makes exactly no difference at all.

And I have yet to hear that port and emerge are incapable of doing dependency resolution. They're battle tested systems that work well in production environments.

Re:Linus' reply on Git and SHA-1 collision by dozzie on Friday February 24, 2017 @03:35PM (#13727643)
First, portage and ports are OS-supplied mechanism for installing software. They are nothing like pip or gems or npm, which only can install things written in their respective languages of choice and fail miserably for modules touching any library external to them (unless you manually ensure the library's and compiler toolchain's presence, that is).

Second, ports and portage have support for and networks of mirror servers that keep copies of software available through these packaging systems. It's trivial to switch if one of the mirrors goes down. For pip, gems, or npm you need to plan ahead for the problems and deploy your own package cache, from what I know.

Third, I was using Gentoo with one of these "battle tested systems that work well in production" for several years. It was doable, but it wasn't pretty, could lead to breaking software after updating some random deep dependency (if it was recompiled with different flags), and generally required more work and attention than APT would, all that for very little gain (if any gain at all). Oh, and it ended up working with binary packages, after all, I just needed to compile them myself instead of having a half an hour downtime of production MySQL because it needed to get compiled (which could fail, leaving me with no working database installed).

Re:Linus' reply on Git and SHA-1 collision by sqeaky on Friday February 24, 2017 @04:17PM (#13727978)
Gems can be used to installing anything. It often build java, go, C, C++ and I think I heard it could do rust once, but generally anything in faster languages to create faster versions of the implementation of the functionality for a given gem.

I bring that up to highlight some of the wrong assumptions you make. You make several needless assumptions and use those to draw funny distinctions between things. I am not even sure of the point anymore.

likely any of these systems could be used in a variety of environments for a variety of purposes.

Re:Linus' reply on Git and SHA-1 collision by steveklabnik on Friday February 24, 2017 @05:18PM (#13728456)
You can do anything, including Rust, yeah. You can also distribute pre compiled stuff.
Re:Linus' reply on Git and SHA-1 collision by Florin_Andrei on Friday February 24, 2017 @07:02PM (#13729110)
The ones that actually matter are more like apt or yum.
Re:Linus' reply on Git and SHA-1 collision by yellowapple on Friday February 24, 2017 @06:05AM (#13722617)
Most language-specific ones do. OS-specific ones less commonly do; Chocolatey, for example, can (IIRC) install packages by running PowerShell scripts, which may or may not include pulling from GitHub.
Re:Linus' reply on Git and SHA-1 collision by dozzie on Friday February 24, 2017 @06:34AM (#13722729)
> Most language-specific ones do.

Those are development tools, not deployment ones (even though they are used as such; programmers usually don't bother with learning what sysadmins do, so it's not a surprise).

Re:Linus' reply on Git and SHA-1 collision by Xylakant on Friday February 24, 2017 @06:58AM (#13722812)
getoos emerge can. A package definition contains a source URL and git urls (with branches and tags) are accepted sources.
Re:Linus' reply on Git and SHA-1 collision by Faaak on Friday February 24, 2017 @04:53AM (#13722351)
yaourt on archlinux
Re:Linus' reply on Git and SHA-1 collision by hprotagonist on Friday February 24, 2017 @09:49AM (#13724090)
Pip, too.
Re:Linus' reply on Git and SHA-1 collision by danmaz74 on Friday February 24, 2017 @07:08AM (#13722848)
> Tomorrow, when preimage SHA-1 attacks are cheap, it will no longer save me.

Well, Moore's law is petering out isn't it? :)

Re:Linus' reply on Git and SHA-1 collision by runholm on Friday February 24, 2017 @09:34AM (#13723940)
Computers are not getting better at the rate they used to, but we are still improving both on performance and power.

However, the largest change we have seen the last couple of years is the accessibility of computer power. These days an attacker can be concerned mostly by how many CPU/GPU hours he needs to rent from Amazon or equivalent providers to achieve his goal. So the accessibility, convenience, and price of processing power is still improving quite fast.

Re:Linus' reply on Git and SHA-1 collision by sqeaky on Friday February 24, 2017 @02:35PM (#13726934)
Depending on your interpretation. If you go by the relatively useless transistor/fixed price cpu then it is dead, but if you go by more practical measures like instructions per second in whole system/dollar the it is as fast as ever. GPUs are really fast and still advancing.
Re:Linus' reply on Git and SHA-1 collision by officelineback on Friday February 24, 2017 @09:49AM (#13724098)
Moore's law is, but the cost of a given amount of computational ability is still going down quickly.
Re:Linus' reply on Git and SHA-1 collision by hasenj on Friday February 24, 2017 @03:13AM (#13721957)
If you want a specific hash, why pull it from github everytime?
Re:Linus' reply on Git and SHA-1 collision by falsedan on Friday February 24, 2017 @03:16AM (#13721973)
Because, when provisioning a new server, where else can you get it from?
Re:Linus' reply on Git and SHA-1 collision by wjh_ on Friday February 24, 2017 @03:21AM (#13721993)
A host that you control.
Re:Linus' reply on Git and SHA-1 collision by falsedan on Friday February 24, 2017 @09:12AM (#13723772)
Where did it get it from?
Re:Linus' reply on Git and SHA-1 collision by hasenj on Friday February 24, 2017 @10:23AM (#13724416)
From github, the first time only. Not every single time.
Re:Linus' reply on Git and SHA-1 collision by falsedan on Saturday February 25, 2017 @05:19AM (#13730940)
Isn't getting it from GitHub the first time vulnerable to attack? Consider when you're scaling up or replacing a failed host.
Re:Linus' reply on Git and SHA-1 collision by dozzie on Friday February 24, 2017 @03:20AM (#13721990)
From a custom package you have built? Did you know that RPMs and DEBs don't grow on magical trees, but are built?
Re:Linus' reply on Git and SHA-1 collision by throwayguestman on Friday February 24, 2017 @04:48AM (#13722331)
So, the problem still stands, theoretically.

Not only do you likely need to populate your host with packages not from your host. But also, your host will also still be connect to a public net, even if only indirectly (e.g. private net), and hence potentially manipulated.

Re:Linus' reply on Git and SHA-1 collision by dozzie on Friday February 24, 2017 @04:57AM (#13722381)
No, you misunderstood what is actually the problem here. Pulling under deployment some code from random resource from the internets that can go down or get deleted at a whim and you can't easily move to just some other mirror and you don't even control when the thing will be up back, that's the problem. Not the trust you need to put to use the code (this is still there, obviously). And the very same comment applies to third-party package repositories, like PPAs in Ubuntu.

Not to mention that with pre-built binary packages your deployment speed and repeatability get significantly better, as you don't need to rebuild the artifacts every single time.

Re:Linus' reply on Git and SHA-1 collision by throwayguestman on Friday February 24, 2017 @05:30AM (#13722509)
I do understand, but "the trust you need to put to use the code" is what we were talking about, no?
Re:Linus' reply on Git and SHA-1 collision by uiri on Friday February 24, 2017 @02:39AM (#13721790)
Wow, Linus raises an entirely different issue which is that the PDF-based attack won't work on git at all. Due to length prefixing, it is extremely difficult to insert nonsense into the middle of a git object which is how this attack works on PDFs. Linus correctly notes that using the first forty bytes of SHA-256 is an option if an attack against git's use of SHA1 were developed.

1) Git doesn't rely on SHA-1 for security. It relies on HTTPS, and a web of trust.

I don't think I've ever (intentionally) used git over HTTPS. I always clone using ssh (which has its own authentication mechanisms) or the git protocol (which is read-only).

2) Even if git did rely on SHA-1, there's no imminent threat. What happened today was a SHA-1 collision, not a preimage attack. If a collision costs 2^n, a preimage attack costs 2^(2n).

Thankfully, the collision attack doesn't apply to git (see above) so the cost ought to be greater than 2^n for a collision.

3) Even if someone managed to pull off a preimage attack, creating a "poisonous" version of one your git repository's objects, they'd still have to convince you pull from their repo. This requires trust.

Find a popular git host (say, Github but if a popular project is on Git Lab or Bitbucket, they will do just as well) and compromise them. Target a recent release for a popular project (say, Rails) and poison a relevant object that gets pulled down by all the downstream maintainers to package the release.

The benefit to straight up compromising a git repo without faking the hash lies in introducing a vulnerability without the maintainers nor developers of the project noticing (or noticing months/years after the fact).

Re:Linus' reply on Git and SHA-1 collision by Perseids on Friday February 24, 2017 @04:21AM (#13722225)
> Wow, Linus raises an entirely different issue which is that the PDF-based attack can't and won't work on git at all. Due to length prefixing it is extremely difficult to insert some nonsense into the middle of a git object which is how this attack works on PDFs.

Please note that the shattered-{1,2}.pdf files both have exactly the same length. And even with cleartext it is easy to pad passages so they contain the same amount of bytes. See how the quoted paragraph above has exactly the same number of characters as this one.

Re:Linus' reply on Git and SHA-1 collision by throwmenow_0140 on Friday February 24, 2017 @05:38AM (#13722529)

  >>> len('''> Wow, Linus raises an entirely different issue which is that the PDF-based attack can't and won't work on git at all. Due to length prefixing it is extremely difficult to insert some nonsense into the middle of a git object which is how this attack works on PDFs.''')
  264
  >>> len('''Please note that the shattered-{1,2}.pdf files both have exactly the same length. And even with cleartext it is easy to pad passages so they contain the same amount of bytes. See how the quoted paragraph above has exactly the same number of characters as this one.''')
  264
Re:Linus' reply on Git and SHA-1 collision by makomk on Friday February 24, 2017 @06:36AM (#13722740)
Indeed, they probably have to have the same length since the length is inserted into the final block as part of SHA-1 hashing and every block after the collision must be the same. I don't think it's even possible to create a MD5 collision between two documents of different length yet.
Re:Linus' reply on Git and SHA-1 collision by yellowapple on Friday February 24, 2017 @06:08AM (#13722638)
I'd be more impressed if both paragraphs also had the same SHA-1 hash ;)
Re:Linus' reply on Git and SHA-1 collision by brillyfresh on Friday February 24, 2017 @09:23AM (#13723847)
What if the hash of the second paragraph had exactly the same number of characters as the hash of the first one? ;)
Re:Linus' reply on Git and SHA-1 collision by perlgeek on Friday February 24, 2017 @12:30AM (#13721275)
> 1) Git doesn't rely on SHA-1 for security. It relies on HTTPS, and a web of trust.

I thought that if you signed your git commits or tags with GPG, you implicitly relied on the commit checksum, and thus on SHA1.

Is that right?

Re:Linus' reply on Git and SHA-1 collision by rocqua on Friday February 24, 2017 @04:03AM (#13722158)
That's what I read in the thread about the collision that was found.
Re:Linus' reply on Git and SHA-1 collision by fryguy on Friday February 24, 2017 @12:10AM (#13721189)
That's not entirely true. You could fork a popular git repo, and then make some kind of patch for a bug in some seldomly changed file. Then force a collision in the new file with the benign change as well as your poisoned version. Then they could convince you to pull in the changes. Then they could reset their repository to the one with the poisoned version and anyone who pulls from them first would get the poisoned version of the file instead of the right one. It seems extremely unlikely that a practical attack would come out of this though.
Re:Linus' reply on Git and SHA-1 collision by disiplus on Friday February 24, 2017 @04:45AM (#13722315)
thats stretching it. if you could convince anybody to pull from you then why even bother to go to a great expense of creating a collision.
Re:Linus' reply on Git and SHA-1 collision by victorNicollet on Friday February 24, 2017 @06:22AM (#13722687)
This reminds me of vulnerability reports that start with "if you have root access..."
Re:Linus' reply on Git and SHA-1 collision by erbo on Friday February 24, 2017 @01:19PM (#13726140)
Or, as Raymond Chen puts it (quoting Douglas Adams), "It rather involved being on the other side of this airtight hatchway."
Re:Linus' reply on Git and SHA-1 collision by sqeaky on Friday February 24, 2017 @03:00PM (#13727249)
It creates plausible dependability.

Imagine the NSA publishing a crypto algorithm and contributes it to openSSL or some hypothetical crypto library using git. If they commit their new algorithm, everyone will be looking at that. They could do something devious like tinker with the way random numbers are generated elsewhere and reduce the possible keyspace of another algorithm to something very small and easy to brute force.

When this keyspace shortening is found out it would be hard or impossible to track back. No amount of inspecting the files that reportedly changed would reveal that the NSA did this.

Re:Linus' reply on Git and SHA-1 collision by tmsldd on Friday February 24, 2017 @01:23AM (#13721511)
Fine with all this, and you are right: nothing to worry by now... but in the end we should trust the math, and nothing else. And so, we need a schedule for update it..
Re:Linus' reply on Git and SHA-1 collision by simias on Friday February 24, 2017 @04:57AM (#13722378)
Not entirely true, it relies on SHA-1 for security when you use PGP signatures. That makes it possible to fetch git repositories from untrusted sources if you can validate the signatures.

I don't really see how HTTPS is relevant here either, I clone most of my repositories over SSH for instance. And you can use git over plain HTTP too.

Re:Linus' reply on Git and SHA-1 collision by dlubarov on Friday February 24, 2017 @12:20AM (#13721237)
> 1) Git doesn't rely on SHA-1 for security. It relies on HTTPS, and a web of trust.

HTTPS lets you verify that you're fetching changes from, say, a Github server. Just because a repo is hosted by Github doesn't mean that you can trust its contents.

> 2) Even if git did rely on SHA-1, there's no imminent threat. What happened today was a SHA-1 collision, not a preimage attack. If a collision costs 2^n, a preimage attack costs 2^(2n).

This needs investigation, but I suspect some plausible attack vectors exist based on collisions. Say you generate a good file and a bad file with the same SHA. If Github uses some kind of object cache for viewing files through the website, you could probably get the good file into their cache, then open a PR with a commit containing the bad file. The project maintainer would see the cached good file, but when they merge the PR, the bad file would be merged.

I'm not sure if this exact attack would work, but probably something like it would. If not with Github, then perhaps with Bitbucket or GitLab.

Another possible approach would be to send a PR which discreetly introduces the bad file into the project maintainer's object store. (It doesn't have to be in a commit you're asking them to merge; it could be in a separate branch which they likely wouldn't notice.) Once that's done, you send a PR which introduces the good file. If they review the second PR on a website, they'll see the good file, but if they merge manually, they'll get the bad file from their local object store. Even if the maintainer merges through Github, if they deploy from their own machine, they'll deploy the bad file.

> 3) Even if someone managed to pull off a preimage attack, creating a "poisonous" version of one your git repository's objects, they'd still have to convince you pull from their repo. This requires trust.

Not really -- on Github, contributors are often strangers, and project maintainers often fetch from a stranger's repo in order to try something out. They expect that fetching objects is harmless. Even if some project maintainers do look for signs of trust before fetching, they'd probably be easily fooled by fake info in a profile. A determined attacker could even make a large network of fake accounts which star each other's projects and so forth, similar to black hat web rings.

> 4) Even if you pulled it in, your git client would simply ignore their "poison" object, because it would say, "oh, no thanks, I already have that object". At worst, the code simply wouldn't work. No harm would be done.

If an attacker had the resources to perform a preimage attack, one thing they could do is take the latest version of jQuery on the day it's released. They could append some malicious code, then add junk in a comment until they get the desired SHA. Now they just have to get a project maintainer to fetch from their repo ("Check out this feature I added! Just fetch from my fork and run the server."), and then wait for the maintainer to upgrade jQuery.

Re:Linus' reply on Git and SHA-1 collision by hvidgaard on Friday February 24, 2017 @02:40AM (#13721796)
Git prepends type and length, that makes an attack significantly more difficult, and certainly you cannot just directly translate the pdf attack to Git.

For applications, such as signing pdf or other documents, SHA-1 should be retired. But the collective crypto community have said that for more than a decade, so I have little sympathy for companies that is affected by this.

But for Git, there is no reason for immediate concern. Should they upgrade to a more secure hash function, yes. Ideally they make it rather straight forward to use different function in the future and perhaps multiple hash functions. I doubt anyone is able to find an input that MD5 and SHA-1 both hash to the same value. It would significantly reduce reliance on a single hash function.

Re:Linus' reply on Git and SHA-1 collision by johncolanduoni on Friday February 24, 2017 @04:14AM (#13722204)
> I doubt anyone is able to find an input that MD5 and SHA-1 both hash to the same value. It would significantly reduce reliance on a single hash function.

As was mentioned in the original collision thread, concatenating insecure hash functions has fundamental weaknesses: https://www.iacr.org/archive/crypto2004/31520306/multicollis...

Re:Linus' reply on Git and SHA-1 collision by hvidgaard on Friday February 24, 2017 @04:23AM (#13722237)
Sort of. It does not improve brute force resistance in a meaningful way, but that is not the purpose either. It protects against one of the hash functions being broken.

Let us assume that we have 2 160bit hash functions, and one is broken to the degree that we can find collisions in constant time. This now means that we can break the combined hash in 2^80 rather than 2^80 + 2^80. The total brute force complexity was not improved, but the reliance on either hash function was.

Re:Linus' reply on Git and SHA-1 collision by johncolanduoni on Friday February 24, 2017 @05:03AM (#13722416)
Yes, but you picked two hash functions which are known to be insecure. Their complexity reduction argument appears to apply to cases where you are not using pure brute force for either hash, which would be the case if you were attacking MD5 and SHA1.
Re:Linus' reply on Git and SHA-1 collision by hvidgaard on Friday February 24, 2017 @05:09AM (#13722443)
I did so quite on purpose. Both are concidered broken, but combined, only the bruteforce attack is known to work, i.e. "the whole is greater than the sum of its parts".
Re:Linus' reply on Git and SHA-1 collision by dlubarov on Friday February 24, 2017 @02:53AM (#13721846)
> Git prepends type and length, that makes an attack significantly more difficult, and certainly you cannot just directly translate the pdf attack to Git.

With the attack vectors discussed above, the type would always be blob. I don't think the length field is much help either; see https://news.ycombinator.com/item?id=13720725

Re:Linus' reply on Git and SHA-1 collision by hvidgaard on Friday February 24, 2017 @03:18AM (#13721984)
The length field makes the attack significantly more difficult. In the publish attack, you take 2 fixed input and prepend special data to make the collision. With Git, you have additional constraint. Either it needs to be of exact length, this may or may not be an issue, but most likely is unless we find a new weakness in SHA-1, or you must be able to handle the changing input.

In all the examples in your link, while true that you can add "silent data" to all of the examples, they are all examples of structured data. So not only do you have to figure out the collision, you have to do so within the structure of the format you're attacking. This is a lot harder than just prepending the exact bytes you want.

Re:Linus' reply on Git and SHA-1 collision by jwilk on Friday February 24, 2017 @04:33AM (#13722271)
> The length field makes the attack significantly more difficult. In the publish attack, you take 2 fixed input and prepend special data to make the collision.

That's not how the attack works. Not at all.

Re:Linus' reply on Git and SHA-1 collision by hvidgaard on Friday February 24, 2017 @05:06AM (#13722433)
If you ignore the prepend part, it is in essence taking known input and calculate a collision.

> This is an identical-prefix collision attack, where a given prefix P is extended with two distinct near-collision block pairs such that they collide for any suffix S.

And

> Our example colliding files only differ in two successive random-looking message blocks generated by our attack. We exploit these limited differences to craft two colliding PDF documents containing arbitrary distinct images.

Re:Linus' reply on Git and SHA-1 collision by EGreg on Friday February 24, 2017 @01:56AM (#13721634)
For 3 though, how is trusting a random author on git (with fake stars etc) practically different than a random author who has the exact sha1 of a "trusted" repo in their history? If you pull from a random author are you really doing a diff with the last trusted commit or something?

Face it - it's far more likely that a github account is compromised and that repo you rely on has been amended. And you don't really have a good way of verifying which commits are "safe" whatever that means. At best, commits can be cryptographically signed by ther authors, to prevent this. But if the author goes rogue then all who depend on them are up the creek.

And all this for what?

Re:Linus' reply on Git and SHA-1 collision by tlrobinson on Friday February 24, 2017 @03:31AM (#13722027)
1) Git doesn't rely on SHA-1 for security. It relies on HTTPS, and a web of trust.

I would say cryptographic integrity definitely counts as "security".

I agree this isn't currently a big deal, but it's probably time to start migrating to a better hash.

Re:Linus' reply on Git and SHA-1 collision by darklajid on Friday February 24, 2017 @03:49AM (#13722104)
But .. that's what Linus is saying in his mail. Like, really exactly what you say in your last sentence..?
Re:Linus' reply on Git and SHA-1 collision by newjersey on Friday February 24, 2017 @01:48PM (#13726425)
The quote for those who didn't read the email. Linus Torvalds says:

> Do we want to migrate to another hash? Yes.

Re:Linus' reply on Git and SHA-1 collision by snakeanus on Friday February 24, 2017 @01:08PM (#13726022)
>1) Git doesn't rely on SHA-1 for security. It relies on HTTPS, and a web of trust.

This is a big lie. When the -S flag is used, git signs the SHA-1 of the commit. Moreover HTTPS does not provide any form of authentication due to the extremely broken CA model. NSA could simply ask any CA to give them a cert for github for example. Not to mention that https would only authenticate that you are talking to the github server, it would say nothing concerning the authenticity of the code.

>they'd still have to convince you pull from their repo. This requires trust.

How about compromising your servers instead? Or maybe simply have NSA asking github to let them modify a commit (which would end up having the same SHA-1 and being signed by you).

>4) Even if you pulled it in, your git client would simply ignore their "poison" object, because it would say, "oh, no thanks, I already have that object". At worst, the code simply wouldn't work. No harm would be done.

https://stackoverflow.com/a/34599081

Didn't Git v2.0 break backwards compatibility? Couldn't they simply move to Sha-2 during that time?

Re:Linus' reply on Git and SHA-1 collision by grumbelbart on Saturday February 25, 2017 @05:31AM (#13730962)
Fully agree to everything you said, one point:

> Didn't Git v2.0 break backwards compatibility?

No, it did not.