1/5] openssl: Security fix CVE-2016-2177
PATCH 1/1 1/5] openssl: Security fix CVE-2016-2177
From: Armin Kuster <[email protected]>
Affects openssl <= 1.0.2h
CVSS v2 Base Score: 7.5 HIGH
--- .../openssl/openssl/CVE-2016-2177.patch | 286 +++++++++++++++++++++ .../recipes-connectivity/openssl/openssl_1.0.2h.bb | 1 + 2 files changed, 287 insertions(+) create mode 100644 meta/recipes-connectivity/openssl/openssl/CVE-2016-2177.patch
meta/recipes-connectivity/openssl/openssl/CVE-2016-2177.patch new file +286 -0
@@ -0,0 +1,286 @@ +From a004e72b95835136d3f1ea90517f706c24c03da7 Mon Sep 17 00:00:00 2001 +From: Matt Caswell <[email protected]> +Date: Thu, 5 May 2016 11:10:26 +0100 +Subject: [PATCH] Avoid some undefined pointer arithmetic + +A common idiom in the codebase is: + +if (p + len > limit) +{ + return; /* Too long */ +} + +Where "p" points to some malloc'd data of SIZE bytes and +limit == p + SIZE + +"len" here could be from some externally supplied data (e.g. from a TLS +message). + +The rules of C pointer arithmetic are such that "p + len" is only well +defined where len <= SIZE. Therefore the above idiom is actually +undefined behaviour. + +For example this could cause problems if some malloc implementation +provides an address for "p" such that "p + len" actually overflows for +values of len that are too big and therefore p + len < limit! + +Issue reported by Guido Vranken. + +CVE-2016-2177 + +Reviewed-by: Rich Salz <[email protected]> + +Upstream-Status: Backport +CVE: CVE-2016-2177 + +Signed-off-by: Armin Kuster <[email protected]> + + +--- + ssl/s3_srvr.c | 14 +++++++------- + ssl/ssl_sess.c | 2 +- + ssl/t1_lib.c | 56 ++++++++++++++++++++++++++++++-------------------------- + 3 files changed, 38 insertions(+), 34 deletions(-) + +diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c +index ab28702..ab7f690 100644 +--- a/ssl/s3_srvr.c ++++ b/ssl/s3_srvr.c +@@ -980,7 +980,7 @@ int ssl3_get_client_hello(SSL *s) + + session_length = *(p + SSL3_RANDOM_SIZE); + +- if (p + SSL3_RANDOM_SIZE + session_length + 1 >= d + n) { ++ if (SSL3_RANDOM_SIZE + session_length + 1 >= (d + n) - p) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); + goto f_err; +@@ -998,7 +998,7 @@ int ssl3_get_client_hello(SSL *s) + /* get the session-id */ + j = *(p++); + +- if (p + j > d + n) { ++ if ((d + n) - p < j) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); + goto f_err; +@@ -1054,14 +1054,14 @@ int ssl3_get_client_hello(SSL *s) + + if (SSL_IS_DTLS(s)) { + /* cookie stuff */ +- if (p + 1 > d + n) { ++ if ((d + n) - p < 1) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); + goto f_err; + } + cookie_len = *(p++); + +- if (p + cookie_len > d + n) { ++ if ((d + n ) - p < cookie_len) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); + goto f_err; +@@ -1131,7 +1131,7 @@ int ssl3_get_client_hello(SSL *s) + } + } + +- if (p + 2 > d + n) { ++ if ((d + n ) - p < 2) { + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_TOO_SHORT); + goto f_err; +@@ -1145,7 +1145,7 @@ int ssl3_get_client_hello(SSL *s) + } + + /* i bytes of cipher data + 1 byte for compression length later */ +- if ((p + i + 1) > (d + n)) { ++ if ((d + n) - p < i + 1) { + /* not enough data */ + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); +@@ -1211,7 +1211,7 @@ int ssl3_get_client_hello(SSL *s) + + /* compression */ + i = *(p++); +- if ((p + i) > (d + n)) { ++ if ((d + n) - p < i) { + /* not enough data */ + al = SSL_AD_DECODE_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH); +diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c +index b182998..54ee783 100644 +--- a/ssl/ssl_sess.c ++++ b/ssl/ssl_sess.c +@@ -573,7 +573,7 @@ int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len, + int r; + #endif + +- if (session_id + len > limit) { ++ if (limit - session_id < len) { + fatal = 1; + goto err; + } +diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c +index fb64607..cdac011 100644 +--- a/ssl/t1_lib.c ++++ b/ssl/t1_lib.c +@@ -1867,11 +1867,11 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, + 0x02, 0x03, /* SHA-1/ECDSA */ + }; + +- if (data >= (limit - 2)) ++ if (limit - data <= 2) + return; + data += 2; + +- if (data > (limit - 4)) ++ if (limit - data < 4) + return; + n2s(data, type); + n2s(data, size); +@@ -1879,7 +1879,7 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, + if (type != TLSEXT_TYPE_server_name) + return; + +- if (data + size > limit) ++ if (limit - data < size) + return; + data += size; + +@@ -1887,7 +1887,7 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, + const size_t len1 = sizeof(kSafariExtensionsBlock); + const size_t len2 = sizeof(kSafariTLS12ExtensionsBlock); + +- if (data + len1 + len2 != limit) ++ if (limit - data != (int)(len1 + len2)) + return; + if (memcmp(data, kSafariExtensionsBlock, len1) != 0) + return; +@@ -1896,7 +1896,7 @@ static void ssl_check_for_safari(SSL *s, const unsigned char *data, + } else { + const size_t len = sizeof(kSafariExtensionsBlock); + +- if (data + len != limit) ++ if (limit - data != (int)(len)) + return; + if (memcmp(data, kSafariExtensionsBlock, len) != 0) + return; +@@ -2053,19 +2053,19 @@ static int ssl_scan_clienthello_tlsext(SSL *s, unsigned char **p, + if (data == limit) + goto ri_check; + +- if (data > (limit - 2)) ++ if (limit - data < 2) + goto err; + + n2s(data, len); + +- if (data + len != limit) ++ if (limit - data != len) + goto err; + +- while (data <= (limit - 4)) { ++ while (limit - data >= 4) { + n2s(data, type); + n2s(data, size); + +- if (data + size > (limit)) ++ if (limit - data < size) + goto err; + # if 0 + fprintf(stderr, "Received extension type %d size %d\n", type, size); +@@ -2472,18 +2472,18 @@ static int ssl_scan_clienthello_custom_tlsext(SSL *s, + if (s->hit || s->cert->srv_ext.meths_count == 0) + return 1; + +- if (data >= limit - 2) ++ if (limit - data <= 2) + return 1; + n2s(data, len); + +- if (data > limit - len) ++ if (limit - data < len) + return 1; + +- while (data <= limit - 4) { ++ while (limit - data >= 4) { + n2s(data, type); + n2s(data, size); + +- if (data + size > limit) ++ if (limit - data < size) + return 1; + if (custom_ext_parse(s, 1 /* server */ , type, data, size, al) <= 0) + return 0; +@@ -2569,20 +2569,20 @@ static int ssl_scan_serverhello_tlsext(SSL *s, unsigned char **p, + SSL_TLSEXT_HB_DONT_SEND_REQUESTS); + # endif + +- if (data >= (d + n - 2)) ++ if ((d + n) - data <= 2) + goto ri_check; + + n2s(data, length); +- if (data + length != d + n) { ++ if ((d + n) - data != length) { + *al = SSL_AD_DECODE_ERROR; + return 0; + } + +- while (data <= (d + n - 4)) { ++ while ((d + n) - data >= 4) { + n2s(data, type); + n2s(data, size); + +- if (data + size > (d + n)) ++ if ((d + n) - data < size) + goto ri_check; + + if (s->tlsext_debug_cb) +@@ -3307,29 +3307,33 @@ int tls1_process_ticket(SSL *s, unsigned char *session_id, int len, + /* Skip past DTLS cookie */ + if (SSL_IS_DTLS(s)) { + i = *(p++); +- p += i; +- if (p >= limit) ++ ++ if (limit - p <= i) + return -1; ++ ++ p += i; + } + /* Skip past cipher list */ + n2s(p, i); +- p += i; +- if (p >= limit) ++ if (limit - p <= i) + return -1; ++ p += i; ++ + /* Skip past compression algorithm list */ + i = *(p++); +- p += i; +- if (p > limit) ++ if (limit - p < i) + return -1; ++ p += i; ++ + /* Now at start of extensions */ +- if ((p + 2) >= limit) ++ if (limit - p <= 2) + return 0; + n2s(p, i); +- while ((p + 4) <= limit) { ++ while (limit - p >= 4) { + unsigned short type, size; + n2s(p, type); + n2s(p, size); +- if (p + size > limit) ++ if (limit - p < size) + return 0; + if (type == TLSEXT_TYPE_session_ticket) { + int r; +-- +2.3.5 +
meta/recipes-connectivity/openssl/openssl_1.0.2h.bb +1 -0
@@ -39,6 +39,7 @@ SRC_URI += "file://find.pl;subdir=${BP}/util/ \ file://ptest_makefile_deps.patch \ file://configure-musl-target.patch \ file://parallel.patch \ + file://CVE-2016-2177.patch \ " SRC_URI[md5sum] = "9392e65072ce4b614c1392eefc1f23d0" SRC_URI[sha256sum] = "1d4007e53aad94a5b2002fe045ee7bb0b3d98f1a47f8b2bc851dcd1c74332919"
Signature · 1 line
2.3.5
PATCH 1/1 2/5] openssl: Security fix CVE-2016-2178
From: Armin Kuster <[email protected]>
affects openssl <= 1.0.2h
CVSS v2 Base Score: 2.1 LOW
--- .../openssl/openssl/CVE-2016-2178.patch | 51 ++++++++++++++++++++++ .../recipes-connectivity/openssl/openssl_1.0.2h.bb | 1 + 2 files changed, 52 insertions(+) create mode 100644 meta/recipes-connectivity/openssl/openssl/CVE-2016-2178.patch
meta/recipes-connectivity/openssl/openssl/CVE-2016-2178.patch new file +51 -0
@@ -0,0 +1,51 @@ +From 399944622df7bd81af62e67ea967c470534090e2 Mon Sep 17 00:00:00 2001 +From: Cesar Pereida <[email protected]> +Date: Mon, 23 May 2016 12:45:25 +0300 +Subject: [PATCH] Fix DSA, preserve BN_FLG_CONSTTIME + +Operations in the DSA signing algorithm should run in constant time in +order to avoid side channel attacks. A flaw in the OpenSSL DSA +implementation means that a non-constant time codepath is followed for +certain operations. This has been demonstrated through a cache-timing +attack to be sufficient for an attacker to recover the private DSA key. + +CVE-2016-2178 + +Reviewed-by: Richard Levitte <[email protected]> +Reviewed-by: Matt Caswell <[email protected]> + +Upstream-Status: Backport +CVE: CVE-2016-2178 + +Signed-off-by: Armin Kuster <[email protected]> + +--- + crypto/dsa/dsa_ossl.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +Index: openssl-1.0.2h/crypto/dsa/dsa_ossl.c +=================================================================== +--- openssl-1.0.2h.orig/crypto/dsa/dsa_ossl.c ++++ openssl-1.0.2h/crypto/dsa/dsa_ossl.c +@@ -248,9 +248,6 @@ static int dsa_sign_setup(DSA *dsa, BN_C + if (!BN_rand_range(&k, dsa->q)) + goto err; + while (BN_is_zero(&k)) ; +- if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) { +- BN_set_flags(&k, BN_FLG_CONSTTIME); +- } + + if (dsa->flags & DSA_FLAG_CACHE_MONT_P) { + if (!BN_MONT_CTX_set_locked(&dsa->method_mont_p, +@@ -282,6 +279,11 @@ static int dsa_sign_setup(DSA *dsa, BN_C + } else { + K = &k; + } ++ ++ if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) { ++ BN_set_flags(K, BN_FLG_CONSTTIME); ++ } ++ + DSA_BN_MOD_EXP(goto err, dsa, r, dsa->g, K, dsa->p, ctx, + dsa->method_mont_p); + if (!BN_mod(r, r, dsa->q, ctx))
meta/recipes-connectivity/openssl/openssl_1.0.2h.bb +1 -0
@@ -40,6 +40,7 @@ SRC_URI += "file://find.pl;subdir=${BP}/util/ \ file://configure-musl-target.patch \ file://parallel.patch \ file://CVE-2016-2177.patch \ + file://CVE-2016-2178.patch \ " SRC_URI[md5sum] = "9392e65072ce4b614c1392eefc1f23d0" SRC_URI[sha256sum] = "1d4007e53aad94a5b2002fe045ee7bb0b3d98f1a47f8b2bc851dcd1c74332919"
Signature · 1 line
2.3.5
PATCH 1/1 3/5] bzip2: Security fix CVE-2016-3189
In reply to Armin KusterFrom: Armin Kuster <[email protected]>
Affects bzip2 <= 1.0.6
CVSS v2 Base Score: 4.3 MEDIUM
--- .../bzip2/bzip2-1.0.6/CVE-2016-3189.patch | 18 ++++++++++++++++++ meta/recipes-extended/bzip2/bzip2_1.0.6.bb | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-extended/bzip2/bzip2-1.0.6/CVE-2016-3189.patch
meta/recipes-extended/bzip2/bzip2-1.0.6/CVE-2016-3189.patch new file +18 -0
@@ -0,0 +1,18 @@ +Upstream-Status: Backport +https://bugzilla.suse.com/attachment.cgi?id=681334 + +CVE: CVE-2016-3189 +Signed-off-by: Armin Kuster <[email protected]> + +Index: bzip2-1.0.6/bzip2recover.c +=================================================================== +--- bzip2-1.0.6.orig/bzip2recover.c ++++ bzip2-1.0.6/bzip2recover.c +@@ -457,6 +457,7 @@ Int32 main ( Int32 argc, Char** argv ) + bsPutUChar ( bsWr, 0x50 ); bsPutUChar ( bsWr, 0x90 ); + bsPutUInt32 ( bsWr, blockCRC ); + bsClose ( bsWr ); ++ outFile = NULL; + } + if (wrBlock >= rbCtr) break; + wrBlock++;
meta/recipes-extended/bzip2/bzip2_1.0.6.bb +3 -1
@@ -12,7 +12,9 @@ SRC_URI = "http://www.bzip.org/${PV}/${BP}.tar.gz \ file://fix-bunzip2-qt-returns-0-for-corrupt-archives.patch \ file://configure.ac;subdir=${BP} \ file://Makefile.am;subdir=${BP} \ - file://run-ptest" + file://run-ptest \ + file://CVE-2016-3189.patch \ + " SRC_URI[md5sum] = "00b516f4704d4a7cb50a1d97e6e8e15b" SRC_URI[sha256sum] = "a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd"
Signature · 1 line
2.3.5
PATCH 1/1 4/5] python2: Security fix CVE-2016-5636
In reply to Armin KusterFrom: Armin Kuster <[email protected]>
Affects python2 < 2.7.11
Base score (4.4) Medium
--- .../python/python/CVE-2016-5636.patch | 44 ++++++++++++++++++++++ meta/recipes-devtools/python/python_2.7.11.bb | 1 + 2 files changed, 45 insertions(+) create mode 100644 meta/recipes-devtools/python/python/CVE-2016-5636.patch
meta/recipes-devtools/python/python/CVE-2016-5636.patch new file +44 -0
@@ -0,0 +1,44 @@ + +# HG changeset patch +# User Benjamin Peterson <[email protected]> +# Date 1453357424 28800 +# Node ID 985fc64c60d6adffd1138b6cc46df388ca91ca5d +# Parent 7ec954b9fc54448a35b56d271340ba109eb381b9 +prevent buffer overflow in get_data (closes #26171) + +Upstream-Status: Backport +https://hg.python.org/cpython/rev/985fc64c60d6 + +CVE: CVE-2016-5636 +Signed-off-by: Armin Kuster <[email protected]> + +Index: Python-2.7.11/Misc/NEWS +=================================================================== +--- Python-2.7.11.orig/Misc/NEWS ++++ Python-2.7.11/Misc/NEWS +@@ -7,6 +7,9 @@ What's New in Python 2.7.11? + + *Release date: 2015-12-05* + ++- Issue #26171: Fix possible integer overflow and heap corruption in ++ zipimporter.get_data(). ++ + Library + ------- + +Index: Python-2.7.11/Modules/zipimport.c +=================================================================== +--- Python-2.7.11.orig/Modules/zipimport.c ++++ Python-2.7.11/Modules/zipimport.c +@@ -895,6 +895,11 @@ get_data(char *archive, PyObject *toc_en + PyMarshal_ReadShortFromFile(fp); /* local header size */ + file_offset += l; /* Start of file data */ + ++ if (data_size > LONG_MAX - 1) { ++ fclose(fp); ++ PyErr_NoMemory(); ++ return NULL; ++ } + raw_data = PyString_FromStringAndSize((char *)NULL, compress == 0 ? + data_size : data_size + 1); + if (raw_data == NULL) {
meta/recipes-devtools/python/python_2.7.11.bb +1 -0
@@ -27,6 +27,7 @@ SRC_URI += "\ file://use_sysroot_ncurses_instead_of_host.patch \ file://avoid_parallel_make_races_on_pgen.patch \ file://add-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch \ + file://CVE-2016-5636.patch \ " S = "${WORKDIR}/Python-${PV}"
Signature · 1 line
2.3.5
PATCH 1/1 5/5] python3: Security fix CVE-2016-5636
In reply to Armin KusterFrom: Armin Kuster <[email protected]>
Affects python3 < 3.5.1
Base Score (4.4) Medium
--- .../python/python3/CVE-2016-5636.patch | 44 ++++++++++++++++++++++ meta/recipes-devtools/python/python3_3.5.1.bb | 1 + 2 files changed, 45 insertions(+) create mode 100644 meta/recipes-devtools/python/python3/CVE-2016-5636.patch
meta/recipes-devtools/python/python3/CVE-2016-5636.patch new file +44 -0
@@ -0,0 +1,44 @@ + +# HG changeset patch +# User Benjamin Peterson <[email protected]> +# Date 1453357506 28800 +# Node ID 10dad6da1b28ea4af78ad9529e469fdbf4ebbc8f +# Parent a3ac2cd93db9d5336dfd7b5b27efde2c568d8794# Parent 01ddd608b85c85952537d95a43bbabf4fb655057 +merge 3.4 (#26171) + +Upstream-Status: Backport +CVE: CVE-2016-5636 + +https://hg.python.org/cpython/raw-rev/10dad6da1b28 +Signed-off-by: Armin Kuster <[email protected]> + +Index: Python-3.5.1/Misc/NEWS +=================================================================== +--- Python-3.5.1.orig/Misc/NEWS ++++ Python-3.5.1/Misc/NEWS +@@ -91,6 +91,9 @@ Core and Builtins + Python.h header to fix a compilation error with OpenMP. PyThreadState_GET() + becomes an alias to PyThreadState_Get() to avoid ABI incompatibilies. + ++- Issue #26171: Fix possible integer overflow and heap corruption in ++ zipimporter.get_data(). ++ + Library + ------- + +Index: Python-3.5.1/Modules/zipimport.c +=================================================================== +--- Python-3.5.1.orig/Modules/zipimport.c ++++ Python-3.5.1/Modules/zipimport.c +@@ -1112,6 +1112,11 @@ get_data(PyObject *archive, PyObject *to + } + file_offset += l; /* Start of file data */ + ++ if (data_size > LONG_MAX - 1) { ++ fclose(fp); ++ PyErr_NoMemory(); ++ return NULL; ++ } + bytes_size = compress == 0 ? data_size : data_size + 1; + if (bytes_size == 0) + bytes_size++;
meta/recipes-devtools/python/python3_3.5.1.bb +1 -0
@@ -37,6 +37,7 @@ SRC_URI += "\ file://setup.py-find-libraries-in-staging-dirs.patch \ file://use_packed_importlib.patch \ file://configure.ac-fix-LIBPL.patch \ + file://CVE-2016-5636.patch \ " SRC_URI[md5sum] = "e9ea6f2623fffcdd871b7b19113fde80" SRC_URI[sha256sum] = "c6d57c0c366d9060ab6c0cdf889ebf3d92711d466cc0119c441dbf2746f725c9"
Signature · 1 line
2.3.5
Re: [master][PATCH] 3/5] bzip2: Security fix CVE-2016-3189
In reply to Armin Kustermeta/recipes-extended/bzip2/bzip2-1.0.6/CVE-2016-3189.patch line 4
Quoted 4 lines · Armin Kuster
meta/recipes-extended/bzip2/bzip2-1.0.6/CVE-2016-3189.patch new file +4
-0+Upstream-Status: Backport +https://bugzilla.suse.com/attachment.cgi?id=681334 + +CVE: CVE-2016-3189
Backport means the patch is taken from upstream development repository, and it's also good to provide a link to where it is in the upstream.
This looks like a distro vendor fix, so the upstream-status should be either pending or inappropriate (depending on the upstream development situation).
Alex