Bug 1317981 (CVE-2016-2315, CVE-2016-2324) - CVE-2016-2315 CVE-2016-2324 git: path_name() integer truncation and overflow leading to buffer overflow
Summary: CVE-2016-2315 CVE-2016-2324 git: path_name() integer truncation and overflow ...
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2016-2315, CVE-2016-2324
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 1317982 1317983 1318220 1318252 1318253 1318254 1318255 1318256 1318257 1320555 1327084 1329591
Blocks: 1317984
TreeView+ depends on / blocked
 
Reported: 2016-03-15 16:49 UTC by Andrej Nemec
Modified: 2021-02-17 04:10 UTC (History)
33 users (show)

Fixed In Version: git 2.4.11, git 2.5.5, git 2.6.6, git 2.7.4
Doc Type: Bug Fix
Doc Text:
An integer truncation flaw and an integer overflow flaw, both leading to a heap-based buffer overflow, were found in the way Git processed certain path information. A remote attacker could create a specially crafted Git repository that would cause a Git client or server to crash or, possibly, execute arbitrary code.
Clone Of:
Environment:
Last Closed: 2016-03-30 14:27:50 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:0496 0 normal SHIPPED_LIVE Important: git security update 2016-03-23 17:34:39 UTC
Red Hat Product Errata RHSA-2016:0497 0 normal SHIPPED_LIVE Important: git19-git security update 2016-03-23 17:06:59 UTC

Description Andrej Nemec 2016-03-15 16:49:33 UTC
There is a buffer overflow vulnerability possibly leading to remote code execution in git. It can happen while pushing or cloning a repository with a large filename or a large number of nested trees.

References:

http://seclists.org/oss-sec/2016/q1/645

Parts of the original report:
http://pastebin.com/UX2P2jjg

CVE assignement notes:
http://seclists.org/oss-sec/2016/q1/653

Comment 2 Andrej Nemec 2016-03-15 16:50:19 UTC
Created git tracking bugs for this issue:

Affects: epel-5 [bug 1317982]

Comment 4 Christian Stadelmann 2016-03-16 09:30:31 UTC
Isn't Fedora 23 and Fedora 22 also affected? They both have git versions below 2.7.1.

Comment 5 Andrej Nemec 2016-03-16 10:02:17 UTC
(In reply to Christian Stadelmann from comment #4)
> Isn't Fedora 23 and Fedora 22 also affected? They both have git versions
> below 2.7.1.

Hi, you might be right, I will change it to affected and let the Fedora guys look at this. Thanks for the heads up.

My mistake might have originated by looking at this http://koji.fedoraproject.org/koji/packageinfo?packageID=1864

Comment 6 Andrej Nemec 2016-03-16 10:05:36 UTC
Created git tracking bugs for this issue:

Affects: fedora-all [bug 1318220]

Comment 15 Stefan Cornelius 2016-03-16 15:29:56 UTC
Statement:

Red Hat Product Security has rated these issues as having Important security impact. For additional information, refer to the Red Hat Knowledgebase article: https://access.redhat.com/articles/2201201

Comment 21 Agostino Sarubbo 2016-03-17 20:22:40 UTC
I'd suggest to change the "Fixed in version" field because it is not fixed in 2.7.1.
Actually the fix does not reside in any upstream release.
http://www.openwall.com/lists/oss-security/2016/03/16/9

Comment 22 David Woodhouse 2016-03-17 23:07:16 UTC
It does now (in v2.4.11, v2.5.5, v2.6.6 and v2.7.4):
http://marc.info/?l=git&m=145824889421350

Comment 29 Fedora Update System 2016-03-21 01:50:15 UTC
git-2.5.5-1.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Comment 30 Stefan Cornelius 2016-03-21 11:44:11 UTC
Both CVE-2016-2315 and CVE-2016-2324 affect the same 
function, "path_name" in revision.c:

>     20 char *path_name(const struct name_path *path, const char *name)
>     21 {
>     22 	const struct name_path *p;
>     23 	char *n, *m;
>     24 	int nlen = strlen(name);
>     25 	int len = nlen + 1;
>     26 
>     27 	for (p = path; p; p = p->up) {
>     28 		if (p->elem_len)
>     29 			len += p->elem_len + 1;
>     30 	}
>     31 	n = xmalloc(len);
>     32 	m = n + len - (nlen + 1);
>     33 	strcpy(m, name);
>     34 	for (p = path; p; p = p->up) {
>     35 		if (p->elem_len) {
>     36 			m -= p->elem_len + 1;
>     37 			memcpy(m, p->elem, p->elem_len);
>     38 			m[p->elem_len] = '/';
>     39 		}
>     40 	}
>     41 	return n;
>     42 }

CVE-2016-2315 has been assigned to the fact that the 
"int" datatype is used for the "nlen" length/size value (line 
24). The problem is that "int" is a signed datatype and 
in case of an integer overflow the value could wrap 
around into a negative value. Additionally, on 64bit this 
could lead to an unexpected integer truncation, as "int" 
may be smaller than, for example, "size_t".

The same applies to the "len" size value (line 25).

CVE-2016-2324 has been assigned to the integer overflow 
in the loop in lines 27 to 30. If path elements of 
sufficient length are added to "len", len could overflow 
and wrap around into a negative value.



It's possible to attack both client and server setups by 
creating a specially crafted packfile (an internal Git 
data format used to efficiently exchange repository 
information) and then providing said packfile to a
vulnerable Git setup.

In order to launch an attack against servers, the 
attacker needs to be able to push data to one of the
server's repositories, which generally requires
successful authentication.

In order to attack a client, an attacker would have to 
trick an unsuspecting Git user into cloning from a 
malicious Git repository.

When exploited, the issues can result in a memory 
corruption, which most likely crashes the Git 
application. However, it can't be ruled out that a 
successful exploitation attempt may result in the 
execution of arbitrary code.

Comment 31 errata-xmlrpc 2016-03-23 13:07:36 UTC
This issue has been addressed in the following products:

  Red Hat Software Collections for Red Hat Enterprise Linux 6.7 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 6
  Red Hat Software Collections for Red Hat Enterprise Linux 6.6 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 7.1 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 7.2 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 7

Via RHSA-2016:0497 https://rhn.redhat.com/errata/RHSA-2016-0497.html

Comment 32 errata-xmlrpc 2016-03-23 13:37:20 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 6
  Red Hat Enterprise Linux 7

Via RHSA-2016:0496 https://rhn.redhat.com/errata/RHSA-2016-0496.html

Comment 33 Fedora Update System 2016-03-30 21:20:35 UTC
git-2.4.11-1.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.

Comment 34 Fedora Update System 2016-05-23 22:16:45 UTC
git-1.8.2.3-1.el5 has been pushed to the Fedora EPEL 5 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.