|
|
427e0a |
From 839b89f45a38b2373bf5836337a33f450aaab72e Mon Sep 17 00:00:00 2001
|
|
|
427e0a |
From: Richard Hughes <richard@hughsie.com>
|
|
|
427e0a |
Date: Thu, 28 May 2020 10:41:23 +0100
|
|
|
427e0a |
Subject: [PATCH] Validate that gpgme_op_verify_result() returned at least one
|
|
|
427e0a |
signature
|
|
|
427e0a |
|
|
|
427e0a |
If a detached signature is actually a PGP message, gpgme_op_verify() returns
|
|
|
427e0a |
the rather perplexing GPG_ERR_NO_ERROR, and then gpgme_op_verify_result()
|
|
|
427e0a |
builds an empty list.
|
|
|
427e0a |
|
|
|
427e0a |
Explicitly check for no signatures present to avoid returning a JcatResult with
|
|
|
427e0a |
no timestamp and an empty authority.
|
|
|
427e0a |
|
|
|
427e0a |
Many thanks to Justin Steven <justin@justinsteven.com> for the discovery and
|
|
|
427e0a |
coordinated disclosure of this issue. Fixes CVE-2020-10759
|
|
|
427e0a |
---
|
|
|
427e0a |
libjcat/jcat-gpg-engine.c | 7 +++++
|
|
|
427e0a |
libjcat/jcat-self-test.c | 55 +++++++++++++++++++++++++++++++++++++++
|
|
|
427e0a |
2 files changed, 62 insertions(+)
|
|
|
427e0a |
|
|
|
427e0a |
diff --git libjcat/jcat-gpg-engine.c libjcat/jcat-gpg-engine.c
|
|
|
427e0a |
index 0812a62..bd44dba 100644
|
|
|
427e0a |
--- libjcat/jcat-gpg-engine.c
|
|
|
427e0a |
+++ libjcat/jcat-gpg-engine.c
|
|
|
427e0a |
@@ -267,6 +267,13 @@ jcat_gpg_engine_pubkey_verify (JcatEngine *engine,
|
|
|
427e0a |
"no result record from libgpgme");
|
|
|
427e0a |
return NULL;
|
|
|
427e0a |
}
|
|
|
427e0a |
+ if (result->signatures == NULL) {
|
|
|
427e0a |
+ g_set_error_literal (error,
|
|
|
427e0a |
+ G_IO_ERROR,
|
|
|
427e0a |
+ G_IO_ERROR_FAILED,
|
|
|
427e0a |
+ "no signatures from libgpgme");
|
|
|
427e0a |
+ return NULL;
|
|
|
427e0a |
+ }
|
|
|
427e0a |
|
|
|
427e0a |
/* look at each signature */
|
|
|
427e0a |
for (s = result->signatures; s != NULL ; s = s->next ) {
|
|
|
427e0a |
diff --git libjcat/jcat-self-test.c libjcat/jcat-self-test.c
|
|
|
427e0a |
index d79a3a9..fd4295e 100644
|
|
|
427e0a |
--- libjcat/jcat-self-test.c
|
|
|
427e0a |
+++ libjcat/jcat-self-test.c
|
|
|
427e0a |
@@ -393,6 +393,60 @@ jcat_gpg_engine_func (void)
|
|
|
427e0a |
#endif
|
|
|
427e0a |
}
|
|
|
427e0a |
|
|
|
427e0a |
+static void
|
|
|
427e0a |
+jcat_gpg_engine_msg_func (void)
|
|
|
427e0a |
+{
|
|
|
427e0a |
+#ifdef ENABLE_GPG
|
|
|
427e0a |
+ g_autofree gchar *fn = NULL;
|
|
|
427e0a |
+ g_autofree gchar *pki_dir = NULL;
|
|
|
427e0a |
+ g_autoptr(GBytes) data = NULL;
|
|
|
427e0a |
+ g_autoptr(GBytes) data_sig = NULL;
|
|
|
427e0a |
+ g_autoptr(GError) error = NULL;
|
|
|
427e0a |
+ g_autoptr(JcatContext) context = jcat_context_new ();
|
|
|
427e0a |
+ g_autoptr(JcatEngine) engine = NULL;
|
|
|
427e0a |
+ g_autoptr(JcatResult) result = NULL;
|
|
|
427e0a |
+ const gchar *sig =
|
|
|
427e0a |
+ "-----BEGIN PGP MESSAGE-----\n"
|
|
|
427e0a |
+ "owGbwMvMwMEovmZX76/pfOKMp0WSGOLOX3/ikZqTk6+jUJ5flJOiyNXJaMzCwMjB\n"
|
|
|
427e0a |
+ "ICumyCJmt5VRUil28/1+z1cwbaxMID0MXJwCMJG4RxwMLUYXDkUad34I3vrT8+X2\n"
|
|
|
427e0a |
+ "m+ZyHyMWnTiQYaQb/eLJGqbiAJc5Jr4a/PPqHNi7auwzGsKsljebabjtnJRzpDr0\n"
|
|
|
427e0a |
+ "YvwrnmmWLJUnTzjM3MH5Kn+RzqXkywsYdk9yD2OUdLy736CiemFMdcuF02lOZvPU\n"
|
|
|
427e0a |
+ "HaTKl76wW62QH8Lr8yGMQ1Xgc6nC2ZwUhvctky7NOZtc1T477uBTL81p31ZmaIUJ\n"
|
|
|
427e0a |
+ "paS8uWZl8UzX5sFsqQi37G1TbDc8Cm+oU/yRkFj2pLBzw367ncsa4n7EqEWu1yrN\n"
|
|
|
427e0a |
+ "yD39LUeErePdqfKCG+xhL6WkWt5ZJ/6//XnjouXhl5Z4tWspT49MtNp5d3aDQ43c\n"
|
|
|
427e0a |
+ "mnbresn6A7KMZgdOiwIA\n"
|
|
|
427e0a |
+ "=a9ui\n"
|
|
|
427e0a |
+ "-----END PGP MESSAGE-----\n";
|
|
|
427e0a |
+
|
|
|
427e0a |
+ /* set up context */
|
|
|
427e0a |
+ jcat_context_set_keyring_path (context, "/tmp/libjcat-self-test/var");
|
|
|
427e0a |
+ pki_dir = g_test_build_filename (G_TEST_DIST, "pki", NULL);
|
|
|
427e0a |
+ jcat_context_add_public_keys (context, pki_dir);
|
|
|
427e0a |
+
|
|
|
427e0a |
+ /* get engine */
|
|
|
427e0a |
+ engine = jcat_context_get_engine (context, JCAT_BLOB_KIND_GPG, &error);
|
|
|
427e0a |
+ g_assert_no_error (error);
|
|
|
427e0a |
+ g_assert_nonnull (engine);
|
|
|
427e0a |
+ g_assert_cmpint (jcat_engine_get_kind (engine), ==, JCAT_BLOB_KIND_GPG);
|
|
|
427e0a |
+ g_assert_cmpint (jcat_engine_get_verify_kind (engine), ==, JCAT_ENGINE_VERIFY_KIND_SIGNATURE);
|
|
|
427e0a |
+
|
|
|
427e0a |
+ /* verify with GnuPG, which should fail as the signature is not a
|
|
|
427e0a |
+ * detached signature at all, but gnupg stabs us in the back by returning
|
|
|
427e0a |
+ * success from gpgme_op_verify() with an empty list of signatures */
|
|
|
427e0a |
+ fn = g_test_build_filename (G_TEST_DIST, "colorhug", "firmware.bin", NULL);
|
|
|
427e0a |
+ data = jcat_get_contents_bytes (fn, &error);
|
|
|
427e0a |
+ g_assert_no_error (error);
|
|
|
427e0a |
+ g_assert_nonnull (data);
|
|
|
427e0a |
+ data_sig = g_bytes_new_static (sig, strlen (sig));
|
|
|
427e0a |
+ result = jcat_engine_pubkey_verify (engine, data, data_sig,
|
|
|
427e0a |
+ JCAT_VERIFY_FLAG_NONE, &error);
|
|
|
427e0a |
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
|
|
|
427e0a |
+ g_assert_null (result);
|
|
|
427e0a |
+#else
|
|
|
427e0a |
+ g_test_skip ("no GnuPG support enabled");
|
|
|
427e0a |
+#endif
|
|
|
427e0a |
+}
|
|
|
427e0a |
+
|
|
|
427e0a |
static void
|
|
|
427e0a |
jcat_pkcs7_engine_func (void)
|
|
|
427e0a |
{
|
|
|
427e0a |
@@ -753,6 +807,7 @@ main (int argc, char **argv)
|
|
|
427e0a |
g_test_add_func ("/jcat/engine{sha1}", jcat_sha1_engine_func);
|
|
|
427e0a |
g_test_add_func ("/jcat/engine{sha256}", jcat_sha256_engine_func);
|
|
|
427e0a |
g_test_add_func ("/jcat/engine{gpg}", jcat_gpg_engine_func);
|
|
|
427e0a |
+ g_test_add_func ("/jcat/engine{gpg-msg}", jcat_gpg_engine_msg_func);
|
|
|
427e0a |
g_test_add_func ("/jcat/engine{pkcs7}", jcat_pkcs7_engine_func);
|
|
|
427e0a |
g_test_add_func ("/jcat/engine{pkcs7-self-signed}", jcat_pkcs7_engine_self_signed_func);
|
|
|
427e0a |
g_test_add_func ("/jcat/context{verify-blob}", jcat_context_verify_blob_func);
|
|
|
427e0a |
--
|
|
|
427e0a |
2.26.2
|
|
|
427e0a |
|