Server and Client RCE in Git version 2.7.1 and below
Git versions before 2.7.1 contain a heap buffer overflow in path_name() and tree-diff.c's path_appendnew() caused by integer overflow when summing path component lengths. An attacker could trigger it by pushing or cloning a repository with a large filename or many nested trees, potentially leading to remote code execution.
seclists.org
Published on seclists.org
Hello, original report describing the overflow is here http://pastebin.com/UX2P2jjg
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 integer overflow when summing path component lengths in path_name() and path_appendnew(), causing a too-small allocation followed by a write beyond its bounds.
Impact
An attacker could potentially achieve remote code execution on both server and client sides, though the text notes that on 64-bit systems the overflow may be impractical to trigger and that malloc failure might occur first on 32-bit systems.
What the attacker needed
Ability to push or clone a repository; Git version before 2.7.1
The fix
It was fixed in Git 2.7.1 by removing path_name() and adding size_t/overflow checks in tree-diff.c.
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 tracking changes in code. A buffer overflow is when a program writes more data into a memory area than it was sized for, which can crash it or let an attacker run their own code. Here, very long or deeply nested file paths in a repository could cause Git to miscalculate how much memory to reserve, leading to such an overflow.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.