Browse code

c-ares:CVE-2017-100381,libgcrypt-CVE-2017-0379,ncures:CVE-2017-1000381

Change-Id: I9837cfbdf87463ea5b7c88ca546843fbee651c93
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4062
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Sharath George

Priyesh Padmavilasomb authored on 2017/10/18 08:05:58
Showing 5 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,35 @@
0
+From e1f43d4d7e89ef8db479d6efd0389c6b6ee1d116 Mon Sep 17 00:00:00 2001
1
+From: David Drysdale <drysdale@google.com>
2
+Date: Mon, 22 May 2017 10:54:10 +0100
3
+Subject: [PATCH 5/5] ares_parse_naptr_reply: check sufficient data
4
+
5
+Check that there is enough data for the required elements
6
+of an NAPTR record (2 int16, 3 bytes for string lengths)
7
+before processing a record.
8
+---
9
+ ares_parse_naptr_reply.c | 7 ++++++-
10
+ 1 file changed, 6 insertions(+), 1 deletion(-)
11
+
12
+diff --git a/ares_parse_naptr_reply.c b/ares_parse_naptr_reply.c
13
+index 11634df9847c..717d35577811 100644
14
+--- a/ares_parse_naptr_reply.c
15
+@@ -110,6 +110,12 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen,
16
+           status = ARES_EBADRESP;
17
+           break;
18
+         }
19
++      /* RR must contain at least 7 bytes = 2 x int16 + 3 x name */
20
++      if (rr_len < 7)
21
++        {
22
++          status = ARES_EBADRESP;
23
++          break;
24
++        }
25
+ 
26
+       /* Check if we are really looking at a NAPTR record */
27
+       if (rr_class == C_IN && rr_type == T_NAPTR)
28
+@@ -185,4 +191,3 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen,
29
+ 
30
+   return ARES_SUCCESS;
31
+ }
32
+-
33
+-- 
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:        A library that performs asynchronous DNS operations
2 2
 Name:           c-ares
3 3
 Version:        1.12.0
4
-Release:        1%{?dist}
4
+Release:        2%{?dist}
5 5
 License:        MIT
6 6
 Group:          System Environment/Libraries
7 7
 Vendor:         VMware, Inc.
... ...
@@ -9,6 +9,7 @@ Distribution:   Photon
9 9
 URL:            http://c-ares.haxx.se/
10 10
 Source0:        http://c-ares.haxx.se/download/%{name}-%{version}.tar.gz
11 11
 %define sha1    c-ares=8abfce61d2d788fb60a3441d05275162a460cbed
12
+Patch0:         CVE-2017-1000381.patch
12 13
 
13 14
 BuildRequires:  autoconf
14 15
 BuildRequires:  automake
... ...
@@ -31,6 +32,7 @@ compile applications or shared objects that use c-ares.
31 31
 
32 32
 %prep
33 33
 %setup -q
34
+%patch0 -p1
34 35
 
35 36
 f=CHANGES ; iconv -f iso-8859-1 -t utf-8 $f -o $f.utf8 ; mv $f.utf8 $f
36 37
 
... ...
@@ -68,6 +70,8 @@ rm -rf $RPM_BUILD_ROOT
68 68
 %{_mandir}/man3/ares_*
69 69
 
70 70
 %changelog
71
+*   Tue Oct 17 2017 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 1.12.0-2
72
+-   Fix CVE-2017-1000381
71 73
 *   Thu Jun 29 2017 Vinay Kulkarni <kulkarniv@vmware.com> 1.12.0-1
72 74
 -   Update c-ares to v1.12.0.
73 75
 *   Wed Oct 05 2016 Xiaolin Li <xiaolinl@vmware.com> 1.10.0-3
74 76
new file mode 100644
... ...
@@ -0,0 +1,152 @@
0
+From bf76acbf0da6b0f245e491bec12c0f0a1b5be7c9 Mon Sep 17 00:00:00 2001
1
+From: NIIBE Yutaka <gniibe@fsij.org>
2
+Date: Fri, 25 Aug 2017 18:13:28 +0900
3
+Subject: [PATCH] ecc: Add input validation for X25519.
4
+
5
+* cipher/ecc.c (ecc_decrypt_raw): Add input validation.
6
+* mpi/ec.c (ec_p_init): Use scratch buffer for bad points.
7
+(_gcry_mpi_ec_bad_point): New.
8
+
9
+--
10
+
11
+Following is the paper describing the attack:
12
+
13
+    May the Fourth Be With You: A Microarchitectural Side Channel Attack
14
+    on Real-World Applications of Curve25519
15
+    by Daniel Genkin, Luke Valenta, and Yuval Yarom
16
+
17
+In the current implementation, we do output checking and it results an
18
+error for those bad points.  However, when attacked, the computation
19
+will done with leak of private key, even it will results errors.  To
20
+mitigate leak, we added input validation.
21
+
22
+Note that we only list bad points with MSB=0.  By X25519, MSB is
23
+always cleared.
24
+
25
+In future, we should implement constant-time field computation.  Then,
26
+this input validation could be removed, if performance is important
27
+and we are sure for no leak.
28
+
29
+CVE-id: CVE-2017-0379
30
+Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
31
+---
32
+ cipher/ecc.c | 17 +++++++++++++++--
33
+ mpi/ec.c     | 51 ++++++++++++++++++++++++++++++++++++++++++++++++---
34
+ src/mpi.h    |  1 +
35
+ 3 files changed, 64 insertions(+), 5 deletions(-)
36
+
37
+diff --git a/cipher/ecc.c b/cipher/ecc.c
38
+index e25bf09..4e3e5b1 100644
39
+--- a/cipher/ecc.c
40
+@@ -1628,9 +1628,22 @@ ecc_decrypt_raw (gcry_sexp_t *r_plain, gcry_sexp_t s_data, gcry_sexp_t keyparms)
41
+   if (DBG_CIPHER)
42
+     log_printpnt ("ecc_decrypt    kG", &kG, NULL);
43
+ 
44
+-  if (!(flags & PUBKEY_FLAG_DJB_TWEAK)
45
++  if ((flags & PUBKEY_FLAG_DJB_TWEAK))
46
++    {
47
+       /* For X25519, by its definition, validation should not be done.  */
48
+-      && !_gcry_mpi_ec_curve_point (&kG, ec))
49
++      /* (Instead, we do output check.)
50
++       *
51
++       * However, to mitigate secret key leak from our implementation,
52
++       * we also do input validation here.  For constant-time
53
++       * implementation, we can remove this input validation.
54
++       */
55
++      if (_gcry_mpi_ec_bad_point (&kG, ec))
56
++        {
57
++          rc = GPG_ERR_INV_DATA;
58
++          goto leave;
59
++        }
60
++    }
61
++  else if (!_gcry_mpi_ec_curve_point (&kG, ec))
62
+     {
63
+       rc = GPG_ERR_INV_DATA;
64
+       goto leave;
65
+diff --git a/mpi/ec.c b/mpi/ec.c
66
+index a0f7357..4c16603 100644
67
+--- a/mpi/ec.c
68
+@@ -396,6 +396,29 @@ ec_get_two_inv_p (mpi_ec_t ec)
69
+ }
70
+ 
71
+ 
72
++static const char *curve25519_bad_points[] = {
73
++  "0x0000000000000000000000000000000000000000000000000000000000000000",
74
++  "0x0000000000000000000000000000000000000000000000000000000000000001",
75
++  "0x00b8495f16056286fdb1329ceb8d09da6ac49ff1fae35616aeb8413b7c7aebe0",
76
++  "0x57119fd0dd4e22d8868e1c58c45c44045bef839c55b1d0b1248c50a3bc959c5f",
77
++  "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec",
78
++  "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed",
79
++  "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee",
80
++  NULL
81
++};
82
++
83
++static gcry_mpi_t
84
++scanval (const char *string)
85
++{
86
++  gpg_err_code_t rc;
87
++  gcry_mpi_t val;
88
++
89
++  rc = _gcry_mpi_scan (&val, GCRYMPI_FMT_HEX, string, 0, NULL);
90
++  if (rc)
91
++    log_fatal ("scanning ECC parameter failed: %s\n", gpg_strerror (rc));
92
++  return val;
93
++}
94
++
95
+ 
96
+ /* This function initialized a context for elliptic curve based on the
97
+    field GF(p).  P is the prime specifying this field, A is the first
98
+@@ -434,9 +457,17 @@ ec_p_init (mpi_ec_t ctx, enum gcry_mpi_ec_models model,
99
+ 
100
+   _gcry_mpi_ec_get_reset (ctx);
101
+ 
102
+-  /* Allocate scratch variables.  */
103
+-  for (i=0; i< DIM(ctx->t.scratch); i++)
104
+-    ctx->t.scratch[i] = mpi_alloc_like (ctx->p);
105
++  if (model == MPI_EC_MONTGOMERY)
106
++    {
107
++      for (i=0; i< DIM(ctx->t.scratch) && curve25519_bad_points[i]; i++)
108
++        ctx->t.scratch[i] = scanval (curve25519_bad_points[i]);
109
++    }
110
++  else
111
++    {
112
++      /* Allocate scratch variables.  */
113
++      for (i=0; i< DIM(ctx->t.scratch); i++)
114
++        ctx->t.scratch[i] = mpi_alloc_like (ctx->p);
115
++    }
116
+ 
117
+   /* Prepare for fast reduction.  */
118
+   /* FIXME: need a test for NIST values.  However it does not gain us
119
+@@ -1572,3 +1603,17 @@ _gcry_mpi_ec_curve_point (gcry_mpi_point_t point, mpi_ec_t ctx)
120
+ 
121
+   return res;
122
+ }
123
++
124
++
125
++int
126
++_gcry_mpi_ec_bad_point (gcry_mpi_point_t point, mpi_ec_t ctx)
127
++{
128
++  int i;
129
++  gcry_mpi_t x_bad;
130
++
131
++  for (i = 0; (x_bad = ctx->t.scratch[i]); i++)
132
++    if (!mpi_cmp (point->x, x_bad))
133
++      return 1;
134
++
135
++  return 0;
136
++}
137
+diff --git a/src/mpi.h b/src/mpi.h
138
+index b5385b5..aeba7f8 100644
139
+--- a/src/mpi.h
140
+@@ -296,6 +296,7 @@ void _gcry_mpi_ec_mul_point (mpi_point_t result,
141
+                              gcry_mpi_t scalar, mpi_point_t point,
142
+                              mpi_ec_t ctx);
143
+ int  _gcry_mpi_ec_curve_point (gcry_mpi_point_t point, mpi_ec_t ctx);
144
++int _gcry_mpi_ec_bad_point (gcry_mpi_point_t point, mpi_ec_t ctx);
145
+ 
146
+ gcry_mpi_t _gcry_mpi_ec_ec2os (gcry_mpi_point_t point, mpi_ec_t ectx);
147
+ 
148
+-- 
... ...
@@ -1,11 +1,12 @@
1 1
 Summary:	Crypto Libraries
2 2
 Name:		libgcrypt
3 3
 Version:	1.7.6
4
-Release:	1%{?dist}
4
+Release:	2%{?dist}
5 5
 License:        GPLv2+ and LGPLv2+
6 6
 URL:            http://www.gnu.org/software/libgcrypt/
7 7
 Source0:        ftp://ftp.gnupg.org/gcrypt/libgcrypt/%{name}-%{version}.tar.bz2
8 8
 %define sha1 libgcrypt=d2b9e0f413064cfc67188f80d3cbda887c755a62
9
+Patch0:         CVE-2017-0379.patch
9 10
 Group:		System Environment/Libraries
10 11
 Vendor:		VMware, Inc.
11 12
 BuildRequires:	libgpg-error
... ...
@@ -27,6 +28,7 @@ that use libgcrypt.
27 27
 
28 28
 %prep
29 29
 %setup -q
30
+%patch0 -p1
30 31
 
31 32
 %build
32 33
 ./configure \
... ...
@@ -57,6 +59,8 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
57 57
 /usr/share/aclocal/libgcrypt.m4
58 58
 
59 59
 %changelog
60
+*	Tue Oct 17 2017 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 1.7.6-2
61
+-	Fix CVE-2017-0379
60 62
 *       Mon Apr 17 2017 Vinay Kulkarni <kulkarniv@vmware.com> 1.7.6-1
61 63
 -       Update to 1.7.6 to fix CVE-2016-6313.
62 64
 *	Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 1.6.5-2
... ...
@@ -1,15 +1,15 @@
1 1
 Summary:	Libraries for terminal handling of character screens
2 2
 Name:		ncurses
3 3
 Version:	6.0
4
-Release:	6%{?dist}
4
+Release:	7%{?dist}
5 5
 License:	MIT
6
-URL:		http://www.gnu.org/software/ncurses
6
+URL:		http://invisible-island.net/ncurses/
7 7
 Group:		Applications/System
8 8
 Vendor:		VMware, Inc.
9 9
 Distribution: 	Photon
10
-Source0:	ftp://ftp.gnu.org/gnu/ncurses/%{name}-%{version}.tar.gz
11
-%define sha1 ncurses=acd606135a5124905da770803c05f1f20dd3b21c
12
-Patch0:		CVE-2017-10684-CVE-2017-10685.patch
10
+%global ncursessubversion 20171007
11
+Source0:	ftp://ftp.invisible-island.net/ncurses/current/%{name}-%{version}-20171007.tgz
12
+%define sha1 ncurses=527be8da26f04f50c1d659e972fa7d0b762c3a80
13 13
 Provides:       libncurses.so.6()(64bit)
14 14
 %description
15 15
 The Ncurses package contains libraries for terminal-independent
... ...
@@ -26,13 +26,13 @@ compatibility.
26 26
 
27 27
 %package	devel
28 28
 Summary:	Header and development files for ncurses
29
-Requires:	%{name} = %{version}
29
+Requires:	%{name} = %{version}-%{release}
30 30
 Provides:	pkgconfig(ncurses)
31 31
 %description	devel
32 32
 It contains the libraries and header files to create applications 
33 33
 %prep
34
-%setup -q
35
-%patch0 -p1
34
+%setup -q -n %{name}-%{version}-%{ncursessubversion}
35
+
36 36
 %build
37 37
 mkdir v6
38 38
 pushd v6
... ...
@@ -155,6 +155,8 @@ ln -sv %{_lib}/libncursesw.so.5.9 %{buildroot}%{_libdir}/libncurses.so.5
155 155
 %{_libdir}/libpanel.so
156 156
 %{_libdir}/libmenu.so
157 157
 %changelog
158
+*   Tue Oct 17 2017 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 6.0-7
159
+-   Update to 6.0-7. Fix CVE-2017-13728
158 160
 *   Fri Sep 15 2017 Xiaolin Li <xiaolinl@vmware.com> 6.0-6
159 161
 -   ncurses-devel provides pkgconfig(ncurses)
160 162
 *   Thu Jul 06 2017 Dheeraj Shetty <dheerajs@vmware.com> 6.0-5