News for hackers. Stuff that matters.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Thursday October 01, 2026 @02:25PM (#49925255)
The problem of a SH1 collision happening by coincidence is vanishingly low and theoretical.

Nothing else matters.

Git hashes are not supposed to be a security mechanism. If your basis for trusting that you have the right checkout is the git hash, in a situation where you have legitimate concern about untrusted parties manipulating remote repositories, then you're simply wrong.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by zygentoma on Thursday October 01, 2026 @03:58PM (#49926360)
Sorry, no.

When I check out code from a git repository in a pipeline using a git hash, I expect the code to be exactly what has been reviewed by me under that hash.

Everything else would just be a crazy invitation to make supply chain attacks uncircumventable.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Thursday October 01, 2026 @04:24PM (#49926637)
And so if you don't trust the server that is hosted on or the security of the transport mechanism like TLS/SSL, such that the content may be manipulated by adversaries, you think that git hashes are good enough?

Well, what about someone who is fetching the commit from that server for the first time and has nothing to compare the hash against?

Oh, that would never be a problem for widely disseminated, popular, open source project, so it doesn't matter.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by crote on Thursday October 01, 2026 @04:59PM (#49927014)
Dealing with potentially-hostile hosts is quite common, actually. See for example how most Linux mirrors work, or Subresource Integrity with HTML.

Turns out securing a service to transfer a single hash is a lot easier than securing a service to transfer gigabytes of data.

Even if I don't fully trust Github, it is still incredibly convenient to be able to upload my code there and then send someone an email telling them to fetch commit `123abc` from some repo link. As long as my email isn't compromised, that should be secure.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by hedora on Thursday October 01, 2026 @11:15PM (#49929505)
Similarly, if you push to github, then trigger CI through something other than github actions, then (other than the SHA-1 problem), you have reasonable assurances that someone who has compromised GH cannot compromise your CI host.

Note that the US CLOUD Act means that, if someone figures out how to actually use collisions to compromise that CI machine, then, if the US government asks Microsoft to do use that vector to break into an overseas machine, then Microsoft will be legally obligated to do it.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by hinkley on Friday October 02, 2026 @04:42AM (#49931246)
Code signing also generally relies on hashes. You don’t encrypt the code to make a signature, you encrypt a fingerprint of the code, which is usually a hash from the SHA family.

I pushed aviation toward starting with SHA-256 instead of SHA-1 for code signing more than fifteen years ago, just after NIST first started discouraging the use of SHA-1 in new code.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by PunchyHamster on Thursday October 01, 2026 @07:51PM (#49928352)
I mean, Git commit signing should be used more often... then you can actually trust the person signing, not the distribution method

But you still need SHA256 for that

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kstrauser on Thursday October 01, 2026 @10:37PM (#49929329)
Rumor has it that GitHub has a flat namespace for commits. They don't store "user1/repo1/abcd1234" in one file and "user2/repo2/abcd1234" in another. Both references point to the same commit in a global shared space. If the hashes are truly unique, then that never matters, because the odds are approximately 0.000000000...000 of you and I accidentally generating the same commit. However, if I see that you pushed commit abcd134, and then I can build and push a colliding commit, and the backend doesn't check uniqueness before writes because the odds are infinitesimal that it'd ever matter, than voila, I've updated your repo by writing to my own.

Or if first writer wins, and I know that you have a popular non-GitHub repo that you're about to migrate into it, then I could pre-poison the namespace by writing my own version of a commit that I see you already have in Codeberg or Savannah or wherever.

I don't swear that this is how GitHub actually works, but I've had knowledgeable friends swear up and down that it is. And honestly, it'd make sense. They could shard storage by the first 4 digits of the hash or something, and that'd be vastly more efficient if all commits were writing to the same space.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by hedora on Thursday October 01, 2026 @11:14PM (#49929502)
I'd expect an LLM to prove this (if true) in ~ 60 minutes, given just your post and "try to prove this true or false; here's a github PAT".
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by nulld3v on Thursday October 01, 2026 @11:48PM (#49929643)
It is already known to be true for repos that are forks or have been forked: https://trufflesecurity.com/blog/anyone-can-access-deleted-a...
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by computerfriend on Friday October 02, 2026 @12:30AM (#49929849)
That's per-repo. The claim is that user/repo/commit is flattened to just the commit. Your counterpoint (which I agree with and is well-known) is that it's flattened to repo/commit (dropping the user).
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by nulld3v on Friday October 02, 2026 @01:19AM (#49930077)
Ah right, though I think it is rather unlikely Github flattens across multiple repos given that Github has already blogged about how their repo storage backend (Spokes) works, and it seems to operate entirely on whole repositories.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by computerfriend on Friday October 02, 2026 @02:46AM (#49930517)
Yeah, I also don't believe it.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by jb1991 on Friday October 02, 2026 @06:24AM (#49931883)
I also don't believe it.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by schacon on Friday October 02, 2026 @02:17AM (#49930356)
So, I haven't worked at GitHub in some time, but we never had a flat namespace for objects. There are a lot of SHAs in the DB but objects are always namespaced by repository. Forks shared an object database for efficiency, and have technically added reachable objects to a shared database via fork, but it's never been a real problem afaik.

But the very wrong assumption here is: "if I see that you pushed commit abcd134, and then I can build and push a colliding commit, and the backend doesn't check uniqueness before writes"

All parts of this are incorrect.

You can push a colliding commit to a fork, but Git will see that it's already there and ignore it - first write does win. Also, "backend doesn't check uniqueness" is also wrong. The server will check for collisions and if this particular case happens, the server will see this and warn you _AND_ not write the object.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by tanoku on Friday October 02, 2026 @05:35AM (#49931599)
> I don't swear that this is how GitHub actually works, but I've had knowledgeable friends swear up and down that it is.

All the details on how GitHub's infrastructure has evolved over the years are very publicly detailed in the GitHub engineering blog and in technical talks. There are no "secrets" or "rumors" here, all the information is one google search away. Perhaps you need to re-evaluate your priors on how knowledgeable your friends are.

- https://github.blog/engineering/architecture-optimization/in... - https://www.youtube.com/watch?v=Ri8hSZNKzu4 - https://github.blog/engineering/building-resilience-in-spoke... - https://github.blog/open-source/git/counting-objects/ - https://www.youtube.com/watch?v=DY0yNRNkYb0 - https://cursor.com/blog/git-at-any-scale

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by fpaq on Friday October 02, 2026 @01:55PM (#49936501)
> However, if I see that you pushed commit abcd134, and then I can build and push a colliding commit...

You cannot do that. This is called a second-preimage attack, which has not been demonstrated even against MD5, let alone SHA1.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by lxgr on Friday October 02, 2026 @04:35AM (#49931213)
> And so if you don't trust the server that is hosted on or the security of the transport mechanism like TLS/SSL, such that the content may be manipulated by adversaries, you think that git hashes are good enough?

Yes, they ought to be good enough. That has always been git's security model.

Note that the commit doesn't have to be communicated over the same channel as the git data.

> Well, what about someone who is fetching the commit from that server for the first time and has nothing to compare the hash against?

Then they're vulnerable. But what about somebody learning about the trusted hash in another way, e.g. a build server getting an internal call authenticated by an authorized developer?

Just because you can think of an insecure way to use git hashes doesn't mean there aren't any other, secure ones.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Friday October 02, 2026 @08:31AM (#49932758)
You are not saying anything other than that hashes are useful for signing. When you communicate to someone that you trust such and such a hash, and they should too, you are informally certifying the hash, the cryptographically formal way to do which is to sign it.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by lxgr on Friday October 02, 2026 @08:50AM (#49932949)
> You are not saying anything other than that hashes are useful for signing.

Yes, but you seem to be saying they are not, or maybe just that git hashes are somehow inherently not capable of taking that role, unless I'm misunderstanding.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by pjc50 on Friday October 02, 2026 @05:24AM (#49931533)
> And so if you don't trust the server that is hosted on or the security of the transport mechanism like TLS/SSL, such that the content may be manipulated by adversaries

Wait, why is anyone expecting that to be a good idea at all?

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by zygentoma on Friday October 02, 2026 @10:54AM (#49934202)
> And so if you don't trust the server that is hosted on or the security of the transport mechanism like TLS/SSL, such that the content may be manipulated by adversaries, you think that git hashes are good enough?

How does this matter? When I have a machine that I trust and a git hash that I trust, I don't need to rely on the transport mechanism. As long as the content cannot be forged to match the hash, the transport is completely irrelevant.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by 7bit on Friday October 02, 2026 @10:20AM (#49933841)
Sorry, no. For trusting code there is code signing. A sha-1 hash is cryptographically the wrong approach for it or we wouldn't have RSA and ECDSA algos.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by zygentoma on Friday October 02, 2026 @10:50AM (#49934158)
And what do these cryptographic signing algorithms do? They sign a cryptographic hash of the data … Which the SHA-family of hashes are.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by alerighi on Friday October 02, 2026 @10:29AM (#49933942)
If you rely on the commit SHA-1 as a integrity verification it's your problem. Git was never intended to be used as an integrity check.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by zygentoma on Friday October 02, 2026 @10:53AM (#49934184)
Git was maybe never intended to be used as an integrity check, but SHA hashes definitely were and are.

And if git provides a cryptographic hash over the content, I don't see why it shouldn't be used to verify the integrity of the checked-out content.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by foldr on Saturday October 03, 2026 @09:59AM (#49944333)
The reason why not is very simple: the SHA-1 algorithm was chosen because it made it practically impossible for two commits to have the same hash, not on the assumption that it would remain forever immune to collision attacks.

A vulnerability can be found in a hash algorithm at any time, whereas changing git's hashing algorithm is inevitably a slow process. IMO, if you want to ensure that someone gets an exact set of files, zip it up and sign the archive with the algorithm of your choice. It's not necessarily going to be practical to change git's signing algorithm every time a security issue is found.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by onraglanroad on Friday October 02, 2026 @01:43PM (#49936308)
I think perhaps you used the wrong words there. The hash is an integrity check but it was never intended as a security check.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by smaudet on Friday October 02, 2026 @11:34AM (#49934672)
>I expect the code to be exactly what has been reviewed by me under that hash

Sorry, no.

Again, hashes are by definition, insecure. I.e. you don't have a guarantee that the hash references the same commit, just a (very, very strong) probability that it does.

> Everything else would just be a crazy invitation to make supply chain attacks uncircumventable.

What? Uncircumventable? Logically equivalent, I read your statement as "So if all cars are not blue then they must be red"? This does not follow...

I like the last part of the article, which proposes a (very reasonable sounding) extension for people who care (more) about their code-sec. You should be able to swap out your hash algo without having to rebuild your content addressing system.

Separation of Concerns, people...

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by fpaq on Friday October 02, 2026 @02:04PM (#49936606)
> Again, hashes are by definition, insecure. I.e. you don't have a guarantee that the hash references the same commit, just a (very, very strong) probability that it does.

This doesn't seem to be a useful definition. Would you classify every computable algorithm as insecure, because by generating a random bitstring, there is a (very, very low) probability of guessing the hash/secret key/solution/signature?

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by Dylan16807 on Saturday October 03, 2026 @02:57AM (#49941962)
> Again, hashes are by definition, insecure. I.e. you don't have a guarantee that the hash references the same commit, just a (very, very strong) probability that it does.

Cool, you've just defined the foundation of signatures and web encryption as insecure. What next?

Also, you can only be so certain about any piece of data no matter what you do. With a non-broken hash you can make the collision chance be a trillion times lower than the chance you're hashing the wrong data to begin with. That's as good as gold, well actually better than gold.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by Henchman21 on Friday October 02, 2026 @12:52PM (#49935749)
Sorry, but aren't there signing and attestation mechanisms built into git already? Why not use those?
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by shakow on Thursday October 01, 2026 @02:47PM (#49925534)
> Git hashes are not supposed to be a security mechanism

Probably a naive question, but why not kill two birds with one stone if it can be done for a reasonable cost?

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Thursday October 01, 2026 @02:57PM (#49925658)
Because you're not killling two birds; you're not killing the security bird with a better content hash.

A SHA-256 sum, though very good, only assures you with great confidence that you're looking at the same thing you looked at before, or that someone else is looking at elsewhere.

It is not a digital signature, and we don't want digital signatures to serve the role of content hashes.

Speaking of signatures, we have support for them in Git; you can use gpg to sign commits, and set it up to be done automatically.

Nobody is going to fake your commit such that the fake has the same SH-1 hash and your GPG signature.

The worry there is that the key holder (whether the legitimate one, or a malicious party who got a hold of the key) somehow does this: creates a new commit, signed with their key, which somehow has the same SH-1 as an existing signed commit. The git hash includes the GPG signature, so there is a significant layer of difficulty there which is likely harder than faking an unsigned SHA-256 commit.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kpcyrd on Thursday October 01, 2026 @03:47PM (#49926229)
Please educate yourself what a merkle tree is. It's a well understood building block of various security systems, including certificate transparency (which explicitly uses sha256).

You refer to PGP signed Git objects, but you also argue:

> Git hashes are not supposed to be a security mechanism

Guess what the Git PGP signature is signing.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Thursday October 01, 2026 @04:13PM (#49926529)
[delayed]
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by crote on Thursday October 01, 2026 @04:51PM (#49926943)
That doesn't make a difference: with sha1 a malicious change in content will still result in the same content hash, so the signature will still be valid, and the commit hash will still be the same.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Thursday October 01, 2026 @04:59PM (#49927019)
Only if the GPG signing process stupidly relies on the SHA-1 hash. I.e. if it takes an unsigned commit and signs only its SHA-1 hash and then creates a new commit with GPG headers. If that's how it works, that is massively stupid and can be fixed without forcing SHA-256 as a git hash. Just have the signing calculate its own digest for its own purposes.

That digest can be the SHA-256; since the infrastructure is there for it, signing should use SHA-256 regardless of what hash is used by the repository for identifying and linking content.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by semiquaver on Thursday October 01, 2026 @08:19PM (#49928512)

  > if it takes an unsigned commit and signs only its SHA-1 hash and then creates a new commit with GPG headers
It does indeed. The bytes passed to GPG when constructing a signed commit look something like:

  tree eebfed94e75e7760540d1485c740902590a00332
  parent 04b871796dc0420f8e7561a895b52484b701d51a
  author Alice <[email protected]> 1465981137 +0000
  committer Alice <[email protected]> 1465981137 +0000

  Headline

  Message

where the contents being signed are entirely represented by the oids of the tree object and parent commit object. This string is very similar to the content that is fed to the hash function to produce a normal git commit object id.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Thursday October 01, 2026 @09:36PM (#49929003)
Haha, well that is a screw up. The weak tree hash can be attacked, replacing the content that is itself not pulled into GPG.

The "bytes passed to GPG" of course get hashed by GPG, using something better than SHA-1.

All bytes that comprise the commit should be hashed by GPG, rather than depending on the content referencing hash in the object tracking system.

This is something that is possible; it is not a logically deductive necessity that we just scan the topmost object and trust the hashes it contains.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by dwohnitmok on Thursday October 01, 2026 @09:50PM (#49929075)
> it is not a logically deductive necessity that we just scan the topmost object and trust the hashes it contains.

It kind of is. Otherwise the whole idea of signing a commit with a backing git history (rather than just a snapshot of a working directory) collapses. The only guarantee you have that the git history is what is claimed by the cryptographic signature is some sort of Merkle tree structure. Either the original one, or you have to construct a whole new parallel one with a better hash, in which case, as I bring up in a cousin comment, why not just use a better hash in your original one?

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Thursday October 01, 2026 @11:03PM (#49929445)
In a git repo based on SHA-1 hashes, it would be good enough that the meaning of a commit signature is that the content of the commit is attested, not the parents.

Parent commits can have their own signatures, and it's true that there is an attack possible there where the same parent hash could point to two different commits, that have valid signatures of some kind (possibly from the same sneaky developer who is a bona fide project member).

Be that as it may, it's perfectly okay for the signature on a banana to validate only the banana, and not the gorilla that is holding it, or the vine the gorilla is swinging on, and the whole jungle.

It would be worth it to have better quality commit signing for SHA-1-based repos.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by dwohnitmok on Friday October 02, 2026 @01:13AM (#49930048)
> it would be good enough that the meaning of a commit signature is that the content of the commit is attested, not the parents.

This is a significant degradation of the implicit guarantees given by a cryptographic signature, to the point that basically all personal use cases I have for signed commits would be invalidated.

Keep in mind that git does not have diffs as first-class objects. Every commit is just a snapshot of some state of the working directory. That means that without attesting to the integrity of the parents of a commit, the only thing a commit X signed by a person A says is "at some point on A's computer, the state of the repo looked like X".

Almost all the relevant questions I would want to ask are not answered by this. E.g. there is a malicious function F that is present in X. Did A write it? Don't know. Did someone else write it? Can't know for certain. Who introduced a certain feature? Don't know. Did A sign off on a new bugfix? Don't know.

All you know is that at some point the codebase looked like X on A's computer. A might not have made any relevant changes at all!

You can only back out a diff and therefore actually attribute a change to someone (either explicitly through `git blame` or informally by looking at git logs) if you have attestation of the parents.

The Merkle tree structure of git repos is interwoven through basically ever useful thing git does. Without cryptographic signatures implicitly carrying a promise of validity for that structure, this would make commit signing useless (depending on just how broken SHA-1 is) for the needs of any org I've ever worked at.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Friday October 02, 2026 @07:58AM (#49932496)
In a SHA-1-based git repo, if a signature were to digest all the bits spanned by a commit, that would be a monotonic improvement over what is done now, even if it falls short of some people's expectations.

Because now, commit X signed by person A does not even attest that the repo looked like X on A's computer, or not very well, due to weaknesses in the hash.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by lxgr on Friday October 02, 2026 @09:06AM (#49933120)
Have you ever worked with large repositories? You really don't want to read every single byte from disk just for signing a commit if you can avoid it.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Friday October 02, 2026 @01:27PM (#49936143)
Then use a SHA256-based repo, and use the cheaper signing scheme.

For some people, an improved signing scheme over the SHA-1-linked repository format would meet their requirements based on their assessment of their security threats.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by Dylan16807 on Friday October 02, 2026 @01:50PM (#49936415)
> Then use a SHA256-based repo, and use the cheaper signing scheme.

The scheme you just called a "screw up"?

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by dwohnitmok on Thursday October 01, 2026 @09:40PM (#49929027)
> If that's how it works, that is massively stupid and can be fixed without forcing SHA-256 as a git hash.

I don't think it's massively stupid. Unless you want to re-hash the entire Merkle tree structure to sign your commit, you basically have to trust the hashes in the Merkle tree (or have a separate parallel Merkle tree) at some point in what you sign, which means you do have to trust the SHA-1 hashes. Otherwise even with a cryptographic signature you can always spoof at least the git repo history (e.g. even if you try to directly hash the entire contents of the current commit).

Re-hashing the entire Merkle tree structure seems prohibitively expensive to generate (even with a lot of caching) and pretty complicated for e.g. verifying a signature. Or you can do that incrementally, but then you're just generating a whole new parallel Merkle tree structure.

Regardless, at the end of the day, you need to trust the integrity of the Merkle tree structure. And you can either do that by trusting the hashes of the current Merkle tree, or you have to completely recreate a new one with more trustworthy hashes, in which case why not just use better hashes in your original tree?

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Thursday October 01, 2026 @11:04PM (#49929453)
I need a commit signature to only attest the integrity and authenticity of that commit, nothing else; no parent or grandparent, etc.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by lxgr on Friday October 02, 2026 @09:03AM (#49933097)
Sure, "just" completely change how git commit signatures work to avoid having to replace a compromised hash function...
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Friday October 02, 2026 @04:19PM (#49938121)
But that is a less disruptive change, because it's managed in headers; it's not part of the core of how objects are linked together.

You just have new header fields (or values for existing fields) which indicate that this is such and such a new style signature, and that's mostly it. Older git won't validate it or produce it. Newer git validates and produces old and new.

Importantly, older git installations will be able to read the commits, etc, just not validate the signatures.

This is not to avoid replacing the compromised hash function as such (taking away the choice from people making new git projects). We have that already.

But existing repos aren't based on that new function. Not everyone wants to switch their existing repos to to start using SHA-256; that means the repos don't work with older git.

The disruption is real.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by orf on Thursday October 01, 2026 @06:28PM (#49927804)
> The GPG signature is not signing the git hash, if that's what you mean.

It kind of is - it’s signing the hash of the tree object, which is the actual thing that you’d attack with a hash collision

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Thursday October 01, 2026 @06:35PM (#49927876)
I understand that if we sign a commit with the help of some arbitrarily strong hash, it doesn't protect the parent commit(s). The integrity of the SHA-1 hash references to the parent commits is not in question, but the authenticity of those commits themselves.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by orf on Thursday October 01, 2026 @06:50PM (#49927974)
No, not the abstract tree formed by a series of commits.

The actual git ‘tree’ object, which is the thing a commit actually points to, referenced by a hash in the commit. That is signed by the GPG signature.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by Borealid on Friday October 02, 2026 @03:51AM (#49930942)
Correct. The content of the git `tree` is partially controlled by the attacker because filenames in the repository are part of it. So if it's feasible to manufacture a generic hash collision it MAY (not MUST) be feasible to generate two colliding `tree` objects.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by tremon on Friday October 02, 2026 @05:45AM (#49931658)
The actual thing you'd attack with a hash collision is the blob object, not the tree object, right? The tree object has a rigid structure and git will throw a fit if you add non-functional data to modify its hash. Source code files have comments which make it much easier to manipulate the hash.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by orf on Friday October 02, 2026 @06:29AM (#49931920)
you're right, i worded that poorly. what i meant to imply was that a blob hash collision causes any tree referencing it to be malicious, which cascades down to many different commits/tags (potentially all of them, if the tree is untouched since repo creation).
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Friday October 02, 2026 @02:43PM (#49937051)
Maybe you could make a valid tree object with the same hash and different content; the details about which graph node at which level is used as a target do not seem that important.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by layer8 on Thursday October 01, 2026 @03:56PM (#49926316)
This is exactly right. A signature is only worth as much as the hash that it’s signing. And all the usual signature algorithms are signing a hash.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by saltcured on Friday October 02, 2026 @12:03PM (#49935074)
I tried to spelunk this thread and couldn't find the topic I want to see explored.

I don't really have the crypto chops to declare a fact here, but I have a speculation or intuition. In this day of supply chain worries, I think a proper signing algorithm should not be signing this tower of hashes, or not just this tower.

It should incorporate a canonical stream of all the actual commit content. It is the integrity of this content from the author's working copy that they can and should attest, not some derived byproduct of the storage scheme. Edit: Of course, I mean a secure hash of this stream, not a signature including a copy of the entire content!

My intuition is that the content-addressable store is used to reconstitute the commit content, but the verification should be over the original content, not the internal addressing of the store.

Wouldn't this make it harder to do these exploits? You would have to find alternate content that simultaneously produces collisions in the internal addressing hashes and for the overall canonical stream hash.

If you also carry size info alongside each hash, would this also make it much more difficult to produce useful collisions?

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by ramses0 on Thursday October 01, 2026 @09:30PM (#49928967)
Dude... please bow out gracefully...

The attack is I pre-author `Makefile => foo: echo "hello"; bar: echo "world"` along with `Makefile => foo: echo "hello"; bar: rm -rf / ; /* $ELDRITCH_SHA1_SPIRITS_GO_HERE */` that both hash to `ff1234...`

I then prepopulate the repo with `echo "hello"`, wait 6-9 months, then submit a commit for `echo "hello" ; echo "world"` and keep (in my back pocket) the alternate implementation that also includes $ELDRITCH_SPIRITS to force a collision and MY predetermined change in functionality.

I then have free choice as to whether I serve them "hello world" or "hello && rm -rf", and THAT's the plausible problem to avoid: the ability to "cloak" content anywhere within the repo if you have enough $ELDRITCH_SPIRITS and GPU's.

You have _really_ good points, but are woefully confused. The proper answer is (would have been) to include `tree ff12354...` along with `tree-sha256 abc123456789...` for another 20 years along with a `[git.hash_strictness]: default/lazy/strict`, and some oddball `git-rerere` type packfile extension which lets you map `sha1:ff1234... => sha256:abc123456789...` "transparently" rather than the horrific situation you're laying out (correctly!) that forks the ecosystem in to "longhash" and "shorthash" when most repos don't even care in the end.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by hedora on Thursday October 01, 2026 @11:21PM (#49929525)
Also, note that you can just sign "hello world" and "hello && rm -rf", then serve whichever you want. In the absence of a hash, then everyone has to trust you not to do that. With SHA-256 git, and a one-time audit of the code, they would need neither your public key nor to trust that the code didn't change.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Thursday October 01, 2026 @09:51PM (#49929078)
> woefully confused

Yes, I didn't understand that the GPG signing just operates on the top level object in the commit and trusts the SHA-1 hashes contained in it.

The signing process doesn't recursively traverse the bytes of the commit to pull them into GPG, like you would expect.

It's like, imagine you made a "bill of materials" of your project's files consisting of their names and CRC-32 checksums, and then signed this file, and called your project securely signed, LOL.

This aspect can be fixed without foisting new hashing scheme into the content tracker. In fact, it must be fixed; users on SHA-1-based repos deserve secure signing.

It's really sneaky that the SHA-1 business (not intended to be a security mechanism) was embroiled into the signing implementation; that GPG is demoted to the strength of SHA-1.

Was that just to save some cycles? It's certainly faster just to sign the commit object!

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by singpolyma3 on Thursday October 01, 2026 @10:35PM (#49929318)
signatures are basically always computed over hashes. The only problem here is that the hashes are not secure. And this is being fixed.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Thursday October 01, 2026 @10:58PM (#49929420)
No, but, the hashes are features of the content tracking system that hook it together. There is no reason that a signing scheme must rely on and trust those hashes!

We can round up the bits that make up a commit in a SHA-1-based repo, and sign those bits securely; this is a thing that is possible.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by dwohnitmok on Friday October 02, 2026 @01:14AM (#49930052)
> We can round up the bits that make up a commit in a SHA-1-based repo, and sign those bits securely; this is a thing that is possible.

Yes but as my other comment explains, this is not particularly useful in and of itself.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Friday October 02, 2026 @08:18AM (#49932661)
It represents an increment in security which doesn't require switching to a SHA-256 repo.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by ramses0 on Friday October 02, 2026 @09:40AM (#49933404)
Remember: bow out gracefully

you're arguing a position which indicates you don't know git's physical (textual) commmit structure.

Spend some quality time with:

    git cat-file -p HEAD
You'll get something like:

    tree ff1234...
    parent ccddef...

    fix(BUG-1245): my ai fixed it

Continue to `cat-file -p $TREE` and you'll get:

    file efef12... Makefile
    tree a1b2c3... src/
    file f0ea12... README.md
...and then it's turtles all the way down. It is (was!) safe to sign $HEAD (and only head!) because... it's turtles all the way down. Signing HEAD attaches IDENTITY (eg; [email protected]) to CONTENT (eg: src/@a1b2c3...) and TRANSITIVELY all the way down.

Your homework is to go run:

    time (
      git ls-files | xargs -n 1 sha256sum
    ) | sha256sum
...and then make a commit (nee: tag/note) containing that content as the commit message.

Your INSTINCT isn't wrong, your mechanics run counter to the practicalities of how git is designed to work, and the practicalities of the crucial defense that git-core is trying to divert: the ability to arbitrarily alter the signed(!!!) past, signed by third parties, with $ELDRITCH_SHA1 attacks.

You _still_ have to trust that GitHub.com or kernel.org won't get popped and start erroneously serving "signed but faulty" files and trees, but the urgency of moving to sha256 is about preventing faulty commits in the first place, which removes the requirement of "trust me bro!" relationship with the serving provider (or MITM).

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Friday October 02, 2026 @01:22PM (#49936076)
> you're arguing a position which indicates you don't know git's physical (textual) commmit structure.

That is false; hopefully everyone here understands that it's a graph linked by hash "pointers", such as SHA-1. I have not seen evidence otherwise.

> time (

Of course I understand that it's (possibly vastly) more expensive to digest the content than just a top-level node. So what? Maybe someone would pay that, if they had the option.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by Dylan16807 on Friday October 02, 2026 @03:52AM (#49930950)
> There is no reason that a signing scheme must rely on and trust those hashes!

Not "must", but it would be stupid to use two sets of hashes without a compelling reason.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Friday October 02, 2026 @08:18AM (#49932652)
Two hashes are already used now: GPG isn't using a SHA-1 digest, but it's signing something that is using SHA-1 digests to refer to other objects.

(Inside GPG, there are configurable choices. It's possible to be using SHA-512, so in a SHA-256 git repo, you can still be using two hashes.)

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by lxgr on Friday October 02, 2026 @08:59AM (#49933060)
You are again talking about a fictional alternate reality in which git commit signatures do something like GPG_Sign(GPG_Signature_Hash(git commit || all objects referenced by commit))), instead of ours where it's GPG_Sign(GPG_Signature_Hash(git commit))), and the git commit is in turn some metadata and a git hash of a bunch of objects.

In our reality, the git hash is load bearing. You can disagree with that design choice, but you can't pretend to live in that alternate reality and design your solutions for this reality according to that.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Friday October 02, 2026 @02:41PM (#49937024)
> You are again talking about a fictional alternate reality

> can't pretend to live in that alternate reality

Discussions about solutions that don't exist or requirements not implemented are everyday occurrences and necessary.

I mean, if you're talking with a contractor about how your bathroom should look, that is a "fictional alternate reality", but you're not pretending to be living in it now.

I don't understand the purpose of the above engagement style, but it doesn't look like a great fit for HackerNews.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by lxgr on Friday October 02, 2026 @06:32PM (#49939436)
There's a difference between talking about a hypothetical path forward and a hypothetical different past. The latter can be intellectually interesting but is rarely part of normal project planning.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Friday October 02, 2026 @08:07PM (#49940143)
[delayed]
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by Dylan16807 on Friday October 02, 2026 @01:39PM (#49936260)
As far as git is concerned, GPG is a black box and git feeds it normal git hashes, of which there is only one kind. This design makes sense.

For anything else, it depends on the exact scheme:

If git sent GPG the bits for the current commit specifically because it expects a better hash to be used, that would be silly to design on purpose (git should use a hash that meets all requirements). And it wouldn't protect history, which matters.

If git rounded up the bits of history, that would perform unacceptably badly.

If git used a better hash to secure history for signing purposes, and still had the normal hash elsewhere, that would be very silly to design on purpose because it should use the better hash for everything.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by fc417fc802 on Friday October 02, 2026 @07:03AM (#49932114)
But is "commit" in this context a full snapshot or a delta? Because what you describe will only work for the former.

Regardless, commit hashes should be a security mechanism IMO. And not just commits. I should be able to treat _any_ content addressing system as having secure addresses. If you can engineer collisions you need to patch your system.

(Note that the above does not necessarily imply support for unconditionally forcing a fork of the entire git ecosystem.)

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by lxgr on Friday October 02, 2026 @08:53AM (#49932983)
> There is no reason that a signing scheme must rely on and trust those hashes!

Yes, but git's signing scheme(s) do, as do many third-party ones, so what are you arguing for, exactly?

The non-necessity of a fix in an alternate reality in which nobody uses git as documented? One in which git launched with a big disclaimer of "never trust our cryptographically secure hash function to be cryptographically secure" in its documentation and CLI outputs?

Because one thing is certainly a big no-go in our reality: git walking back these explicit and implicit (Hyrum's law) contracts because fixing a load-bearing hash function is hard.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Friday October 02, 2026 @01:24PM (#49936109)
Improving a signing scheme in the same repository format is less disruptive. It may not hit all the checkboxes, but it seems worth doing.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by dwohnitmok on Friday October 02, 2026 @01:38AM (#49930153)
> The signing process doesn't recursively traverse the bytes of the commit to pull them into GPG, like you would expect.

No I wouldn't expect this. If by recursive you mean traversing the entirety of git history, that would be prohibitively expensive performance-wise (imagine rehashing the entire multi-gigabyte history of the Linux kernel every time to sign and verify a commit) and destroy git functionality such as shallow clones and blob-less clones.

If you by recursive you are only referring to the current working directory, as I lay out here https://news.ycombinator.com/item?id=49930048 it doesn't work. Indeed, without attestation of parent commits, a malicious attacker can actively frame any pre-existing vulnerability as someone else's handiwork by simply inserting a new commit that purports to be the parent of another commit that does not contain the vulnerability, which then makes the original commit look like the source of the vulnerability.

"I didn't introduce the vulnerability, he did! Look I can even prove it with my signed commit!"

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by dwohnitmok on Friday October 02, 2026 @04:46AM (#49931276)
>"I didn't introduce the vulnerability, he did! Look I can even prove it with my signed commit!"

I misspoke. It's worse. "I didn't introduce the vulnerability, he did! Look I can even prove it with his signed commit!"

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by kazinator on Friday October 02, 2026 @11:26AM (#49934584)
Well, no, you cannot because under this system, you can't prove anything about some other commit; the history is not trusted.

You can produce two commits that have the same SHA-1 and hash them. One has the vulnerability and one doesn't.

Then someone else bases a new commit on the one with the vulnerability, which has yours as the parent. You then swap in the one without the vulnerability and now it looks like the child is introducing that change.

Their only defenses are (1) plausible deniability (we don't trust parent hashes) and (2) still having the original commit they based theirs on to show that a swizzle took place and that the real original already had the vuln.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by lxgr on Friday October 02, 2026 @09:11AM (#49933179)
> It's like, imagine you made a "bill of materials" of your project's files consisting of their names and CRC-32 checksums, and then signed this file, and called your project securely signed, LOL.

If you are arguing that CRC-32 is a cryptographically secure hash function you might.

SHA-1 is (or rather, used to be) one, so you actually can. This is literally how git works.

> It's really sneaky that the SHA-1 business (not intended to be a security mechanism) was embroiled into the signing implementation; that GPG is demoted to the strength of SHA-1.

What's sneaky about it? It's a completely reasonable design decision, making git orders of magnitude more efficient than the counterfactual you're arguing for.

> Was that just to save some cycles? It's certainly faster just to sign the commit object!

Sure, "just" read potentially gigabytes of data, potentially over the network, and send them through your cryptographic hash function as opposed to just the objects you're touching in your commit. Absolutely the same effort.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by hinkley on Friday October 02, 2026 @04:50AM (#49931300)
You do understand that most code signing is just PKI over the top of SHA hashes, right?

The only substantial difference is that the author vouched for these particular snapshots of code, in a way where nobody else can intercept the communication and substitute a completely different hash than one the author previously signed.

In fact if you can find a SHA collision, you can peal the signature off of the legitimate payload and slap it on the colliding one.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by SAI_Peregrinus on Thursday October 01, 2026 @05:58PM (#49927551)
> Git hashes are not supposed to be a security mechanism.

Commit signing indicates otherwise.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by hinkley on Friday October 02, 2026 @04:54AM (#49931328)
Linus said it was a security feature in that big presentation he did about Git.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by someonebaggy on Friday October 02, 2026 @12:11AM (#49929760)
You could pull a malicious colliding PR and reject it. Then you pull the other half of the collision without realising it is, and it's something good and you merge it. But your CI server already saw the malicious one and thinks it's the same, so builds the malicious code
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by pseudohadamard on Friday October 02, 2026 @01:25AM (#49930100)
That's what a lot of the responses are missing, which is why the response to them in turn is both no and yes. There's no published threat model that I know of for the properties that the hashes are supposed to be providing for git, which means anyone can make up any required property they like and then confidently state that SHA-1 provides or does not provide it, see this discussion for examples. The result is, to use another Linus quote as the OP has already quoted him in the writeup, "people wanking around with their opinions".

We use SHA-1 in our storage mechanism, which predates git. There is a (quite long) written threat model. Someone being able to generate collisions with an enormous amount of effort under just the right conditions is not a threat under that model.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by funcDropShadow on Friday October 02, 2026 @04:11AM (#49931060)
No, that argument misses the point. Cryptographic hashes enable you to trust, that I only have to review the changes since the last trusted commit. That is more important for the developers and maintainers of the software and less for the users.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by hinkley on Friday October 02, 2026 @04:54AM (#49931322)
In order to work for the users, a thing first has to work for its makers.

There are a lot of tools where the lines blur between “for the users” and “for the development team” because the users benefit from some things that make the developers’ lives easier.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by lxgr on Friday October 02, 2026 @04:31AM (#49931193)
> Git hashes are not supposed to be a security mechanism.

They absolutely are, both when you're using signed commits (i.e. GPG, SSH, and S/MIME) or just identifying a given commit/repository state by hash via a secure channel and then serving object data over untrusted transports.

It's entirely possible that you don't use either, but that's certainly not true for everybody.

Calling anyone using either to be "doing it wrong" is borderline gaslighting: Git used to have these security guarantees, and just because they're now broken doesn't mean they were never there in the first place, or that it was stupid to rely on them.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by deknos on Friday October 02, 2026 @07:24AM (#49932267)
> Git hashes are not supposed to be a security mechanism.

That you are wrong. Many people and orgs rely on this.

Does not matter if you think it's stupid, for them it is. live with it.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by hylaride on Friday October 02, 2026 @09:49AM (#49933500)
Exactly! The recommended way to use GitHub actions is to use their deploy hash as the version to prevent hijackings. It was never the intention (nor would this have been envisioned when git was created), but security needs to be applied to the way tech is used.
Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by knorker on Friday October 02, 2026 @09:58AM (#49933606)
Supposed to be or not, it is.

Package managers even use it. E.g. you can have a cargo dependency pointing to GitHub at a specific commit. It's definitely intended to provide end to end security without depending on GitHub being secure.

Also git submodules.

Re:Git 3.0's upcoming SHA-256 default will be a costly mistake by knorker on Friday October 02, 2026 @02:34PM (#49936949)
And I should add: not just github compromise, but supply chain / original author replacing the contents.

Absolutely the SHA-1 is treated as "authenticating". Cargo.lock (for regular crates.io dependencies) are confirmed using SHA-256.