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

Re: [RFC/PATCH] receive-pack.c: only accept push-cert if push_cert_nonce was advertised

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 9, 2015, 23:05 UTC
Message-ID
<xmqqfvbjblmd.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqqsifjbmu2.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 32 quoted lines
>> diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
>> index 4c069c5..628d13a 100644
>> --- a/builtin/receive-pack.c
>> +++ b/builtin/receive-pack.c
>> @@ -1276,7 +1276,8 @@ static struct command *read_head_info(struct sha1_array *shallow)
>>  				use_atomic = 1;
>>  		}
>>  
>> -		if (!strcmp(line, "push-cert")) {
>> +		if (push_cert_nonce &&
>> +		    !strcmp(line, "push-cert")) {
>>  			int true_flush = 0;
>>  			char certbuf[1024];
>
> This implementation is somewhat questionable.
>
> The server knows how to parse "push-cert" line, knows that what
> follows after that line up to "push-cert-end" line are shaped very
> differently from protocol commands outside the push-cert block.  In
> other words, it knows how to parse the request meant for the capable
> server; it just wants to refuse to serve that request.
>
> The patched code will make it fail by hoping that queue_command()
> that only handles "40-hex 40-hex ref" will reject the line that
> begins with "push-cert".  Instead of relying on such a hidden
> dependency, wouldn't it be cleaner to actually parse the push-cert
> block and then at the end notice and explictly say "Your requests
> were syntactically correct, but I am not going to honor your request
> to use the push-cert extension, because I never told you that I'd
> offer you that capability", instead of rejecting the request with "I
> was expecting old/new/ref but you sent a line with 'push-cert' on
> it; what are you talking about?"

Note that I said "somewhat" questionable, not "horribly broken", because another part of me wants to say that this implementation may be better than "parse and reject" from security point of view. The pusher cannot tell if the push failed because the server is old to know about the extension, or the server is new but is refusing, by observing the failure.

But the other side of the same coin is that it makes it harder to diagnose the failure.

When the protocol exchange gets to this state, in practice, we know we are talking with somebody who has push privilege into the repository, so revealing a bit more about the server by taking "parse and reject" route may be a reasonable price to give diagnosis that is more useful to help the users in this case, though.

Previous: Junio C HamanoNext: Stefan Beller
Message 3 of 11 in “receive-pack.c: only accept push-cert if push_cert_nonce was advertised”
  1. receive-pack.c: only accept push-cert if push_cert_nonce was advertisedStefan Beller, Jan 9, 2015
  2. Junio C HamanoJan 9, 2015
  3. Junio C HamanoJan 9, 2015
  4. Stefan BellerJan 9, 2015
  5. Junio C HamanoJan 9, 2015
  6. receive-pack.c: don't miss exporting unsolicited push certificatesStefan Beller, Jan 10, 2015
  7. Junio C HamanoJan 10, 2015
  8. Stefan BellerJan 10, 2015
  9. Junio C HamanoJan 12, 2015
  10. Stefan BellerJan 14, 2015
  11. Junio C HamanoJan 14, 2015

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.