git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 1/1] verify-tag/verify-commit should exit unsuccessfully when signature is not trusted
@ 2018-07-31 20:05 Vojtech Myslivec
  2018-08-01  0:19 ` brian m. carlson
  0 siblings, 1 reply; 19+ messages in thread
From: Vojtech Myslivec @ 2018-07-31 20:05 UTC (permalink / raw)
  To: git; +Cc: Karel Kočí


[-- Attachment #1.1.1: Type: text/plain, Size: 1226 bytes --]

Hello,

me and my colleague are struggling with automation of verifying git
repositories and we have encountered that git verify-commit and
verify-tag accepts untrusted signatures and exit successfully.

We have done some investigation of the GPG verification changes in git
repository which I includes in this patch message. GPG results
`TRUST_NEVER` and `TRUST_UNDEFINED` in raw output is treated as
untrusted in git (U) and should not be accepted in verify-commit and
verify-tag command.


In 434060ec6d verify-tag and verify-commit was centralized into
check_signature function and good (G) and untrusted (U) signatures were
marked as valid and exited successfully. In this commit it is
incorrectly stated that this behavior is adopted from older verify-tag
function however original verify-tag behavior was to return exit code
from gpg process itself (removed in a4cc18f29).

Also rejecting untrusted (U) signature is the pull/merge with
--verify-signatures behavior (defined in builtin/merge.c cmd_merge
function and presented in eb307ae7bb).

The behavior of merge/pull --verify-signatures and
verify-commit/verify-tag should be the same.


With regards,
Vojtech Myslivec and Karel Koci


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: 0001-gpg-interface-Do-not-accept-untrusted-signatures.patch --]
[-- Type: text/x-patch; name="0001-gpg-interface-Do-not-accept-untrusted-signatures.patch", Size: 3336 bytes --]

From c9c7b555da284c4f67fe36dc95d592644089544a Mon Sep 17 00:00:00 2001
From: Vojtech Myslivec <vojtech.myslivec@nic.cz>
Date: Tue, 31 Jul 2018 20:32:32 +0200
Subject: [PATCH] gpg-interface: Do not accept untrusted signatures

In 434060ec6d verify-tag and verify-commit was centralized into
check_signature function and good (G) and untrusted (U) signatures were
marked as valid and exited successfully. In this commit it is
incorrectly stated that this behavior is adopted from older verify-tag
function however original verify-tag behavior was to return exit code
from gpg process itself (removed in a4cc18f29).

Also rejecting untrusted (U) signature is the pull/merge with
--verify-signatures behavior (defined in builtin/merge.c cmd_merge
function and presented in eb307ae7bb).

The behavior of merge/pull --verify-signatures and
verify-commit/verify-tag should be the same.
---
 gpg-interface.c          | 2 +-
 t/t7030-verify-tag.sh    | 4 ++--
 t/t7510-signed-commit.sh | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gpg-interface.c b/gpg-interface.c
index 09ddfbc26..83adc7d12 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -86,7 +86,7 @@ int check_signature(const char *payload, size_t plen, const char *signature,
 	strbuf_release(&gpg_status);
 	strbuf_release(&gpg_output);
 
-	return sigc->result != 'G' && sigc->result != 'U';
+	return sigc->result != 'G';
 }
 
 void print_signature_buffer(const struct signature_check *sigc, unsigned flags)
diff --git a/t/t7030-verify-tag.sh b/t/t7030-verify-tag.sh
index 291a1e2b0..d6f77c443 100755
--- a/t/t7030-verify-tag.sh
+++ b/t/t7030-verify-tag.sh
@@ -63,7 +63,7 @@ test_expect_success GPG 'verify and show signatures' '
 	(
 		for tag in eighth-signed-alt
 		do
-			git verify-tag $tag 2>actual &&
+			test_must_fail git verify-tag $tag 2>actual &&
 			grep "Good signature from" actual &&
 			! grep "BAD signature from" actual &&
 			grep "not certified" actual &&
@@ -103,7 +103,7 @@ test_expect_success GPG 'verify signatures with --raw' '
 	(
 		for tag in eighth-signed-alt
 		do
-			git verify-tag --raw $tag 2>actual &&
+			test_must_fail git verify-tag --raw $tag 2>actual &&
 			grep "GOODSIG" actual &&
 			! grep "BADSIG" actual &&
 			grep "TRUST_UNDEFINED" actual &&
diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index 6e2015ed9..5cb388cb6 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -89,8 +89,8 @@ test_expect_success GPG 'verify and show signatures' '
 	)
 '
 
-test_expect_success GPG 'verify-commit exits success on untrusted signature' '
-	git verify-commit eighth-signed-alt 2>actual &&
+test_expect_success GPG 'verify-commit exits unsuccessfully on untrusted signature' '
+	test_must_fail git verify-commit eighth-signed-alt 2>actual &&
 	grep "Good signature from" actual &&
 	! grep "BAD signature from" actual &&
 	grep "not certified" actual
@@ -118,7 +118,7 @@ test_expect_success GPG 'verify signatures with --raw' '
 	(
 		for commit in eighth-signed-alt
 		do
-			git verify-commit --raw $commit 2>actual &&
+			test_must_fail git verify-commit --raw $commit 2>actual &&
 			grep "GOODSIG" actual &&
 			! grep "BADSIG" actual &&
 			grep "TRUST_UNDEFINED" actual &&
-- 
2.18.0


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2018-08-13 15:14 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).