In a well-fleshed-out post, Scott Chacon shows how unneecessary Git 3.0's move to replace SHA-1 with SHA-256 is.

all 22 comments

sorted by: hot top controversial new old
[–] 12 points 1 month ago (3 children)

Why did they skip the 255 versions?!

/s

  • source
  • hideshow 3 child comments
  • [–] 11 points 1 month ago (2 children)

    This post misses, uh, a few important things that get mentioned in the lobsters comments: https://lobste.rs/s/bytzgl/git_3_0_s_upcoming_sha_256_default_will_be

  • source
  • hideshow 2 child comments
  • [–] 21 points 1 month ago

    Madness

    We had a similar stupid issue at my last job. Someone made an edict that all Sha-1 and md5 references in the code must be removed for security reasons.

  • source
  • [–] 21 points 1 month ago (4 children)

    There's people who seriously think commit hashes are there for security purposes? Furthermore, there are git MAINTAINERS that think this?

    How absurd. Author is completely right, making SHA-256 the default implementation serves no purpose. SHA-1 is a completely valid algorithm for non-security use cases, which is precisely how git uses it. This is a solution looking for a problem.

    I think he's maybe overblowing the impact of this change. Realistically, the only ones who are going to be impacted are the folks who maintain git-related tools and forges, as he mentions. The rest of us probably won't even notice. But that's still a ton of pointless work for those folks.

  • source
  • hideshow 4 child comments
  • [–] 4 points 1 month ago

    I think he's maybe overblowing the impact of this change.

    Maybe... But I don't look forward to working with the dozens of IT folks at my company who all installed git once and have never upgraded. This will be multiple meetings, show up on slide decks, break builds...

    It's going to be a right pain for nothing.

  • source
  • parent
  • [–] 3 points 1 month ago* (2 children)

    Wait, they don't affect security? Wouldn't a hash collision mean pulling that hash from GitHub would pull wrong code? Or maybe delete code? I'd assume the hash is used as a lookup key in a database somewhere.

    You also pin dependencies to specific hashes for security reasons.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 5 points 1 month ago

    The blog post lays it out pretty well.

    The vulnerability of SHA-1 is that it's possible for an attacker to find colliding hashes. But that's not really an attack vector, because it's not like they can find aatching hash for just ANY input. In order to pull off an attack, using a hash collision, an attacker would have to already be trusted within the controlling system, in which case they can do a hell of a lot worse than swapping out a file.

    Like you say, the hash is used as a lookup key within the git repo's database. The requirement for that is uniqueness, which SHA-1 still fulfills just fine. The trust isn't in the database lookup, the trust is in the systems that controls access to and distribution of that database.

    As the article points out, Linus Torvalds himself said as much in 2005, when he first wrote git:

    I really think people should not consider the sha1 the "security". The real security is in distribution.

  • source
  • parent
  • [–] 24 points 1 month ago (3 children)

    His defense of SHA-1:

    Mathematically, for SHA-1’s 160-bit output, the birthday bound means that you would need about 1.4 septillion random files (1.4 quadrillion billion files - 1,400,000,000,000,000 billion - it's impossible to effectively describe) in a single project to have file hashes accidentally collide.

    For the most part the article mostly talks about collision attacks, which quite frankly i think is silly.

    He also talks about hashes pointing to other (older) projects using a different hashing algorithm, but can't the software just detect if its a SHA-1 hash or SHA-256, and fetch it accordingly? He acts like its the end of the world when in my mind most everything can (and probably will) be compensated for pretty easily. It's reminiscent of the IPv6 fear-mongering.

    The thing that gets me is he doesn't say if the current hashing algorithm or the new one has any support for when hashes do collide. Since that can theoretically happen with both, to me that sounds like a problem worth tackling.

  • source
  • hideshow 3 child comments
  • [–] 1 point 1 month ago*

    Collision concerns make sense. If you manage to get two different files with the same hash, that will cause issues for your repo - the concerns over a collision justify the move to SHA-256 though.

  • source
  • parent
  • [–] 7 points 1 month ago (1 child)

    I'm not qualified to talk about it but Hacker News has arguments against his post: https://news.ycombinator.com/item?id=49924179

  • source
  • hideshow 1 child comment
  • [–] 25 points 1 month ago

    You're probably more qualified than most HNers, just less confident, less inclined to indulge in performative expertise and pseudo-intellectual posturing, and more resistant to joining the circle-jerks with those who do indulge.

  • source
  • parent
  • [–] 4 points 1 month ago* (2 children)

    It's sad to see this community only listening to people because they're rich: there are a lot of better engineers who knows more than this guy but they're not "co-creator of GitHub". I read this title as boot licking silicon valley.

    That being said you don't hash git commits for security reason : YOU SIGN YOUR COMMITS FOR SECURITY. Sorry for the caps but let's make this visible.

  • source
  • hideshow 2 child comments
  • [–] [S] 2 points 1 month ago

    If you know of write-ups by others on this, you are welcome to share. It was a pretty long post, so I mentioned who authored it. If it was on, say, LWN, I wouldn't have prefixed anything to the topic. It looks like it also helps people to avoid rich-man blogs (if they want to)!

  • source
  • parent
  • 19 comments in c/programming@programming.dev view that post
    [–] 57 points 1 month ago (8 children)

    I tried to implement my own git from scratch. And when I got to choose a hashing algorithm, I reached the exact same conclusion as the author pretty fast.

    The hashing algorithm doesn't really matter as long as it's good enough to prevent accidental collisions. And if there is a collision, it is extremely easy to check.

    If you are about to create a new object and an object with that hash already exists, you compare the 2 objects. If they are the same, nothing happened. If they are different, you just found a collision. Throw some obscure error that will only be witnessed once in the lifetime of the universe and be done with it. Tell the user to change a single bit of the input and be done with it.

    The purpose of object hashes in git was never to provide security. Security is achieved through other means.

  • source
  • hideshow 8 child comments
  • [–] 7 points 1 month ago (6 children)

    Even if it's not the purpose it can fulfill it. Hashes are used for all kinds of things like traceability or for pinning versions. They are used in a context where people depend on that a hash always has the same code behind it and SHA1 can not guarantee that anymore. A better hashing algo is needed to keep the way how people use git secure.

    It's not enough to say "you shouldn't use it that way". We have to accept the reality of how git is used and adapt.

  • source
  • parent
  • hideshow 6 child comments
  • [–] 6 points 1 month ago (5 children)

    If someone has access to write to a repo you are downloading code from, and you don't trust that someone, you shouldn't be running the code in that repo.

    The only "security" vulnerability is: I have audited and verified that the code in commit 05682ab36ca. And I will use only that version.

    What you do then is: download that commit and store it in a local repo, and package it so you can distribute it to your clients.

    Auditing external software is tremendous effort, even if it is open source. Using your local repo instead of downloading that commit from GitHub every time is very little extra effort in comparison.

    And if you really need it. You can always hash with sha256 yourself and verify that the commit with that sha1 still produces the same sh256. So you can keep downloading it each time, just need to store the sha256.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 2 points 1 month ago (4 children)

    You are exactly doing what I described. You are saying "your using it wrong" instead of acknowledging that's how people use it and and then improving that. You might not need this feature because you are "using it correctly" but that doesn't matter. For the lived reality of many people sha256 is the correct move.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 4 points 1 month ago (3 children)

    I've never heard of anyone relying on git's sha1 hashed for security

  • source
  • parent
  • hideshow 3 child comments
  • [–] 1 point 1 month ago (2 children)

    I have. In some languages you can use git repos as dependencies. It's good practice to use hashes instead if tags because tags are not immutable. SHA1 hashes are better than tags but better hases would be even better.

    Also traceability. You can build a chain from your commit over ci to the artifact if you do it right. If you can change the files to a hash you can destroy that trust chain. Sha256 makes that impossible.

    People use the hashes in ways you might not. It wasn't meant as a trust anchor but it became one. And that is now being addressed. I also think that the git maintainers have put a lot of thought into backward compatability and making the change as painless as possible.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 1 month ago (1 child)

    Good practice != Something that ensures security. As I said, it's an even better practice to just host your own fork if what you want is security. The reason to use git hashes is mostly so you don't have to trust the author following semver in there version number. It's a matter of ensuring that your code will always compile, not a security feature.

    Have you read the article? Your arguments derive from an assumption of "sha1 is mutable, sha256 is immutable". First of all, every hashing algorithm is going to have collisions, that's an unavoidable "feature" of hashes. And sha1 is in no way "mutable", it takes a great amount of effort (and money) to generate a collision. Furthermore, those collisions are not arbitrary. You have to calculate them beforehand. As the article says: what is more likely? Paying 40k€ in compute time to generate a single collision? Or just paying an open source maintainer 40k€ to let you do 1 new commit that most people are going to download anyway?

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 1 month ago

    Yes I read the article. I don't agree with all the conclusions.

    Now is the best time to change to a new algo. SHA1 is not completely broken yet. It most probably will be at some point.

    Also AFAIK they will have compatibility tools for SHA1 repos in git. I don't see the big deal with the path they chose.

    We will probably nor agree on that one. I think the hashes are important and that they are mutable right new with effort and later without. It's okay that we don't agree though. The git maintainers have made their decision anyways.

  • source
  • parent
  • [–] 6 points 1 month ago* (last edited 1 month ago)

    Security is achieved through other means.

    Let's explicit this: you can, and should, sign your commits if you want security (no commit tampering). You need to:

    • generated a gpg key: gpg --full-generate-key
    • set git to look for the public key to use: git config --global user.signingkey [public key ID]
    • set git to sign your commits: git config --global commit.gpgsign true

    Note that I used --global here but you can do without to sign on a per-project basis.

    Also gpg UX is terrible, to find the [public key ID] use the command gpg --list-keys, it should looks like:

    pub   ed25519 2026-01-01 [SC] <- type algorithm date and capability (this key is only to Sign and Certify)
          662E3CDD6FE329002D0CA5BB40339DD82B12EF16 <- Public key ID
    uid           [ultimate] my full name (Master Key) <my_email@domain.com> <- owner information (should be your name and email address)
    sub   rsa4096 2026-01-01 [E] <- sub key used to encrypt
    sub   ed25519 2026-01-01 [S] [expires: 2027-01-01] <- subkey used to sign
    

    Last, if you want to save/backup you keys the default location of gpg files is ~/gnupg or you can export keys with gpg --export [key ID] > path/to/file.key for the public part and gpg --export-secret-keys [private key ID] for the private part. Both export can have a -a or --armor argument to output as base64 text instead of raw binary. [private key ID] can be found with gpg --list-secret-keys.

    EDIT: after writing this I checked https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work and TIL you can sign tags too.

    EDIT 2: you can also use your ssh key to sign -> git config --global gpg.format ssh (I am less inclined to do this as you won't have subkeys and expiration date but this would be simplier indeed)

  • source
  • parent
  • [–] 16 points 1 month ago (5 children)

    There are some very good points in there, I would like to hear the counter-arguments.

  • source
  • hideshow 5 child comments
  • [–] 10 points 1 month ago (3 children)

    Which are? I'm not joking, "GitHub broken" and "Google has issues" are not arguments against a better encryption default.

    The submodule argument is transitional at best.

    As for the pro side (note that this is my opinion, I'm not deeply involved in the discussion - and with not deeply I mean "not at all"):

    The case the author aggressively ridiculed ("I don't use GPG to trust, I trust the GitHub authentication!) is one that anyone would have if they'd want to stay safe from centralized systems.

    Another is upstream availability: once an algorithm is identified as broken (no matter how small) usage drops rapidly - there's a reason why no one uses md5 anymore although it "would be fine" for purely collision mitigation.

    And then there the simple fact that the integrity hash is a security feature, not purely anti collision (as the author also describes). Just because they (nor I!) can't see an attack vector at the moment doesn't make this less of an issue.

    In short: it's the other way around: you'd need way stronger arguments than "there will be a transition pain" to knowingly compromise your security.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 1 point 1 month ago (1 child)

    I still like md5 for collision detection, but every damn security scanner flags it. So then you have to add the exception, then explain to auditors about the exception. It's not worth the hassle for the increased performance.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 5 points 1 month ago

    There's no reason to use md5 if you don't care about security and only want speed. Non-cryptographic hashes are incredibly fast to calculate and there are far faster hashing algorithms if you want to go that route. Using md5 is a "I don't want to think hard" answer, and if you don't want to think hard, then you might as well be secure in your default answer.

  • source
  • parent
  • [–] 8 points 1 month ago* (last edited 1 month ago) (2 children)

    thats bad, i got couple of repos on sha-256, i wonder what happens if they drop it, which i think they wont, do i have to like re-create them?

  • source
  • hideshow 2 child comments
  • [–] 14 points 1 month ago

    The blame and mistake isn't honestly on git, but the rest of the tooling ecosystem. This wasn't a snap decision and the fact that nobody thought to get ready in the 6 god fucking years that this has been planned is the real problem.

    This will be painful, but only because apparently nobody was willing to just start supporting it 5min before the deadline.

  • source
  • 13 comments in c/git@programming.dev view that post
    [–] 12 points 1 month ago (3 children)

    The author makes the argument that we shouldn't update the hashing algorithm because an adversary has simpler, cheaper means to achieve the same goal of injecting malicious code into a project. I don't find this a convincing reason. People say the same about Wayland. As I understand it, Wayland makes it so that processes can't see inside windows in other processes or observe the keyboard when one of its windows is not in focus, something X11 apparently doesn't guarantee. They say we shouldn't switch because it would achieve nothing: an adversarial program could just as easily do similar snooping because it has access to the user's home directory. I think that just means we need to also patch the other holes. You can't improve security by doing nothing. It's like you have two insecure doors in your home and you don't bother installing a lock on one because an intruder could easily get through the other one. You have to start somewhere. You can strengthen the hashes and try to patch the other holes (social engineering, etc.) at a later point.

  • source
  • hideshow 3 child comments
  • [–] 8 points 1 month ago

    he gives a pretty reasonable solution at the end? basically his point is the implementation is problematic and causes churn for everyone who uses git and if the concern is really about security then they would allow swapping out the verification hash instead of hard coding it again and waiting for 256 to be broken.

  • source
  • parent
  • [–] 7 points 1 month ago* (last edited 1 month ago)

    Wayland actually increases the barrier to entry by improving the security model.

    Git commit hashes were never meant for security or trust, and trying to crowbar them into that role is shortsighted, as Linus argues.

    Personally, I'm in favor of the migration and would already be using it (except Nix only supports sha1 atm). But, the security argument isn't a good one.

    I'm in favor of a better hashing algorithm because the hash will be a better hash, not because I think it will improve the cryptographic security and trust of my repos. But honestly, that's just a nerd mental thing. I could take it or leave it. SHA1 is sufficient for the role.

  • source
  • parent
  • [–] 2 points 1 month ago

    I don't think your Wayland comparison is great. There are already solutions to app isolation that make X a weak link, e.g. Android or Qubes. Whereas there's basically no future where SHA1 in Git is the weakest link.

    Also security was only one reason for Wayland.

  • source
  • parent
  • [–] 9 points 1 month ago* (last edited 1 month ago)

    Very interesting. I taught git to students last year and was showing them the SHA256 option and the issues he's describing was pretty much what I was wondering about. If you force people to switch, with no intercompatibility, holy shit this is gonna be quite the clusterfuck!

    What I'm taking away from this is that Linus was right from the get go : SHA1 isn't there for security, it's a really good algorithm for a hashtable's hash where we really want to avoid collisions. That's it.
    If you're thinking it's safe because it used to be involved in security, you're a muppet.

  • source
  • [–] 6 points 1 month ago

    great read, thanks for sharing!

  • source
  • [–] 4 points 1 month ago

    Migrations like this are a good reminder to write down why a default changed. Junior devs often skip reading the design discussion, but it teaches more than the release notes.

  • source
  • [–] 2 points 1 month ago

    Good thread. For mentees learning git, I would start with a clear branching habit before worrying about hash internals.

  • source
  • [–] 0 points 1 month ago (3 children)
  • [–] 4 points 1 month ago (2 children)
  • [–] 0 points 1 month ago

    Can't argue with that! The fact that you cant mix and match within a repo means this should be a complete non-starter.

  • source
  • 9 comments in c/technology@lemmy.world view that post
    [–] 22 points 1 month ago (8 children)

    The root problem is that there is no backward compatibility - you can't mix the two. Why is that is beyond me.

  • source
  • hideshow 8 child comments
  • [–] 14 points 1 month ago (6 children)

    I read that whole article, and aside from an unsourced statement that GitHub et al will need "new and distinct servers" exactly zero of that seemed to support the thesis that a SHA-256 default was going to be "expensive".

    Submodules are not the preferred way to incorporate third-party code for any environment I know. And while web-exposed URLs for management tools like Jira or AzureDevOps will need to adapt before the new default can be used, doing so even with a wholesale re-hashing of every commit isn't technically difficult.

    What would be terrible and dangerous would be if git 3.0 entirely dropped SHA-1 support. But just as you're free to keep on using "master" instead of "main", i expect that extant projects will still be supported until a version after every major project has converted to SHA-256 or what have you.

  • source
  • parent
  • hideshow 6 child comments
  • [–] 5 points 1 month ago (2 children)

    Further reading that casts doubt on even submodules breaking:

    https://www.deployhq.com/blog/git-3-0-on-the-horizon-what-git-users-need-to-know-about-the-next-major-release

    It sounds like the new default is specifically to push GitHub et al to support SHA-256. Which they either will, or they will fork git and continue on with SHA-1 forever.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 1 month ago (1 child)

    Where do you see that submodules won't cause headaches?

  • source
  • parent
  • hideshow 1 child comment
  • [–] 5 points 1 month ago

    The bit about "comparability". Where do you see that they will? (I mean, aside from the original article that claimed it without evidence.)

    A submodule is "just" a pointer to a specific commit in an external repo. It was at one point entirely done via shell scripts, and unless I missed an update is still obnoxiously slow compared to the rest of git.

    I can't fathom why the SHA-256 support for submodules would do more than just treat the SHA as a foreign key.and go from there. We'd potentially be in trouble if SHA-1 support is being removed, but I don't see any reason why git would do something so stupid.

    (I honestly can't fathom why SHA-256 hashed commits couldn't be the children of SHA-1 commits. A bunch of reasons why you may not WANT to, but that's a separate concern that seems like it'd be outweighed by comparability.)

  • source
  • parent
  • [–] 5 points 1 month ago (2 children)

    Submodules are not the preferred way to incorporate third-party code for any environment I know. And while web-exposed URLs for management tools like Jira or AzureDevOps will need to adapt before the new default can be used, doing so even with a wholesale re-hashing of every commit isn’t technically difficult.

    Well, like it or not, they are used. And not so rarely. Now, rehashing will probably work, but it will require every project to do that. If you use more than one submodule which is not under your control, you have again mixed hashes that you can't fix easily.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 1 month ago (1 child)

    Sorry for the late reply.

    Again, do you have any actual evidence that SHA-256 repositories in version 3.0 won't be able to reference SHA-1 repositories as submodules?

    Based on the design doc it looks like git will include both hashes during the transition, specifically to allow two-way communication with SHA-1 remotes. You may not be able to include a random stranger's SHA-1 submodule via a shallow clone, but just doing a full clone sure as heck looks like a supported usage.

    https://git-scm.com/docs/hash-function-transition

  • source
  • parent
  • hideshow 1 child comment