git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Michał Górny" <mgorny@gentoo.org>
Cc: git@vger.kernel.org, jrnieder@gmail.com
Subject: Re: [PATCH v2] gpg-interface.c: detect and reject multiple signatures on commits
Date: Thu, 04 Oct 2018 23:14:15 -0700	[thread overview]
Message-ID: <xmqqin2g3op4.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: 1538555376.1042.3.camel@gentoo.org

Michał Górny <mgorny@gentoo.org> writes:

> On Fri, 2018-08-17 at 09:34 +0200, Michał Górny wrote:
>> GnuPG supports creating signatures consisting of multiple signature
>> packets.  If such a signature is verified, it outputs all the status
>> messages for each signature separately.  However, git currently does not
>> account for such scenario and gets terribly confused over getting
>> multiple *SIG statuses.
>> 
>> For example, if a malicious party alters a signed commit and appends
>> a new untrusted signature, git is going to ignore the original bad
>> signature and report untrusted commit instead.  However, %GK and %GS
>> format strings may still expand to the data corresponding
>> to the original signature, potentially tricking the scripts into
>> trusting the malicious commit.
>> 
>> Given that the use of multiple signatures is quite rare, git does not
>> support creating them without jumping through a few hoops, and finally
>> supporting them properly would require extensive API improvement, it
>> seems reasonable to just reject them at the moment.
>> 
>
> Gentle ping.

I think among the three issues raised in the review of v1 [*1*], one
of them remain unaddressed.  Other than that the addition relative
to v2 looks reasonable (but I only skimmed the patch).

[Reference] *1* https://public-inbox.org/git/xmqq1saxc5gu.fsf@gitster-ct.c.googlers.com/ 

Relevant part reproduced here.

>>>  	/* Iterate over all search strings */
>>>  	for (i = 0; i < ARRAY_SIZE(sigcheck_gpg_status); i++) {
>>> @@ -50,6 +52,10 @@ static void parse_gpg_output(struct signature_check *sigc)
>>>  				continue;
>>>  			found += strlen(sigcheck_gpg_status[i].check);
>>> ...
>>> +	if (had_status > 1) {
>>> +		sigc->result = 'E';
>>> +		/* Clear partial data to avoid confusion */
>>> +		if (sigc->signer)
>>> +			FREE_AND_NULL(sigc->signer);
>>> +		if (sigc->key)
>>> +			FREE_AND_NULL(sigc->key);
>>> +	}
>>
>> Makes sense to me.
>
> I was wondering if we have to revamp the loop altogether.  The
> current code runs through the list of all the possible "status"
> lines, and find the first occurrence for each type in the buffer
> that has GPG output.  Second and subsequent occurrence of the same
> type, if existed, will not be noticed by the original loop
> structure, and this patch does not change it, even though the topic
> of the patch is about rejecting the signature block with elements
> taken from multiple signatures.

Which still smells to me that it points out a grave (made grave by
what the patch claims to address) issue in the implementation of v1;
did v2 get substantially updated to address the concern?

> One way to fix it may be to keep
> the current loop structure to go over the sigcheck_gpg_status[],
> but make the logic inside the loop into an inner loop that finds all
> occurrences of the same type, instead of stopping after finding the
> first instance.  But once we go to that length, I suspect that it
> may be cleaner to iterate over the lines in the buffer, checking
> each line if it matches one of the recognized "[GNUPG:] FOOSIG"
> lines and acting on it (while ignoring unrecognized lines).


P.S. I'd be either offline or otherwise occupied until the next
week, so there is no need to hastily prepare an updated patch
series.

Thanks.


  parent reply	other threads:[~2018-10-05  6:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-17  7:34 [PATCH v2] gpg-interface.c: detect and reject multiple signatures on commits Michał Górny
2018-10-03  8:29 ` Michał Górny
2018-10-03 18:57   ` Stefan Beller
2018-10-05  6:14   ` Junio C Hamano [this message]
2018-10-04 22:52 ` Tacitus Aedifex

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqin2g3op4.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=mgorny@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).