Skip to contentSkip to conversation

OpenSSL: CVE-2004-2761 replace MD5 hash algorithm

PATCH Superseded T.O. Radzy Radzykewycz 2 participants 3 messages Nov 15, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 OpenSSL: CVE-2004-2761 replace MD5 hash algorithm

Use SHA256 as default digest for OpenSSL instead of MD5.

CVE-2004-2761:

The MD5 Message-Digest Algorithm is not collision resistant, which makes it easier for context-dependent attackers to conduct spoofing attacks, as demonstrated by attacks on the use of MD5 in the signature algorithm of an X.509 certificate.

Status: Backport from OpenSSL 2.0 to OpenSSL 1.0.2 Commit f8547f62c212837dbf44fb7e2755e5774a59a57b

---
 .../Use-SHA256-not-MD5-as-default-digest.patch     | 59 ++++++++++++++++++++++
 .../recipes-connectivity/openssl/openssl_1.0.2h.bb |  1 +
 2 files changed, 60 insertions(+)
 create mode 100644 meta/recipes-connectivity/openssl/openssl/Use-SHA256-not-MD5-as-default-digest.patch
meta/recipes-connectivity/openssl/openssl/Use-SHA256-not-MD5-as-default-digest.patch new file +59 -0
new file mode 100644
index 000000000000..766af67e1db9
@@ -0,0 +1,59 @@
+From d795f5f20a29adecf92c09459a3ee07ffac01a99 Mon Sep 17 00:00:00 2001
+From: Rich Salz <[email protected]>
+Date: Sat, 13 Jun 2015 17:03:39 -0400
+Subject: [PATCH] Use SHA256 not MD5 as default digest.
+
+Commit f8547f62c212837dbf44fb7e2755e5774a59a57b upstream.
+
+Upstream Status: Backport
+
+Reviewed-by: Viktor Dukhovni <[email protected]>
+Signed-off-by: Zhang Xiao <[email protected]>
+---
+ apps/ca.c   | 2 +-
+ apps/dgst.c | 2 +-
+ apps/enc.c  | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/apps/ca.c b/apps/ca.c
+index 3b7336c..8f3a84b 100644
+--- a/apps/ca.c
++++ b/apps/ca.c
+@@ -1612,7 +1612,7 @@ static int certify_cert(X509 **xret, char *infile, EVP_PKEY *pkey, X509 *x509,
+     } else
+         BIO_printf(bio_err, "Signature ok\n");
+ 
+-    if ((rreq = X509_to_X509_REQ(req, NULL, EVP_md5())) == NULL)
++    if ((rreq = X509_to_X509_REQ(req, NULL, NULL)) == NULL)
+         goto err;
+ 
+     ok = do_body(xret, pkey, x509, dgst, sigopts, policy, db, serial, subj,
+diff --git a/apps/dgst.c b/apps/dgst.c
+index 95e5fa3..0d1529f 100644
+--- a/apps/dgst.c
++++ b/apps/dgst.c
+@@ -442,7 +442,7 @@ int MAIN(int argc, char **argv)
+             goto end;
+         }
+         if (md == NULL)
+-            md = EVP_md5();
++            md = EVP_sha256();
+         if (!EVP_DigestInit_ex(mctx, md, impl)) {
+             BIO_printf(bio_err, "Error setting digest %s\n", pname);
+             ERR_print_errors(bio_err);
+diff --git a/apps/enc.c b/apps/enc.c
+index 7b7c70b..a7d944c 100644
+--- a/apps/enc.c
++++ b/apps/enc.c
+@@ -344,7 +344,7 @@ int MAIN(int argc, char **argv)
+     }
+ 
+     if (dgst == NULL) {
+-        dgst = EVP_md5();
++        dgst = EVP_sha256();
+     }
+ 
+     if (bufsize != NULL) {
+-- 
+1.9.1
+
meta/recipes-connectivity/openssl/openssl_1.0.2h.bb +1 -0
index 5a4e52a4d735..5714affe4407 100644
@@ -49,6 +49,7 @@ SRC_URI += "file://find.pl;subdir=${BP}/util/ \
             file://CVE-2016-6303.patch \
             file://CVE-2016-6304.patch \
             file://CVE-2016-6306.patch \
+	    file://Use-SHA256-not-MD5-as-default-digest.patch \
            "
 SRC_URI[md5sum] = "9392e65072ce4b614c1392eefc1f23d0"
 SRC_URI[sha256sum] = "1d4007e53aad94a5b2002fe045ee7bb0b3d98f1a47f8b2bc851dcd1c74332919"
Signature · 1 line
1.9.1
#1 lore raw
Quoted 2 lines · T.O. Radzy Radzykewycz
 .../recipes-connectivity/openssl/openssl_1.0.2h.bb |  1 +

oe-core master is on openssl 1.0.2j now, so please rebase.

Quoted 14 lines
 2 files changed, 60 insertions(+)
 create mode 100644 meta/recipes-connectivity/openssl/openssl/Use-SHA256-

not-MD5-as-default-digest.patch

(quoted diff) +0 -0

not-MD5-as-default-digest.patch b/meta/recipes-connectivity/ openssl/openssl/Use-SHA256-not-MD5-as-default-digest.patch new file mode 100644
index 000000000000..766af67e1db9

meta/recipes-connectivity/openssl/openssl/Use-SHA256- new file +0 -0

not-MD5-as-default-digest.patch

meta/recipes-connectivity/openssl/openssl/Use-SHA256- line 8

Quoted 8 lines
meta/recipes-connectivity/openssl/openssl/Use-SHA256- new file +8 -0
@@ -0,0 +1,59 @@
+From d795f5f20a29adecf92c09459a3ee07ffac01a99 Mon Sep 17 00:00:00 2001
+From: Rich Salz <[email protected]>
+Date: Sat, 13 Jun 2015 17:03:39 -0400
+Subject: [PATCH] Use SHA256 not MD5 as default digest.
+
+Commit f8547f62c212837dbf44fb7e2755e5774a59a57b upstream.
+
+Upstream Status: Backport

I'm such a pedant but we do have automated tooling around this, so please use "Upstream-Status". Also adding a CVE tag in the patch (CVE:
CVE-2004-2761) would be appreciated for tracking.

Ross

#2 lore raw

________________________________________

Quoted 29 lines

From: Burton, Ross [[email protected]]
Sent: Tuesday, November 15, 2016 11:59 AM
To: Radzykewycz, T (Radzy)
Cc: OE-core
Subject: Re: [OE-core] [PATCH] OpenSSL: CVE-2004-2761 replace MD5 hash algorithm

On 15 November 2016 at 19:43, T.O. Radzy Radzykewycz <[email protected]<mailto:[email protected]>> wrote:

 .../recipes-connectivity/openssl/openssl_1.0.2h.bb<http://openssl_1.0.2h.bb> |  1 +

oe-core master is on openssl 1.0.2j now, so please rebase.

 2 files changed, 60 insertions(+)
 create mode 100644 meta/recipes-connectivity/openssl/openssl/Use-SHA256-not-MD5-as-default-digest.patch
meta/recipes-connectivity/openssl/openssl/Use-SHA256-not-MD5-as-default-digest.patch new file +8 -0
new file mode 100644
index 000000000000..766af67e1db9
@@ -0,0 +1,59 @@
+From d795f5f20a29adecf92c09459a3ee07ffac01a99 Mon Sep 17 00:00:00 2001
+From: Rich Salz <[email protected]<mailto:[email protected]>>
+Date: Sat, 13 Jun 2015 17:03:39 -0400
+Subject: [PATCH] Use SHA256 not MD5 as default digest.
+
+Commit f8547f62c212837dbf44fb7e2755e5774a59a57b upstream.
+
+Upstream Status: Backport
Quoted 1 line

I'm such a pedant but we do have automated tooling around this, so please use "Upstream-Status". Also adding a CVE tag in the patch (CVE: CVE-2004-2761) would be appreciated for tracking.

Thanks for the great feedback!

I'll send a new patch shortly.

Enjoy!

-- radzy

PS: The instructions at
http://www.openembedded.org/wiki/How_to_submit_a_patch_to_OpenEmbedded
seem to indicate that you should not use master. Since I seem to have misunderstood, please forgive my ignorance.

Quoted 1 line

Ross