Skip to content
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

Backport fixes for CVE 2018-11235 #4659

Merged
merged 22 commits into from
May 29, 2018
Merged

Conversation

ethomson
Copy link
Member

@ethomson ethomson commented May 29, 2018

Backporting @carlosmn's fixes so that we can do an 0.27.1 security release. Thanks @carlosmn and @pks-t for the work.

carlosmn and others added 21 commits May 29, 2018 13:44
We should pretend such submdules do not exist as it can lead to RCE.
If the we decide that the "name" of the submodule (i.e. its path inside
`.git/modules/`) is trying to escape that directory or otherwise trick us, we
ignore the configuration for that submodule.

This leaves us with a half-configured submodule when looking it up by path, but
it's the same result as if the configuration really were missing.

The name check is potentially more strict than it needs to be, but it lets us
re-use the check we're doing for the checkout. The function that encapsulates
this logic is ready to be exported but we don't want to do that in a security
release so it remains internal for now.
Otherwise we would also admit `..\..\foo\bar` as a valid path and fail to
protect Windows users.

Ideally we would check for both separators without the need for the copied
string, but this'll get us over the RCE.
This lets us check for other kinds of reserved files.
It checks against the 8.3 shortname variants, including the one which includes
the checksum as part of its name.
Given a path component it knows what to pass to the filesystem-specific
functions so we're protected even from trees which try to use the 8.3 naming
rules to get around us matching on the filename exactly.

The logic and test strings come from the equivalent git change.
These can't go into the public API yet as we don't want to introduce API or ABI
changes in a security release.
These will be used by the checkout code to detect them for the particular
filesystem they're on.
We want to reject these as they cause compatibility issues and can lead to git
writing to files outside of the repository.
We may take in names from the middle of a string so we want the caller to let us
know how long the path component is that we should be checking.
This is so we have it available for the path validity checking. In a later
commit we will start rejecting `.gitmodules` files as symlinks.
Any part of the library which asks the question can pass in the mode to have it
checked against `.gitmodules` being a symlink.

This is particularly relevant for adding entries to the index from the worktree
and for checking out files.
When dealing with `core.proectNTFS` and `core.protectHFS` we do check
against `.gitmodules` but we still have a failing test as the non-filesystem
codepath does not check for it.
We still compare case-insensitively to protect more thoroughly as we don't know
what specifics we'll see on the system and it's the behaviour from git.
We might modify caches due to us trying to load the configuration to figure out
what kinds of filesystem protections we should have.
@ethomson
Copy link
Member Author

Thanks @pks-t for doing the backport.

@ethomson ethomson changed the title Backport fixes for CVE 2018-11234 and CVE 2018-11235 Backport fixes for CVE 2018-11235 May 29, 2018
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.

None yet

3 participants