Skip to content
RCE Write-up Intermediate

Git v2.14.1, v2.13.5, and others – security fix for CVE-2017-1000117

A crafted ssh:// URL could cause Git to pass a hostname beginning with a dash to the ssh command, which would treat it as an option and potentially execute arbitrary programs. An attacker could place such a URL in a .gitmodules file so that a victim running git clone --recurse-submodules triggers the issue.

mail-archive.com

Published on mail-archive.com

Junio C Hamano Thu, 10 Aug 2017 11:01:11 -0700

The author, on mail-archive.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the ssh:// URL parser allowed hostnames beginning with a dash, which were then passed to the ssh command without validation, enabling option injection.

Impact

An attacker could execute any program on the victim's machine if the victim clones a malicious project with submodules.

What the attacker needed

Victim runs git clone --recurse-submodules; malicious project with crafted .gitmodules

The fix

The issue was fixed by forbidding hostnames, ports, and repository names that begin with a dash.

How it was found

  1. Create a malicious project with a .gitmodules file containing a crafted ssh:// URL.
  2. Trick a victim into running git clone --recurse-submodules on that project.
  3. The crafted URL causes Git to invoke ssh with a hostname starting with a dash, leading to execution of an arbitrary program.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Git is a tool for managing code. When you clone a project that uses submodules, Git may run ssh to fetch other repositories. If a URL starts with a dash, ssh can mistake it for a command-line option and run a program instead of connecting. This lets an attacker run code on your computer if you clone a malicious project.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.