rpms/git/EL-4 git-1.5.4.7-daemon-extra-args.patch, NONE, 1.1 git.spec, 1.33, 1.34

Todd M. Zullinger tmz at fedoraproject.org
Fri Jun 19 13:35:38 UTC 2009


Author: tmz

Update of /cvs/pkgs/rpms/git/EL-4
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv502

Modified Files:
	git.spec 
Added Files:
	git-1.5.4.7-daemon-extra-args.patch 
Log Message:
Fix git-daemon hang on invalid input (CVE-2009-2108, bug 505761)


git-1.5.4.7-daemon-extra-args.patch:

--- NEW FILE git-1.5.4.7-daemon-extra-args.patch ---
>From 96c61f0fa25770a4b6f92243ee2b3ee2769f7f00 Mon Sep 17 00:00:00 2001
From: Shawn O. Pearce <spearce at spearce.org>
Date: Thu, 4 Jun 2009 18:33:32 -0700
Subject: [PATCH] daemon: Strictly parse the "extra arg" part of the command

This is a backport of upstream commit 73bb33a.

Since 1.4.4.5 (49ba83fb67 "Add virtualization support to git-daemon")
git daemon enters an infinite loop and never terminates if a client
hides any extra arguments in the initial request line which is not
exactly "\0host=blah\0".

Since that change, a client must never insert additional extra
arguments, or attempt to use any argument other than "host=", as
any daemon will get stuck parsing the request line and will never
complete the request.

Since the client can't tell if the daemon is patched or not, it
is not possible to know if additional extra args might actually be
able to be safely requested.

If we ever need to extend the git daemon protocol to support a new
feature, we may have to do something like this to the exchange:

  # If both support git:// v2
  #
  C: 000cgit://v2
  S: 0010ok host user
  C: 0018host git.kernel.org
  C: 0027git-upload-pack /pub/linux-2.6.git
  S: ...git-upload-pack header...

  # If client supports git:// v2, server does not:
  #
  C: 000cgit://v2
  S: <EOF>

  C: 003bgit-upload-pack /pub/linux-2.6.git\0host=git.kernel.org\0
  S: ...git-upload-pack header...

This requires the client to create two TCP connections to talk to
an older git daemon, however all daemons since the introduction of
daemon.c will safely reject the unknown "git://v2" command request,
so the client can quite easily determine the server supports an
older protocol.

Signed-off-by: Shawn O. Pearce <spearce at spearce.org>
Signed-off-by: Junio C Hamano <gitster at pobox.com>
---
 connect.c |    5 ++++-
 daemon.c  |   11 ++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/connect.c b/connect.c
index 71597d4..b7bc917 100644
--- a/connect.c
+++ b/connect.c
@@ -569,7 +569,10 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
 			git_tcp_connect(fd, host, flags);
 		/*
 		 * Separate original protocol components prog and path
-		 * from extended components with a NUL byte.
+		 * from extended host header with a NUL byte.
+		 *
+		 * Note: Do not add any other headers here!  Doing so
+		 * will cause older git-daemon servers to crash.
 		 */
 		packet_write(fd[1],
 			     "%s %s%chost=%s%c",
diff --git a/daemon.c b/daemon.c
index 2b4a6f1..5566a6f 100644
--- a/daemon.c
+++ b/daemon.c
@@ -431,16 +431,15 @@ static void make_service_overridable(const char *name, int ena)
 }
 
 /*
- * Separate the "extra args" information as supplied by the client connection.
- * Any resulting data is squirreled away in the given interpolation table.
+ * Read the host as supplied by the client connection.
  */
-static void parse_extra_args(struct interp *table, char *extra_args, int buflen)
+static void parse_host_arg(struct interp *table, char *extra_args, int buflen)
 {
 	char *val;
 	int vallen;
 	char *end = extra_args + buflen;
 
-	while (extra_args < end && *extra_args) {
+	if (extra_args < end && *extra_args) {
 		saw_extended_args = 1;
 		if (strncasecmp("host=", extra_args, 5) == 0) {
 			val = extra_args + 5;
@@ -460,6 +459,8 @@ static void parse_extra_args(struct interp *table, char *extra_args, int buflen)
 			/* On to the next one */
 			extra_args = val + vallen;
 		}
+		if (extra_args < end && *extra_args)
+			die("Invalid request");
 	}
 }
 
@@ -579,7 +580,7 @@ static int execute(struct sockaddr *addr)
 	interp_set_entry(interp_table, INTERP_SLOT_PERCENT, "%");
 
 	if (len != pktlen) {
-	    parse_extra_args(interp_table, line + len + 1, pktlen - len - 1);
+	    parse_host_arg(interp_table, line + len + 1, pktlen - len - 1);
 	    fill_in_extra_table_entries(interp_table);
 	}
 
-- 
1.6.3.2



Index: git.spec
===================================================================
RCS file: /cvs/pkgs/rpms/git/EL-4/git.spec,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -p -r1.33 -r1.34
--- git.spec	14 Jan 2009 18:58:39 -0000	1.33
+++ git.spec	19 Jun 2009 13:35:08 -0000	1.34
@@ -1,7 +1,7 @@
 # Pass --without docs to rpmbuild if you don't want the documentation
 Name: 		git
 Version: 	1.5.4.7
-Release: 	2%{?dist}
+Release: 	3%{?dist}
 Summary:  	Git core and tools
 License: 	GPL
 Group: 		Development/Tools
@@ -12,6 +12,7 @@ Source2:	git.conf.httpd
 Patch0:		git-1.5-gitweb-home-link.patch
 Patch1:		gitweb-CVE-2008-5516.patch
 Patch2:		gitweb-CVE-2008-5517.patch
+Patch3:         git-1.5.4.7-daemon-extra-args.patch
 BuildRequires:	perl, zlib-devel >= 1.2, openssl-devel, curl-devel, expat-devel, gettext %{!?_without_docs:, xmlto, asciidoc > 6.0.3}
 BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Requires:	git-core, git-svn, git-cvs, git-email, gitk, git-gui, perl-Git
@@ -97,6 +98,7 @@ Perl interface to Git
 %patch0 -p1
 %patch1 -p1 -b .CVE-2008-5516
 %patch2 -p1 -b .CVE-2008-5517
+%patch3 -p1 -b .daemon-extra-args
 
 %build
 make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" \
@@ -200,6 +202,9 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Fri Jun 19 2009 Todd Zullinger <tmz at pobox.com> - 1.5.4.7-3
+- Fix git-daemon hang on invalid input (CVE-2009-2108, bug 505761)
+
 * Mon Jan 12 2009 Todd Zullinger <tmz at pobox.com> 1.5.4.7-2
 - Backport gitweb fixes for CVE-2008-5516 and CVE-2008-5517 (bug 479715)
 




More information about the fedora-extras-commits mailing list