git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] archive: don't allow negation of --remote-request

From
Jeff King <peff@peff.net>
Date
Nov 15, 2011, 21:43 UTC
Message-ID
<20111115214317.GA20624@sigill.intra.peff.net>
In-Reply-To
<20111115214159.GA20457@sigill.intra.peff.net>

The remote-request flag is a security feature, telling the spawned git-archive that certain formats should be turned off. We always place it at the front of the command line when serving a remote request. Of course, this doesn't do us any good if the client can simply ask us politely to turn it off.

This bug was introduced in c09cd77 (upload-archive: use start_command instead of fork, 2011-10-24), but hasn't yet been released.

Signed-off-by: Jeff King <peff@peff.net>
---
The other option would be recognizing and disallowing this when reading
arguments from the remote.
 builtin/archive.c   |    2 +-
 t/t5000-tar-tree.sh |   12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/builtin/archive.c b/builtin/archive.c
index e405566..fce20a1 100644
--- a/builtin/archive.c
+++ b/builtin/archive.c
@@ -97,7 +97,7 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
 			"path to the remote git-upload-archive command"),
 		{ OPTION_BOOLEAN, 0, "remote-request", &is_remote, NULL,
 			"indicate we are serving a remote request",
-			PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
+			PARSE_OPT_NOARG | PARSE_OPT_HIDDEN | PARSE_OPT_NONEG },
 		OPT_END()
 	};
 
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 889842e..723b54e 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -305,6 +305,18 @@ test_expect_success 'only enabled filters are available remotely' '
 	test_cmp remote.bar config.bar
 '
 
+# We have to hand-craft this, since the local "git archive" will
+# eat our "--no-remote-request" argument otherwise.
+test_expect_success 'malicious clients cannot un-remote themselves' '
+	{
+		echo "0021argument --no-remote-request" &&
+		echo "001eargument --format=tar.foo" &&
+		echo "0012argument HEAD" &&
+		printf "0000"
+	} >evil-request &&
+	test_must_fail git upload-archive . <evil-request >remote.tar.foo
+'
+
 if $GZIP --version >/dev/null 2>&1; then
 	test_set_prereq GZIP
 else
-- 
1.7.7.3.8.g38efa
Previous: Jeff KingNext: Jeff King
Message 2 of 7 in “upload-archive security issues”
  1. 0/2 upload-archive security issuesJeff King, Nov 15, 2011
  2. 1/2 archive: don't allow negation of --remote-requestJeff King, Nov 15, 2011
  3. 2/2 archive: limit ourselves during remote requestsJeff King, Nov 15, 2011
  4. Junio C HamanoNov 16, 2011
  5. Erik Faye-LundNov 15, 2011
  6. Jeff KingNov 15, 2011
  7. Junio C HamanoNov 15, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.