Bug 1161443 - (CVE-2014-8564) CVE-2014-8564 gnutls: Heap corruption when generating key ID for ECC (GNUTLS-SA-2014-5)
CVE-2014-8564 gnutls: Heap corruption when generating key ID for ECC (GNUTLS-...
Status: CLOSED ERRATA
Product: Security Response
Classification: Other
Component: vulnerability (Show other bugs)
unspecified
All Linux
medium Severity medium
: ---
: ---
Assigned To: Red Hat Product Security
impact=moderate,public=20141110,repor...
: Security
Depends On: 1161472 1161473 1162086
Blocks: 1159291
  Show dependency treegraph
 
Reported: 2014-11-07 02:13 EST by Siddharth Sharma
Modified: 2014-11-16 09:40 EST (History)
5 users (show)

See Also:
Fixed In Version: gnutls 3.1.28, gnutls 3.2.20, gnutls 3.3.10
Doc Type: Bug Fix
Doc Text:
An out-of-bounds memory write flaw was found in the way GnuTLS parsed certain ECC (Elliptic Curve Cryptography) certificates or certificate signing requests (CSR). A malicious user could create a specially crafted ECC certificate or a certificate signing request that, when processed by an application compiled against GnuTLS (for example, certtool), could cause that application to crash or execute arbitrary code with the permissions of the user running the application.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-11-12 00:46:37 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
proposed upstream patch (1.21 KB, patch)
2014-11-07 02:56 EST, Huzaifa S. Sidhpurwala
no flags Details | Diff

  None (edit)
Description Siddharth Sharma 2014-11-07 02:13:34 EST
IssueDescription:

An out-of-bounds memory write flaw was found in the way GnuTLS parsed certain ECC (Elliptic Curve Cryptography) certificates or certificate signing requests (CSR). A malicious user could create a specially crafted ECC certificate or a certificate signing request that, when processed by an application compiled against GnuTLS (for example, certtool), could cause that application to crash or execute arbitrary code with the permissions of the user running the application.
Comment 1 Huzaifa S. Sidhpurwala 2014-11-07 02:56:46 EST
Created attachment 954810 [details]
proposed upstream patch
Comment 2 Huzaifa S. Sidhpurwala 2014-11-07 03:19:34 EST
Analysis:

The issue exists in the _gnutls_ecc_ansi_x963_export() function in gnutls_ecc.c

The function starts with a call to gnutls_ecc_curve_get_size() at:

 36   int numlen = gnutls_ecc_curve_get_size (curve);

This gets the size of the curve parameters as given in the standards. The value is stored in the numlen variable.  

Since there are two numbers which need to be stores (bigint x and bigint y in this case), this number is multiplied by two and one byte is used to store "0x04"

 43   out->size = 1 + 2 * numlen;

After that out->size amount of memory is malloced, zero'ed out and the first byte (0x04) is written. 

Now bigint x needs to be converted to ascii to be stored in the "out" variable. This starts by estimating the size of bigint by using the _gnutls_mpi_get_nbits() macros. In this case it turns out to be bigger than numlen and is stored in the byte_size variable.

Now since there is no check on byte_size, the following results in a overflow.

 56   size = out->size - (1 + (numlen - byte_size));

In the above case numlen < byte_size 

Later when an attempt is made to store x in "out" it causes an OOB write at:

 57   ret = _gnutls_mpi_print (x, &out->data[1 + (numlen - byte_size)], &size);

portions of x are written before memory location of out->data array and causes heap corruption.

Same can happen when an attempt is made to store y in out->data
Comment 3 Huzaifa S. Sidhpurwala 2014-11-07 03:20:22 EST
Statement:

This issue does not affect the version of gnutls as shipped with Red Hat Enterprise Linux 5 and 6, since it does not have support for ECC (Elliptic Curve Cryptography).
Comment 7 Huzaifa S. Sidhpurwala 2014-11-10 04:07:34 EST
Public via:

http://www.gnutls.org/security.html#GNUTLS-SA-2014-5
Comment 8 Huzaifa S. Sidhpurwala 2014-11-10 04:10:29 EST
Created gnutls tracking bugs for this issue:

Affects: fedora-all [bug 1162086]
Comment 9 Huzaifa S. Sidhpurwala 2014-11-10 04:14:51 EST
Upstream patches:

gnutls-3.1.28:
https://gitorious.org/gnutls/gnutls/commit/7429872b74c8216bbf15e241e47aba94369ef083
Comment 14 Huzaifa S. Sidhpurwala 2014-11-10 22:38:29 EST
Acknowledgements:

Red Hat would like to thank GnuTLS upstream for reporting this issue. Upstream acknowledges Sean Burford as the original reporter.
Comment 15 errata-xmlrpc 2014-11-12 00:40:25 EST
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

Via RHSA-2014:1846 https://rhn.redhat.com/errata/RHSA-2014-1846.html
Comment 16 Fedora Update System 2014-11-13 13:22:45 EST
gnutls-3.1.28-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 17 Fedora Update System 2014-11-16 09:40:51 EST
gnutls-3.3.10-1.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.