Bug 1161443 (CVE-2014-8564) - CVE-2014-8564 gnutls: Heap corruption when generating key ID for ECC (GNUTLS-SA-2014-5)
Summary: CVE-2014-8564 gnutls: Heap corruption when generating key ID for ECC (GNUTLS-...
Status: CLOSED ERRATA
Alias: CVE-2014-8564
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard: impact=moderate,public=20141110,repor...
Keywords: Security
Depends On: 1161472 1161473 1162086
Blocks: 1159291
TreeView+ depends on / blocked
 
Reported: 2014-11-07 07:13 UTC by Siddharth Sharma
Modified: 2019-06-08 20:15 UTC (History)
5 users (show)

(edit)
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.
Clone Of:
(edit)
Last Closed: 2014-11-12 05:46:37 UTC


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


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2014:1846 normal SHIPPED_LIVE Moderate: gnutls security update 2014-11-12 10:40:14 UTC

Description Siddharth Sharma 2014-11-07 07:13:34 UTC
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 07:56:46 UTC
Created attachment 954810 [details]
proposed upstream patch

Comment 2 Huzaifa S. Sidhpurwala 2014-11-07 08:19:34 UTC
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 08:20:22 UTC
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 09:07:34 UTC
Public via:

http://www.gnutls.org/security.html#GNUTLS-SA-2014-5

Comment 8 Huzaifa S. Sidhpurwala 2014-11-10 09:10:29 UTC
Created gnutls tracking bugs for this issue:

Affects: fedora-all [bug 1162086]

Comment 9 Huzaifa S. Sidhpurwala 2014-11-10 09:14:51 UTC
Upstream patches:

gnutls-3.1.28:
https://gitorious.org/gnutls/gnutls/commit/7429872b74c8216bbf15e241e47aba94369ef083

Comment 14 Huzaifa S. Sidhpurwala 2014-11-11 03:38:29 UTC
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 05:40:25 UTC
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 18:22:45 UTC
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 14:40:51 UTC
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.