-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: refuse creating new DAGs with insecure hash functions (SHA1) #8895
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
A more specific flag would make it more obvious that a less secure hash function is being used, like --allow-insecure-hash-function
or something like that. Also can you add a sharness test for this? Should be really easy.
Thanks for the feedback. I fixed suggested the edits changing the flag name to |
Your patch seems to only work for SHA1: $ ./ipfs add --hash=md5 --allow-insecure-hash-function <(echo test)
Error: potentially insecure hash functions not allowed (it might be significantly harder to support all unsecure functions, don't do it if you can't, sha1 is a good start 🙂) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is definitely a feature we want to merge, however a few things needs some tweaking first. 🙂
test/sharness/t0047-add-forcehash.sh
Outdated
HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" && | ||
echo "added $HASH hello.txt" >expected && | ||
test_cmp expected actual | ||
' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add a test that tries to add a file with an unsecure function and check that it fails.
Co-authored-by: Jorropo <jorropo.pgm@gmail.com>
…/go-ipfs into command/add/hashforcing
Fixed the syntax changes @Jorropo , also added failure tests specifically for SHA1. I'm aware that the Patch only works for SHA1 at this time, I can change the wording of the error if you think that would be better. My initial thought that generalizing the error statement will simplify future extensions. EDIT: I've been racking my brain on why the CI tests failed, I only added a single 'fail' test to my sharness. It works locally, based my tests directly off existing tests. Can't figure out what is now failing, as I have changed nothing / how a single test will cause http_client tests to fail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Marcin Rataj <lidel@lidel.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to ask for more but this:
ipfs add --hash=md5 --allow-insecure-hash randomFileHere
Doesn't work.
I know this is a more complicated task, but I would like to avoid yet an other half working feature.
I don't know what other maintainers think of this.
We already have that, it is https://github.com/ipfs/go-verifcid.
|
Seems doable, see: #8703 (comment)
I don't see a particularly good reason to bother with doing go-verifcid plumbing everywhere to allow sets of insecure hash functions. Note: you likely wouldn't want it to be all or nothing... allowing SHA-1 doesn't necessarily mean allowing a 1 bit SHA-2 hash or MD5. Allowing the system to support more insecure hash functions seems like a bad idea for a widely deployed consumer binary, especially given that most other users of that binary won't be able to retrieve the data anyhow. Nothing at the library or protocol level stops you from using broken hash functions like MD4, but I don't see a reason why go-ipfs should support using it. |
I'm saying this is what we currently more less have.
|
This seems unlikely to work. For example
Ok fair enough there are a few library pieces where you'd have to mock out the interfaces or do a fork to remove the checks. IIRC those structs aren't explicitly used rather than their interfaces so not too bad to deal with. However, if there's actual demand for it it's probably fine to add some configurability. |
Ok fair enough too. We can put that value in the context (create a |
2022-06-16 conversation: @Jorropo will write up the next steps that we'd like to take here since we don't want to introduce something special that is only relevant for sha1. |
Sorry but we are not intrested in this fix, But mainly. The danger is in We will follow the same route as git, using the sha1 fix to make the function "safe" again. (the only reason sha1 is still there is for git anyway so using the same fix as it make sense). The context for this is here: #8703 (comment) |
Closing #8703, added an optional forcing flag for
ipfs add
to discourage use of broken hashes like SHA-1 while still allowing it, given you pass in an optional forcing flag. Tested this manually due to the small scope of the changes.