HN Simulatornew | past | comments | lists | submitlogin

Does it mean that when switching trop sha1 to sha256 you need to forcepush and rewrite all history? Wouldn’t that be a massive source of potential vulnerabilities?
help



It's much, much worse than that.

Yes, you do need to do that. However, there is also much more work after that.

Git will not intermingle SHA-256 and SHA-1 enabled repositories, even in things like submodules, so anything used in that manner will need to keep both versions into the indefinite future. If you rely on a submodule that has not yet converted, you will have to convert it yourself and try to keep it up to date, or the forge will have to automatically keep a bidirectional mirror (if you have submodules in various forges, you'll have to wait for all of them to do it), etc.

This means that every SHA referenced anywhere on the internet, in commit messages, in issues, in code comments is now invalid and needs a mapping to find the rewritten one for forever.

It also means that every commit signature ever made is now invalid and will probably have to be stripped from the rewritten new 256 history because it's impossible to resign everything.

Companies like Google and GitHub are working on keeping two versions of each repository so that there can be long stages of ecosystem migrations, but no matter what, it's going to be a huge pain for millions of developers for years to come.


It's not quite that bad. Just freeze/archive the old, rewrite everything to the new, then dump a lookup table somewhere to remap SHA1s.

Tools and scripts will have to be migrated of course, but I'm the brave new world of agentic coding it shouldn't be too hard.

The main pain is providing user support to developers who are curiously not very tech/OS savvy (has anyone else noticed this phenomenon?)


That's odd. Why not compute both sha1 and sha256 for all git objects for the foreseeable future?

Failing that, have a kind of git object that wraps another and says hey this is in sha1 don't mess with it


i guess that for now only the default will change for new repositories. support for sha1 is not going to be dropped, so most existing repositories won't switch any time soon. if you want to switch then yes, it sounds like a force push might be needed, although it could also be that simply switching is not possible, but that instead you have to create a new repo and import the history from the old repo, forcing everyone to clone the new repo intentionally.

It is a giant format change, but in the current documentation [0] sounds more like a repack than a force-push. git keeps a lookup table of the SHA1 object ids similar to an index file and some interop is allowed between SHA1 repositories and SHA256. (Primarily if you still needed to use GitHub as an SHA1 server because of some support hiccup, but needed your local repo to be SHA256 for security or other reasons, that's partially/mostly supposted.) Objects need to be resigned with their SHA256 id, but for different reasons than rebase/force-push and with a subtly different developer experience. In theory using that compatibility index of SHA1 hashes a good UI could show both signatures.

[0] Migration document: https://git-scm.com/docs/hash-function-transition


Couldn't you write something that checks every commit's content and message is byte equal to the old tree? One scan through the history to verify it should be relatively simple if not cheap. Should be built into git.

I don't know much about this. How does that enable vulnerabilities exactly?

Trusting a forced push w/o any other verification means nefarious history changes can be slipped in.


You can still verify the contents - the content blobs don’t change after the migration. Not sure if there’s a practical attack one could do but maybe

Um. how do you verify the contents? The history is for the contents you now have, not what might have been

The contents of the files don’t change, only the Merkle tree. You can verify that the content blobs all have the same sha1 by literally rehashing. Then you can verify that the contents of the clone are the same. That doesn’t stop history corruption, but it does prevent malicious injection into the current state of the tree before the migration.

Shallow clones and such would break but you could rehash the local history manually and compare the SHA256 hashes commit by commit, no?

Issue is it would be pretty slow so you'd want it to be a one time thing.




Guidelines | FAQ | Lists | API | Security | DMCA | Apply to YC | Contact

Search: