Skip to content

smart protocol: PACK packets are illegal while downloading refs#4694

Merged
ethomson merged 1 commit into
libgit2:masterfrom
nelhage:smart-no-pack
Jun 26, 2018
Merged

smart protocol: PACK packets are illegal while downloading refs#4694
ethomson merged 1 commit into
libgit2:masterfrom
nelhage:smart-no-pack

Conversation

@nelhage
Copy link
Copy Markdown
Contributor

@nelhage nelhage commented Jun 24, 2018

I'm not sure this is the best fix, but without this fix we can cause a git2 client to spin forever allocating memory by responding with the four characters "PACK" to a smart protocol client:

[nelhage@penguin:~/code/libgit2]$ echo PACK | nc -l -p 9999 -q0 >/dev/null &                                                                      
[1] 22480
[nelhage@penguin:~/code/libgit2]$ build/examples/cgit2 --git-dir .git ls-remote git://localhost:9999/       
# loops until it consumes all available memory and crashes

This bug was found by an oss-fuzz integration I'm working on.

@ethomson ethomson merged commit 3eec73a into libgit2:master Jun 26, 2018
@ethomson
Copy link
Copy Markdown
Member

Thanks for this - a minor complaint: we start error message in lower-case, so that library consumers can prepend their own error message. For example, we do:

giterr_set(GITERR_NET, "unexpected widget in the widget factory");

So that users can report:

Could not check out branch: unexpected widget in the widget factory

So - rather than bouncing this back for you to fix - I took the liberty of changing your error message. I manually merged this. Thanks for fuzzing!

@nelhage nelhage deleted the smart-no-pack branch July 10, 2018 03:10
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.

2 participants