Git vulnerability with submodules - Azure DevOps Blog (original) (raw)

Edward Thomson

Principal Program Manager

The Git community has disclosed a serious security vulnerability in Git that can lead to arbitrary code execution. This has been assigned CVE 2017-1000117.

The Visual Studio Team Services (VSTS) team takes security issues very seriously. We encourage all users to update their Git clients as soon as possible to address this issue.

If you use other Git clients, please contact the vendor to understand whether or not you need to upgrade.

The problem

When fetching from remote repositories, Git URL parsing can be confused by command line options embedded inside the URL. This can be exploited to pass specific command-line options to the ssh executable, and those options may specify a command to execute using its “ProxyCommand” functionality.

For example, if you run:

git clone ssh://-oProxyCommand=notepad.exe/ /tmp/git_vulnerability

Then Notepad will open. (Substitute notepad.exe with an application of your choice if you’re not a Windows user.)

Of course, since this URL looks quite funny, it’s unlikely that somebody would be convinced to clone that themselves. The larger risk, instead, comes when this URL is embedded as a submodule in a rather innocent-looking repository.

An attacker can easily change the URL of a submodule in a repository by editing the .gitmodules file. If it were changed to point to the exploit URL above:

[submodule "pwned"] path = pwned url = ssh://-oProxyCommand=notepad.exe/

Then doing a recursive clone on this innocent-looking repository would cause arbitrary code execution.

Solution

The solution to this problem is quite simple and effective: submodule URLs are now examined more closely by Git clients. If the SSH hostname looks like a command-line option (i.e., if it begins with a “-“) then the submodule is blocked. The updated Git clients referenced above contain this fix and should be installed as soon as possible.

Author

Edward Thomson

Principal Program Manager

Edward Thomson is a Program Manager for Azure DevOps, where he ensures that customers are successful with Git, CI/CD and DevOps concepts. Before becoming a Program Manager, he was a Software Engineer at GitHub and Microsoft working on Git tools.