summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2019-03-25 15:47:51 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2019-03-27 07:20:12 +0100
commitad27713bef613e6c4600a0fb83ae48c6d390ff5b (patch)
tree05b5f6c401c8944e964177cd20ca88c0aa048f39
parent9043c8c2d1c6aef9aff0e4a40ec3926bc7c34361 (diff)
downloadgnutls-ad27713bef613e6c4600a0fb83ae48c6d390ff5b.tar.gz
fuzz: added fuzzer for certificate verification
This also adds a reproducer for CVE-2019-3829. Resolves: #694 Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r--fuzz/Makefile.am2
-rw-r--r--fuzz/gnutls_x509_verify_fuzzer.c201
-rw-r--r--fuzz/gnutls_x509_verify_fuzzer.in/005eb5cbad48e22a4b0c36cd97f1c0225f3eed7f1
-rw-r--r--fuzz/gnutls_x509_verify_fuzzer.in/c2632449b011340199af11389c073d2d380b2e1ebin0 -> 1394 bytes
-rw-r--r--fuzz/gnutls_x509_verify_fuzzer.repro/cacdb69aaf394120d761291f43983336d15c7be3bin0 -> 1394 bytes
-rw-r--r--tests/cert-tests/Makefile.am2
-rw-r--r--tests/cert-tests/data/cve-2019-3829.pem66
-rwxr-xr-xtests/cert-tests/invalid-sig16
8 files changed, 286 insertions, 2 deletions
diff --git a/fuzz/Makefile.am b/fuzz/Makefile.am
index 4af73bc095..32d64d6abc 100644
--- a/fuzz/Makefile.am
+++ b/fuzz/Makefile.am
@@ -9,6 +9,7 @@ LDADD = ../gl/libgnu.la ../lib/libgnutls.la \
$(LIBS)
FUZZERS = \
+ gnutls_x509_verify_fuzzer$(EXEEXT) \
gnutls_base64_decoder_fuzzer$(EXEEXT) \
gnutls_base64_encoder_fuzzer$(EXEEXT) \
gnutls_client_fuzzer$(EXEEXT) \
@@ -31,6 +32,7 @@ FUZZERS = \
check_PROGRAMS = $(FUZZERS)
+gnutls_x509_verify_fuzzer_SOURCES = gnutls_x509_verify_fuzzer.c main.c fuzzer.h
gnutls_base64_decoder_fuzzer_SOURCES = gnutls_base64_decoder_fuzzer.c main.c fuzzer.h
gnutls_base64_encoder_fuzzer_SOURCES = gnutls_base64_encoder_fuzzer.c main.c fuzzer.h
gnutls_client_fuzzer_SOURCES = gnutls_client_fuzzer.c main.c fuzzer.h mem.h certs.h
diff --git a/fuzz/gnutls_x509_verify_fuzzer.c b/fuzz/gnutls_x509_verify_fuzzer.c
new file mode 100644
index 0000000000..645075150a
--- /dev/null
+++ b/fuzz/gnutls_x509_verify_fuzzer.c
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2019 Red Hat, Inc.
+ *
+ * Author: Nikos Mavrogiannopoulos
+ *
+ * This file is part of GnuTLS.
+ *
+ * The GnuTLS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>
+ *
+ */
+
+#include <assert.h>
+#include <stdint.h>
+
+#include <gnutls/gnutls.h>
+#include <gnutls/x509.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "fuzzer.h"
+
+unsigned char _ca_der[] = {
+ 0x30, 0x82, 0x05, 0xe2, 0x30, 0x82, 0x04, 0xca, 0xa0, 0x03, 0x02, 0x01,
+ 0x02, 0x02, 0x10, 0x27, 0x53, 0xf8, 0x06, 0xfe, 0x91, 0x37, 0x32, 0x2f,
+ 0x5b, 0x40, 0x9f, 0x1c, 0x31, 0x87, 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a,
+ 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x81,
+ 0xca, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02,
+ 0x55, 0x53, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13,
+ 0x0e, 0x56, 0x65, 0x72, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x2c, 0x20, 0x49,
+ 0x6e, 0x63, 0x2e, 0x31, 0x1f, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x04, 0x0b,
+ 0x13, 0x16, 0x56, 0x65, 0x72, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x20, 0x54,
+ 0x72, 0x75, 0x73, 0x74, 0x20, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b,
+ 0x31, 0x3a, 0x30, 0x38, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x31, 0x28,
+ 0x63, 0x29, 0x20, 0x32, 0x30, 0x30, 0x36, 0x20, 0x56, 0x65, 0x72, 0x69,
+ 0x53, 0x69, 0x67, 0x6e, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, 0x2d,
+ 0x20, 0x46, 0x6f, 0x72, 0x20, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69,
+ 0x7a, 0x65, 0x64, 0x20, 0x75, 0x73, 0x65, 0x20, 0x6f, 0x6e, 0x6c, 0x79,
+ 0x31, 0x45, 0x30, 0x43, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x3c, 0x56,
+ 0x65, 0x72, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x20, 0x43, 0x6c, 0x61, 0x73,
+ 0x73, 0x20, 0x33, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20, 0x50,
+ 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69,
+ 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x41, 0x75, 0x74,
+ 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x20, 0x2d, 0x20, 0x47, 0x35, 0x30,
+ 0x1e, 0x17, 0x0d, 0x31, 0x30, 0x30, 0x32, 0x30, 0x38, 0x30, 0x30, 0x30,
+ 0x30, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x32, 0x30, 0x30, 0x32, 0x30, 0x37,
+ 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x81, 0xb4, 0x31, 0x0b,
+ 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31,
+ 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0e, 0x56, 0x65,
+ 0x72, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x2c, 0x20, 0x49, 0x6e, 0x63, 0x2e,
+ 0x31, 0x1f, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x16, 0x56,
+ 0x65, 0x72, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x20, 0x54, 0x72, 0x75, 0x73,
+ 0x74, 0x20, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x31, 0x3b, 0x30,
+ 0x39, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x32, 0x54, 0x65, 0x72, 0x6d,
+ 0x73, 0x20, 0x6f, 0x66, 0x20, 0x75, 0x73, 0x65, 0x20, 0x61, 0x74, 0x20,
+ 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e,
+ 0x76, 0x65, 0x72, 0x69, 0x73, 0x69, 0x67, 0x6e, 0x2e, 0x63, 0x6f, 0x6d,
+ 0x2f, 0x72, 0x70, 0x61, 0x20, 0x28, 0x63, 0x29, 0x31, 0x30, 0x31, 0x2e,
+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ff, 0x04, 0x08,
+ 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x00, 0x30, 0x70, 0x06, 0x03,
+ 0x55, 0x1d, 0x20, 0x04, 0x69, 0x30, 0x67, 0x30, 0x65, 0x06, 0x0b, 0x60,
+ 0x86, 0x48, 0x01, 0x86, 0xf8, 0x45, 0x01, 0x07, 0x17, 0x03, 0x30, 0x56,
+ 0x30, 0x28, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x02, 0x01,
+ 0x16, 0x1c, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77,
+ 0x77, 0x2e, 0x76, 0x65, 0x72, 0x69, 0x73, 0x69, 0x67, 0x6e, 0x2e, 0x63,
+ 0x6f, 0x6d, 0x2f, 0x63, 0x70, 0x73, 0x30, 0x2a, 0x06, 0x08, 0x2b, 0x06,
+ 0x01, 0x05, 0x05, 0x07, 0x02, 0x02, 0x30, 0x1e, 0x1a, 0x1c, 0x68, 0x74,
+ 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x76, 0x65,
+ 0x72, 0x69, 0x73, 0x69, 0x67, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72,
+ 0x70, 0x61, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff,
+ 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x6d, 0x06, 0x08, 0x2b, 0x06,
+ 0x01, 0x05, 0x05, 0x07, 0x01, 0x0c, 0x04, 0x61, 0x30, 0x5f, 0xa1, 0x5d,
+ 0xa0, 0x5b, 0x30, 0x59, 0x30, 0x57, 0x30, 0x55, 0x16, 0x09, 0x69, 0x6d,
+ 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0x30, 0x21, 0x30, 0x1f, 0x30,
+ 0x07, 0x06, 0x05, 0x2b, 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0x6d, 0x37, 0x32, 0xe3, 0xc5, 0xa3, 0x84
+};
+unsigned int _ca_der_len = 1510;
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+{
+ gnutls_datum_t raw;
+ gnutls_datum_t ca;
+ gnutls_x509_crt_t crt, ca_crt;
+ int ret;
+ unsigned status;
+
+ raw.data = (unsigned char *)data;
+ raw.size = size;
+
+ ca.data = _ca_der;
+ ca.size = _ca_der_len;
+
+ ret = gnutls_x509_crt_init(&ca_crt);
+ assert(ret >= 0);
+
+ ret = gnutls_x509_crt_init(&crt);
+ assert(ret >= 0);
+
+ ret = gnutls_x509_crt_import(ca_crt, &ca, GNUTLS_X509_FMT_DER);
+ if (ret < 0)
+ goto fail;
+
+ ret = gnutls_x509_crt_import(crt, &raw, GNUTLS_X509_FMT_DER);
+ if (ret < 0)
+ goto fail;
+
+ ret = gnutls_x509_crt_list_verify(&crt, 1, &ca_crt, 1, NULL, 0,
+ GNUTLS_VERIFY_ALLOW_UNSORTED_CHAIN|GNUTLS_VERIFY_ALLOW_BROKEN|
+ GNUTLS_VERIFY_DISABLE_TRUSTED_TIME_CHECKS,
+ &status);
+ assert(ret >= 0 || status != 0);
+
+ fail:
+ gnutls_x509_crt_deinit(crt);
+ gnutls_x509_crt_deinit(ca_crt);
+ return 0;
+}
diff --git a/fuzz/gnutls_x509_verify_fuzzer.in/005eb5cbad48e22a4b0c36cd97f1c0225f3eed7f b/fuzz/gnutls_x509_verify_fuzzer.in/005eb5cbad48e22a4b0c36cd97f1c0225f3eed7f
new file mode 100644
index 0000000000..246a9aa565
--- /dev/null
+++ b/fuzz/gnutls_x509_verify_fuzzer.in/005eb5cbad48e22a4b0c36cd97f1c0225f3eed7f
@@ -0,0 +1 @@
+0„ \ No newline at end of file
diff --git a/fuzz/gnutls_x509_verify_fuzzer.in/c2632449b011340199af11389c073d2d380b2e1e b/fuzz/gnutls_x509_verify_fuzzer.in/c2632449b011340199af11389c073d2d380b2e1e
new file mode 100644
index 0000000000..ba9f7c073d
--- /dev/null
+++ b/fuzz/gnutls_x509_verify_fuzzer.in/c2632449b011340199af11389c073d2d380b2e1e
Binary files differ
diff --git a/fuzz/gnutls_x509_verify_fuzzer.repro/cacdb69aaf394120d761291f43983336d15c7be3 b/fuzz/gnutls_x509_verify_fuzzer.repro/cacdb69aaf394120d761291f43983336d15c7be3
new file mode 100644
index 0000000000..bad7160bae
--- /dev/null
+++ b/fuzz/gnutls_x509_verify_fuzzer.repro/cacdb69aaf394120d761291f43983336d15c7be3
Binary files differ
diff --git a/tests/cert-tests/Makefile.am b/tests/cert-tests/Makefile.am
index a608a24a3c..0d13aeaa75 100644
--- a/tests/cert-tests/Makefile.am
+++ b/tests/cert-tests/Makefile.am
@@ -65,7 +65,7 @@ EXTRA_DIST = data/ca-no-pathlen.pem data/no-ca-or-pathlen.pem data/aki-cert.pem
data/openssl-keyid.p7b data/openssl-keyid.p7b.out data/openssl.p12 \
data/x509-v1-with-sid.pem data/x509-v1-with-iid.pem data/x509-v3-with-fractional-time.pem \
templates/template-long-dns.tmpl templates/template-long-serial.tmpl \
- data/key-rsa-pss-raw.pem data/key-rsa-pss.pem \
+ data/key-rsa-pss-raw.pem data/key-rsa-pss.pem data/cve-2019-3829.pem \
data/long-dns.pem data/template-long-dns-crq.pem data/chain-with-critical-on-root.pem \
data/chain-with-critical-on-intermediate.pem data/chain-with-critical-on-endcert.pem \
templates/crit-extensions.tmpl data/crit-extensions.pem data/x509-with-zero-version.pem \
diff --git a/tests/cert-tests/data/cve-2019-3829.pem b/tests/cert-tests/data/cve-2019-3829.pem
new file mode 100644
index 0000000000..c771843ea7
--- /dev/null
+++ b/tests/cert-tests/data/cve-2019-3829.pem
@@ -0,0 +1,66 @@
+-----BEGIN CERTIFICATE-----
+MIIFbjCCBFagAwIBAgIQPBKFvactgik351RXZ5opvTANBgkqhkiG9w0BAQUFADCB
+tDELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYD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SBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZl
+cmlzaWduLmNvbS92c2xvZ28uZ2lmMDQGA1UdHwQtMCswKaAnoCWGI2h0dHA6Ly9j
+cmwudmVyaXNpZ24uY29tL3BjYTMtZzUuY3JsMCgGA1UdEQQhMB+kHTAbMRkwFwYD
+VQQDExBWZXJpU2lnbk1QS0ktMi04MB0GA1UdDgQWBBTPmanqeyb0S8mOj9fwBSbv
+49KnnTArBgNVHSUEJDAiBggrBgEFBQcDAgYIKwYBBQUHAwMGDCqGOgABg4+JDQEB
+ATAfBgNVHSMEGDAWgBR/02Wnwt3su/AwCfNDOfoCrzMxMzANBgkqhkiG9w0BAQUF
+AAOCAQEAW46f07q+qa8aPmWBt8Fk9qJ460yABjqsIm6MK7xdhX/AjxAqysStliQB
+aP9ltdEULCql2kmWr+nU/3GckwlKamH0S9HLtl8p/GgR5XL/Rg82KZlDnrPZrEeT
+e+/E62aGp9aJVD6Umw2R8NIjasANN85G35WupGXGGL+kaXM/6IXQSH0o7/NfsAG0
+dbTRU0v0b/aki2a273g5xYgrZzIa70DAlPa30ouEoCZvikvF2NxU7uJKVqq8cuWT
+5j+23m1seyVbAexvKWS38y4j9h+uES3GurnrCGCxLRsrnr6FdAodLipSkRgg18my
+l4SPFiwyyhgSqsUgWcr7bTcy48WjhA==
+-----END CERTIFICATE-----
diff --git a/tests/cert-tests/invalid-sig b/tests/cert-tests/invalid-sig
index bc2774e1f5..bcebf995cb 100755
--- a/tests/cert-tests/invalid-sig
+++ b/tests/cert-tests/invalid-sig
@@ -29,6 +29,10 @@ if ! test -z "${VALGRIND}"; then
VALGRIND="${LIBTOOL:-libtool} --mode=execute ${VALGRIND}"
fi
+if ! test -x "${CERTTOOL}"; then
+ exit 77
+fi
+
#check whether a different PKCS #1 signature than the advertized in certificate is tolerated
${VALGRIND} "${CERTTOOL}" -e --infile "${srcdir}/data/invalid-sig.pem"
rc=$?
@@ -75,7 +79,17 @@ rc=$?
# We're done.
if test "${rc}" = "0"; then
- echo "Verification of invalid signature (4) failed"
+ echo "Verification of invalid signature (5) failed"
+ exit ${rc}
+fi
+
+#this was causing a double free; verify that we receive the expected error code
+${VALGRIND} "${CERTTOOL}" --verify-chain --infile "${srcdir}/data/cve-2019-3829.pem"
+rc=$?
+
+# We're done.
+if test "${rc}" != "1"; then
+ echo "Verification of invalid signature (6) failed"
exit ${rc}
fi