FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Introduce (optional) SHA1 collision attack detection by ethomson · Pull Request #4136 · libgit2/libgit2 · GitHub

Repository navigation

Introduce (optional) SHA1 collision attack detection - #4136

Merged
carlosmn merged 4 commits into
masterfrom
ethomson/sha1dc
Mar 3, 2017
Merged

carlosmn merged 4 commits into
masterfrom
ethomson/sha1dc

Conversation

Copy link
Copy Markdown
Member

Include SHA1 collision attack detection from https://github.com/cr-marcstevens/sha1collisiondetection when configured with -DUSE_SHA1DC=1.

This is the same implementation being proposed for git core; see https://public-inbox.org/git/20170223230536.tdmtsn46e4lnrimx@sigill.intra.peff.net/

pks-t commented Feb 24, 2017

Copy link
Copy Markdown
Member

The imported code is not ISO C90 compatible, there's a declaration after code in src/hash/sha1dc/sha1.c:55.

Otherwise this looks fine, I guess (even though I obviously didn't skim through the SHA1DC implementation).

ethomson commented Feb 24, 2017 •
edited
Loading

Copy link
Copy Markdown
Member Author

Dang, thanks @pks-t , I missed that. (Seriously, you would have thought somebody at Microsoft would have gotten that one right. 😛 )

Copy link
Copy Markdown
Member Author

AppVeyor's mingw builds are busted. Sigh. 👀

Copy link
Copy Markdown
Member Author

All fixed up!

Comment thread tests/core/sha1.c Outdated
git_oid __expected; \
git_oid_fromstr(&__expected, (idstr)); \
cl_assert_equal_oid(&__expected, (oid)); \
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This #define is currently unused?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yep, good 👁 . I've dropped this.

Comment thread CMakeLists.txt
ELSEIF (WIN32 AND NOT MINGW AND NOT SHA1_TYPE STREQUAL "builtin")
ADD_DEFINITIONS(-DGIT_SHA1_WIN32)
FILE(GLOB SRC_SHA1 src/hash/hash_win32.c)
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

By the way, is it correct that OS X does not check for SHA1_TYPE=="builtin"? Sounds as if it wasn't possible for OS X systems to build with our generic hashing algorithm.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Good question... digging in a bit deeper, it looks like one can't actually set SHA1_TYPE. So I'm removing these tests for builtin entirely.

carlosmn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Just some thoughts, feel free to tell me I'm petty.

Comment thread CMakeLists.txt Outdated
OPTION( ENABLE_TRACE "Enables tracing support" OFF )
OPTION( LIBGIT2_FILENAME "Name of the produced binary" OFF )

OPTION( USE_SHA1DC "Use sha1 with collision detection" OFF )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

s/sha1/SHA-1/ ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Done

Comment thread tests/core/sha1.c

#ifdef GIT_SHA1_COLLISIONDETECT
GIT_UNUSED(expected);
cl_git_fail(sha1_file(&oid, FIXTURE_DIR "/shattered-1.pdf"));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Do we want to have a specific error code for this as well, so we can do cl_git_fail_with(GIT_ESHA1ATTACK, ...)? I'm not sure if this adds that much value, just a thought.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

So... my thinking here is that this is only useful if it's something that you want to act on. I think that if you were a hosting provider that you would actually not want to bother logging these, because once this becomes reasonably cheap and you can create two git objects that have colliding hashes -- or when a research org decides to extend their corpus of files with colliding hashes to git objects and not just PDFs -- then people are going to go crazy uploading them to poke at you. And if you're a client, then this isn't useful knowledge to have at all.

But it's quite easy to implement, so I'm happy to add it if you're passionate about it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I just figured a client might want to throw a particular prompt, but it's so far beyond what we have control over that it's not really worth it.

carlosmn merged commit 3348570 into master Mar 3, 2017

ethomson commented Mar 3, 2017

Copy link
Copy Markdown
Member Author

It looks like the git authors and the authors of this SHA-1 collision detection library are interested in optimizing it; we'll revisit this if/when they settle on something more efficient.

gnawhleinad pushed a commit that referenced this pull request Mar 28, 2017
Introduce (optional) SHA1 collision attack detection
gnawhleinad pushed a commit that referenced this pull request Mar 29, 2017
Introduce (optional) SHA1 collision attack detection
gnawhleinad pushed a commit that referenced this pull request Mar 29, 2017
Introduce (optional) SHA1 collision attack detection
gnawhleinad pushed a commit that referenced this pull request Mar 29, 2017
Introduce (optional) SHA1 collision attack detection
ethomson deleted the ethomson/sha1dc branch January 9, 2019 10:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL