guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: gnu: gnutls: Fix CVE-2021-20231 and CVE-2021-2023


From: guix-commits
Subject: branch master updated: gnu: gnutls: Fix CVE-2021-20231 and CVE-2021-20232.
Date: Sat, 13 Mar 2021 04:59:45 -0500

This is an automated email from the git hooks/post-receive script.

mhw pushed a commit to branch master
in repository guix.

The following commit(s) were added to refs/heads/master by this push:
     new 74e2c0e  gnu: gnutls: Fix CVE-2021-20231 and CVE-2021-20232.
74e2c0e is described below

commit 74e2c0e00f58c8bf948f7dc7c5ae2876af910d5a
Author: Mark H Weaver <mhw@netris.org>
AuthorDate: Sat Mar 13 03:41:14 2021 -0500

    gnu: gnutls: Fix CVE-2021-20231 and CVE-2021-20232.
    
    * gnu/packages/patches/gnutls-CVE-2021-20231.patch,
    gnu/packages/patches/gnutls-CVE-2021-20232.patch: New files.
    * gnu/local.mk (dist_patch_DATA): Add them.
    * gnu/packages/tls.scm (gnutls)[replacement]: New field.
    (gnutls/fixed): New variable.
    (guile2.2-gnutls): Use package/inherit.
---
 gnu/local.mk                                     |  2 +
 gnu/packages/patches/gnutls-CVE-2021-20231.patch | 62 ++++++++++++++++++++++++
 gnu/packages/patches/gnutls-CVE-2021-20232.patch | 60 +++++++++++++++++++++++
 gnu/packages/tls.scm                             | 15 ++++--
 4 files changed, 136 insertions(+), 3 deletions(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index e2bebb9..551503e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1144,6 +1144,8 @@ dist_patch_DATA =                                         
\
   %D%/packages/patches/gnupg-default-pinentry.patch            \
   %D%/packages/patches/gnutls-skip-trust-store-test.patch      \
   %D%/packages/patches/gnutls-cross.patch                      \
+  %D%/packages/patches/gnutls-CVE-2021-20231.patch             \
+  %D%/packages/patches/gnutls-CVE-2021-20232.patch             \
   %D%/packages/patches/gobject-introspection-absolute-shlib-path.patch \
   %D%/packages/patches/gobject-introspection-cc.patch          \
   %D%/packages/patches/gobject-introspection-girepository.patch        \
diff --git a/gnu/packages/patches/gnutls-CVE-2021-20231.patch 
b/gnu/packages/patches/gnutls-CVE-2021-20231.patch
new file mode 100644
index 0000000..5186522
--- /dev/null
+++ b/gnu/packages/patches/gnutls-CVE-2021-20231.patch
@@ -0,0 +1,62 @@
+From 15beb4b193b2714d88107e7dffca781798684e7e Mon Sep 17 00:00:00 2001
+From: Daiki Ueno <ueno@gnu.org>
+Date: Fri, 29 Jan 2021 14:06:05 +0100
+Subject: [PATCH 1/2] key_share: avoid use-after-free around realloc
+
+Signed-off-by: Daiki Ueno <ueno@gnu.org>
+---
+ lib/ext/key_share.c | 12 +++++-------
+ 1 file changed, 5 insertions(+), 7 deletions(-)
+
+diff --git a/lib/ext/key_share.c b/lib/ext/key_share.c
+index ab8abf8fe..a8c4bb5cf 100644
+--- a/lib/ext/key_share.c
++++ b/lib/ext/key_share.c
+@@ -664,14 +664,14 @@ key_share_send_params(gnutls_session_t session,
+ {
+       unsigned i;
+       int ret;
+-      unsigned char *lengthp;
+-      unsigned int cur_length;
+       unsigned int generated = 0;
+       const gnutls_group_entry_st *group;
+       const version_entry_st *ver;
+ 
+       /* this extension is only being sent on client side */
+       if (session->security_parameters.entity == GNUTLS_CLIENT) {
++              unsigned int length_pos;
++
+               ver = _gnutls_version_max(session);
+               if (unlikely(ver == NULL || ver->key_shares == 0))
+                       return 0;
+@@ -679,16 +679,13 @@ key_share_send_params(gnutls_session_t session,
+               if (!have_creds_for_tls13(session))
+                       return 0;
+ 
+-              /* write the total length later */
+-              lengthp = &extdata->data[extdata->length];
++              length_pos = extdata->length;
+ 
+               ret =
+                   _gnutls_buffer_append_prefix(extdata, 16, 0);
+               if (ret < 0)
+                       return gnutls_assert_val(ret);
+ 
+-              cur_length = extdata->length;
+-
+               if (session->internals.hsk_flags & HSK_HRR_RECEIVED) { /* we 
know the group */
+                       group = get_group(session);
+                       if (unlikely(group == NULL))
+@@ -736,7 +733,8 @@ key_share_send_params(gnutls_session_t session,
+               }
+ 
+               /* copy actual length */
+-              _gnutls_write_uint16(extdata->length - cur_length, lengthp);
++              _gnutls_write_uint16(extdata->length - length_pos - 2,
++                                   &extdata->data[length_pos]);
+ 
+       } else { /* server */
+               ver = get_version(session);
+-- 
+2.30.2
+
diff --git a/gnu/packages/patches/gnutls-CVE-2021-20232.patch 
b/gnu/packages/patches/gnutls-CVE-2021-20232.patch
new file mode 100644
index 0000000..dc3a0be
--- /dev/null
+++ b/gnu/packages/patches/gnutls-CVE-2021-20232.patch
@@ -0,0 +1,60 @@
+From 75a937d97f4fefc6f9b08e3791f151445f551cb3 Mon Sep 17 00:00:00 2001
+From: Daiki Ueno <ueno@gnu.org>
+Date: Fri, 29 Jan 2021 14:06:23 +0100
+Subject: [PATCH 2/2] pre_shared_key: avoid use-after-free around realloc
+
+Signed-off-by: Daiki Ueno <ueno@gnu.org>
+---
+ lib/ext/pre_shared_key.c | 15 ++++++++++++---
+ 1 file changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/lib/ext/pre_shared_key.c b/lib/ext/pre_shared_key.c
+index a042c6488..380bf39ed 100644
+--- a/lib/ext/pre_shared_key.c
++++ b/lib/ext/pre_shared_key.c
+@@ -267,7 +267,7 @@ client_send_params(gnutls_session_t session,
+       size_t spos;
+       gnutls_datum_t username = {NULL, 0};
+       gnutls_datum_t user_key = {NULL, 0}, rkey = {NULL, 0};
+-      gnutls_datum_t client_hello;
++      unsigned client_hello_len;
+       unsigned next_idx;
+       const mac_entry_st *prf_res = NULL;
+       const mac_entry_st *prf_psk = NULL;
+@@ -428,8 +428,7 @@ client_send_params(gnutls_session_t session,
+       assert(extdata->length >= sizeof(mbuffer_st));
+       assert(ext_offset >= (ssize_t)sizeof(mbuffer_st));
+       ext_offset -= sizeof(mbuffer_st);
+-      client_hello.data = extdata->data+sizeof(mbuffer_st);
+-      client_hello.size = extdata->length-sizeof(mbuffer_st);
++      client_hello_len = extdata->length-sizeof(mbuffer_st);
+ 
+       next_idx = 0;
+ 
+@@ -440,6 +439,11 @@ client_send_params(gnutls_session_t session,
+       }
+ 
+       if (prf_res && rkey.size > 0) {
++              gnutls_datum_t client_hello;
++
++              client_hello.data = extdata->data+sizeof(mbuffer_st);
++              client_hello.size = client_hello_len;
++
+               ret = compute_psk_binder(session, prf_res,
+                                        binders_len, binders_pos,
+                                        ext_offset, &rkey, &client_hello, 1,
+@@ -474,6 +478,11 @@ client_send_params(gnutls_session_t session,
+       }
+ 
+       if (prf_psk && user_key.size > 0 && info) {
++              gnutls_datum_t client_hello;
++
++              client_hello.data = extdata->data+sizeof(mbuffer_st);
++              client_hello.size = client_hello_len;
++
+               ret = compute_psk_binder(session, prf_psk,
+                                        binders_len, binders_pos,
+                                        ext_offset, &user_key, &client_hello, 
0,
+-- 
+2.30.2
+
diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index e0741ad..e8e1350 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -1,6 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2020 Ludovic Courtès 
<ludo@gnu.org>
-;;; Copyright © 2014, 2015, 2016, 2017, 2018 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2021 Mark H Weaver 
<mhw@netris.org>
 ;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
 ;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
@@ -165,6 +165,7 @@ living in the same process.")
   (package
     (name "gnutls")
     (version "3.6.15")
+    (replacement gnutls/fixed)
     (source (origin
               (method url-fetch)
               ;; Note: Releases are no longer on ftp.gnu.org since the
@@ -256,6 +257,15 @@ required structures.")
     (properties '((ftp-server . "ftp.gnutls.org")
                   (ftp-directory . "/gcrypt/gnutls")))))
 
+(define gnutls/fixed
+  (package
+    (inherit gnutls)
+    (source (origin
+              (inherit (package-source gnutls))
+              (patches (append (search-patches "gnutls-CVE-2021-20231.patch"
+                                               "gnutls-CVE-2021-20232.patch")
+                               (origin-patches (package-source gnutls))))))))
+
 (define-public gnutls/guile-2.0
   ;; GnuTLS for Guile 2.0.
   (package/inherit gnutls
@@ -274,8 +284,7 @@ required structures.")
               ,@(package-inputs gnutls)))))
 
 (define-public guile2.2-gnutls
-  (package
-    (inherit gnutls)
+  (package/inherit gnutls
     (name "guile2.2-gnutls")
     (inputs `(("guile" ,guile-2.2)
               ,@(alist-delete "guile"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]