Skip to content

Fixes for CVE 2018-11235#4660

Merged
carlosmn merged 20 commits intomasterfrom
cmn/submodule-traversal
May 29, 2018
Merged

Fixes for CVE 2018-11235#4660
carlosmn merged 20 commits intomasterfrom
cmn/submodule-traversal

Conversation

@carlosmn
Copy link
Copy Markdown
Member

No description provided.

carlosmn and others added 20 commits April 30, 2018 13:03
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.
@carlosmn carlosmn force-pushed the cmn/submodule-traversal branch from ea38111 to 491722e Compare May 29, 2018 18:03
@carlosmn carlosmn changed the title Fixes for CVE 2018-11234 and CVE 2018-11235 Fixes for CVE 2018-11235 May 29, 2018
@carlosmn carlosmn merged commit 7f6c1ce into master May 29, 2018
@carlosmn carlosmn deleted the cmn/submodule-traversal branch May 29, 2018 19:04
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.

1 participant