From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>,
"Karel Kočí" <karel.koci@nic.cz>,
"Santiago Torres" <santiago@nyu.edu>,
"Vojtech Myslivec" <vojtech.myslivec@nic.cz>,
git@vger.kernel.org
Subject: Re: [PATCH 1/1] verify-tag/verify-commit should exit unsuccessfully when signature is not trusted
Date: Thu, 09 Aug 2018 11:40:27 -0700 [thread overview]
Message-ID: <xmqqy3dfbcys.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20180809171219.GF1439@sigill.intra.peff.net> (Jeff King's message of "Thu, 9 Aug 2018 13:12:19 -0400")
Jeff King <peff@peff.net> writes:
> I guess leaving it serves as a sort of cross-check if gpg would return a
> zero exit code but indicate in the status result that the signature was
> not good. Sort of a belt-and-suspenders, I guess (which might not be
> that implausible if we think about somebody wrapping gpg with a sloppy
> bit of shell code that loses the exit code -- it's their fault, but it
> might be nice for us to err on the conservative side).
OK, this time a real log message.
-- >8 --
Subject: [PATCH] gpg-interface: propagate exit status from gpg back to the callers
When gpg-interface API unified support for signature verification
codepaths for signed tags and signed commits in mid 2015 at around
v2.6.0-rc0~114, we accidentally loosened the GPG signature
verification.
Before that change, signed commits were verified by looking for
"G"ood signature from GPG, while ignoring the exit status of "gpg
--verify" process, while signed tags were verified by simply passing
the exit status of "gpg --verify" through. The unified code we
currently have ignores the exit status of "gpg --verify" and returns
successful verification when the signature matches an unexpired key
regardless of the trust placed on the key (i.e. in addition to "G"ood
ones, we accept "U"ntrusted ones).
Make these commands signal failure with their exit status when
underlying "gpg --verify" (or the custom command specified by
"gpg.program" configuration variable) does so. This essentially
changes their behaviour in a backward incompatible way to reject
signatures that have been made with untrusted keys even if they
correctly verify, as that is how "gpg --verify" behaves.
Note that the code still overrides a zero exit status obtained from
"gpg" (or gpg.program) if the output does not say the signature is
good or computes correctly but made with untrusted keys, to catch
a poorly written wrapper around "gpg" the user may give us.
We could exclude "U"ntrusted support from this fallback code, but
that would be making two backward incompatible changes in a single
commit, so let's avoid that for now. A follow-up change could do so
if desired.
Helped-by: Vojtech Myslivec <vojtech.myslivec@nic.cz>
Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
gpg-interface.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gpg-interface.c b/gpg-interface.c
index 0647bd6348..b5e64c55e2 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -81,12 +81,13 @@ int check_signature(const char *payload, size_t plen, const char *signature,
sigc->gpg_output = strbuf_detach(&gpg_output, NULL);
sigc->gpg_status = strbuf_detach(&gpg_status, NULL);
parse_gpg_output(sigc);
+ status |= sigc->result != 'G' && sigc->result != 'U';
out:
strbuf_release(&gpg_status);
strbuf_release(&gpg_output);
- return sigc->result != 'G' && sigc->result != 'U';
+ return !!status;
}
void print_signature_buffer(const struct signature_check *sigc, unsigned flags)
--
2.18.0-547-g1d89318c48
next prev parent reply other threads:[~2018-08-09 18:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-31 20:05 [PATCH 1/1] verify-tag/verify-commit should exit unsuccessfully when signature is not trusted Vojtech Myslivec
2018-08-01 0:19 ` brian m. carlson
2018-08-01 0:25 ` Santiago Torres
2018-08-03 13:36 ` Karel Kočí
2018-08-03 15:43 ` Santiago Torres
2018-08-03 16:06 ` Jeff King
2018-08-04 8:43 ` Karel Kočí
2018-08-08 23:04 ` Jeff King
2018-08-08 23:12 ` brian m. carlson
2018-08-09 0:59 ` Junio C Hamano
2018-08-09 1:43 ` brian m. carlson
2018-08-09 14:30 ` Jeff King
2018-08-09 15:30 ` Junio C Hamano
2018-08-09 17:12 ` Jeff King
2018-08-09 18:40 ` Junio C Hamano [this message]
2018-08-09 19:50 ` Jeff King
2018-08-10 2:27 ` brian m. carlson
2018-08-13 15:14 ` Vojtech Myslivec
2018-08-03 17:32 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqy3dfbcys.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=karel.koci@nic.cz \
--cc=peff@peff.net \
--cc=sandals@crustytoothpaste.net \
--cc=santiago@nyu.edu \
--cc=vojtech.myslivec@nic.cz \
/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.
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 NNTP newsgroup(s).