Git fscked by SHA-1 collision? Not so fast, says Linus Torvalds

Attack is hard, discovery is easy, so fix it right
rather than right now


About that SHA-1 collision: Linus Torvalds has taken to Google+ to emphasise that in Git, its main role is error detection, so “the sky isn't falling.”

The weak hashing algorithm is used, among other things, to provide a digital signature for software, documents like PDFs, and encryption certificates. The mathematical operation should produce a unique 40-character summary for any given input data, but CWI and Google's work showed it is reasonably possible now to produce SHA-1 “collisions” – for example, two different PDFs gave the same SHA-1 hash.

In the Git software repository system – authored by Torvalds – the SHA-1 hash of a repo's tree can be used to check you are fetching the code you think you're fetching.

An attacker could, using CWI and Google's findings, insert a backdoor in a program's source code in such a way that its repo's hash value collides with the hash value of a legit copy of the source – the hash value is the same for both despite the code being different. Thus, a victim fetching the poisoned source would believe it's an untampered-with “safe” repo, because its hash matches the official legit tree, and ends up building and running a backdoored version.

Not so fast, Torvalds writes. Here's what he said:

First off, the sky isn't falling. There's a big difference between using a cryptographic hash for things like security signing, and using one for generating a 'content identifier' for a content-addressable system like git.

While the algorithm does have a security role even in Git, error correction is more important, Torvalds says, because trust should be a function of the community.

If you fetch a Linux kernel from Linus's repo, it's because that's where you expect the authoritative kernel to be: the hash is there so if someone tampered with the source, the signature won't match, and you know something's wrong. Torvalds sees SHA-1 hashes of repos more as a checksum than proof the data you fetched is the data in the official repo, though.

“In contrast, in a project like git, the hash isn't used for 'trust'. I don't pull on people's trees because they have a hash of a4d442663580. Our trust is in people, and then we end up having lots of technology measures in place to secure the actual data," he said.

“Think of [SHA-1] like 'parity on steroids': it's not able to correct for errors, but it's really really good at detecting corrupt data.” Torvalds continued:

Secondly, the nature of this particular SHA1 attack means that it's actually pretty easy to mitigate against, and there's already been two sets of patches posted for that mitigation.

The reason mitigation is “pretty easy”, he explained, is that to generate a collision, the attacker has to control both the “good” object and the “bad” object – and an attack is detectable on both sides of the collision.

For Git, this makes attacks hard to hide, unlike in the PDF-based proof of concept: “The PDF format acted as the 'black box', and what you see is the printout which has only a very indirect relationship to the PDF encoding.”

In other words, it's easy to stash within the PDF file magic data required to keep the SHA-1 value of the document the same after it has been tampered with. However, that binary data isn't easy to hide in source code without it being spotted by humans or upsetting the toolchain or compiler.

In Git, if "somebody inserts random odd generated crud in the middle of your source code, you will absolutely notice,” Torvalds said, and even if someone found somewhere to hide a collision, git fsck “already warns about those kinds of shenanigans.”

In this lengthy mailing list discussion, Torvalds elaborates: “You also need to make the non-opaque data of the bad object besomething that actually encodes valid git data with interesting hashes in it (for the parent/tree/whatever pointers).”

And even then, discovery is trivial – kernel.org runs git fsck nightly to see if anyone's fooling around with code. He continued:

And finally, there's actually a reasonably straightforward transition to some other hash that won't break the world - or even old git repositories.

“There's a plan, it doesn't look all that nasty, and you don't even have to convert your repository”, he notes. On the mailing list, he says SHA3-256 looks like a sensible replacement hash function. ®

Updated to add

It's been brought to our attention that one reason for Linus's “settle down” message could be a complaint by GNU luminary John Gilmore that he tried to warn against SHA-1 in 2005.

“[Torvalds] wired assumptions about SHA-1 deeply into git. In the next few years, nasty people will teach him the threat model, with ungentle manipulations of his and many other peoples' source trees,” Gilmore said.

Broader topics

Narrower topics


Other stories you might like

  • North Korea pulled in $400m in cryptocurrency heists last year – report

    Plus: FIFA 22 players lose their identity and Texas gets phony QR codes

    In brief Thieves operating for the North Korean government made off with almost $400m in digicash last year in a concerted attack to steal and launder as much currency as they could.

    A report from blockchain biz Chainalysis found that attackers were going after investment houses and currency exchanges in a bid to purloin funds and send them back to the Glorious Leader's coffers. They then use mixing software to make masses of micropayments to new wallets, before consolidating them all again into a new account and moving the funds.

    Bitcoin used to be a top target but Ether is now the most stolen currency, say the researchers, accounting for 58 per cent of the funds filched. Bitcoin accounted for just 20 per cent, a fall of more than 50 per cent since 2019 - although part of the reason might be that they are now so valuable people are taking more care with them.

    Continue reading
  • Tesla Full Self-Driving videos prompt California's DMV to rethink policy on accidents

    Plus: AI systems can identify different chess players by their moves and more

    In brief California’s Department of Motor Vehicles said it’s “revisiting” its opinion of whether Tesla’s so-called Full Self-Driving feature needs more oversight after a series of videos demonstrate how the technology can be dangerous.

    “Recent software updates, videos showing dangerous use of that technology, open investigations by the National Highway Traffic Safety Administration, and the opinions of other experts in this space,” have made the DMV think twice about Tesla, according to a letter sent to California’s Senator Lena Gonzalez (D-Long Beach), chair of the Senate’s transportation committee, and first reported by the LA Times.

    Tesla isn’t required to report the number of crashes to California’s DMV unlike other self-driving car companies like Waymo or Cruise because it operates at lower levels of autonomy and requires human supervision. But that may change after videos like drivers having to take over to avoid accidentally swerving into pedestrians crossing the road or failing to detect a truck in the middle of the road continue circulating.

    Continue reading
  • Alien life on Super-Earth can survive longer than us due to long-lasting protection from cosmic rays

    Laser experiments show their magnetic fields shielding their surfaces from radiation last longer

    Life on Super-Earths may have more time to develop and evolve, thanks to their long-lasting magnetic fields protecting them against harmful cosmic rays, according to new research published in Science.

    Space is a hazardous environment. Streams of charged particles traveling at very close to the speed of light, ejected from stars and distant galaxies, bombard planets. The intense radiation can strip atmospheres and cause oceans on planetary surfaces to dry up over time, leaving them arid and incapable of supporting habitable life. Cosmic rays, however, are deflected away from Earth, however, since it’s shielded by its magnetic field.

    Now, a team of researchers led by the Lawrence Livermore National Laboratory (LLNL) believe that Super-Earths - planets that are more massive than Earth but less than Neptune - may have magnetic fields too. Their defensive bubbles, in fact, are estimated to stay intact for longer than the one around Earth, meaning life on their surfaces will have more time to develop and survive.

    Continue reading

Biting the hand that feeds IT © 1998–2022