Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Introduce (optional) SHA1 collision attack detection#4136

Merged
carlosmn merged 4 commits intomasterlibgit2/libgit2:masterfrom
ethomson/sha1dclibgit2/libgit2:ethomson/sha1dcCopy head branch name to clipboard
Mar 3, 2017
Merged

Introduce (optional) SHA1 collision attack detection#4136
carlosmn merged 4 commits intomasterlibgit2/libgit2:masterfrom
ethomson/sha1dclibgit2/libgit2:ethomson/sha1dcCopy head branch name to clipboard

Conversation

@ethomson
Copy link
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
Copy link
Member

pks-t commented Feb 24, 2017

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
Copy link
Member Author

ethomson commented Feb 24, 2017

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

@ethomson
Copy link
Member Author

AppVeyor's mingw builds are busted. Sigh. 👀

@ethomson
Copy link
Member Author

All fixed up!

git_oid __expected; \
git_oid_fromstr(&__expected, (idstr)); \
cl_assert_equal_oid(&__expected, (oid)); \
}
Copy link
Member

Choose a reason for hiding this comment

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

This #define is currently unused?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, good 👁 . I've dropped this.

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
Member

Choose a reason for hiding this comment

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

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
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Member

@carlosmn carlosmn left a comment

Choose a reason for hiding this comment

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

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

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
Member

Choose a reason for hiding this comment

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

s/sha1/SHA-1/ ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done


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

Choose a reason for hiding this comment

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

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
Member Author

Choose a reason for hiding this comment

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

🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

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
Member

Choose a reason for hiding this comment

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

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.

Edward Thomson added 4 commits March 3, 2017 10:50
@carlosmn carlosmn merged commit 3348570 into master Mar 3, 2017
@ethomson
Copy link
Member Author

ethomson commented Mar 3, 2017

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 ethomson deleted the ethomson/sha1dc branch January 9, 2019 10:18
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.