[curl/f18] fix buffer overflow when negotiating SASL DIGEST-MD5 auth (CVE-2013-0249)

Kamil Dudka kdudka at fedoraproject.org
Wed Feb 6 14:28:27 UTC 2013


commit 362dff21e39aab36a50368eabe9cd347ba4e316e
Author: Kamil Dudka <kdudka at redhat.com>
Date:   Wed Feb 6 15:21:13 2013 +0100

    fix buffer overflow when negotiating SASL DIGEST-MD5 auth (CVE-2013-0249)

 0009-curl-7.27.0-f206d6c0.patch |   69 +++++++++++++++++++++++++++++++++++++++
 curl.spec                       |    9 ++++-
 2 files changed, 77 insertions(+), 1 deletions(-)
---
diff --git a/0009-curl-7.27.0-f206d6c0.patch b/0009-curl-7.27.0-f206d6c0.patch
new file mode 100644
index 0000000..f904907
--- /dev/null
+++ b/0009-curl-7.27.0-f206d6c0.patch
@@ -0,0 +1,69 @@
+From 46890e837c3b27195e4b0285d221d900f2ad48cc Mon Sep 17 00:00:00 2001
+From: Eldar Zaitov <kyprizel at volema.com>
+Date: Wed, 30 Jan 2013 23:22:27 +0100
+Subject: [PATCH] Curl_sasl_create_digest_md5_message: fix buffer overflow
+
+When negotiating SASL DIGEST-MD5 authentication, the function
+Curl_sasl_create_digest_md5_message() uses the data provided from the
+server without doing the proper length checks and that data is then
+appended to a local fixed-size buffer on the stack.
+
+This vulnerability can be exploited by someone who is in control of a
+server that a libcurl based program is accessing with POP3, SMTP or
+IMAP. For applications that accept user provided URLs, it is also
+thinkable that a malicious user would feed an application with a URL to
+a server hosting code targetting this flaw.
+
+Bug: http://curl.haxx.se/docs/adv_20130206.html
+
+[upstream commit f206d6c055d1008f0edb6d5d5920f0f300b9983a]
+
+Signed-off-by: Kamil Dudka <kdudka at redhat.com>
+---
+ lib/curl_sasl.c |   23 ++++++-----------------
+ 1 files changed, 6 insertions(+), 17 deletions(-)
+
+diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c
+index ccb54a8..e42b850 100644
+--- a/lib/curl_sasl.c
++++ b/lib/curl_sasl.c
+@@ -345,9 +345,7 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data,
+     snprintf(&HA1_hex[2 * i], 3, "%02x", digest[i]);
+ 
+   /* Prepare the URL string */
+-  strcpy(uri, service);
+-  strcat(uri, "/");
+-  strcat(uri, realm);
++  snprintf(uri, sizeof(uri), "%s/%s", service, realm);
+ 
+   /* Calculate H(A2) */
+   ctxt = Curl_MD5_init(Curl_DIGEST_MD5);
+@@ -391,20 +389,11 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data,
+   for(i = 0; i < MD5_DIGEST_LEN; i++)
+     snprintf(&resp_hash_hex[2 * i], 3, "%02x", digest[i]);
+ 
+-  strcpy(response, "username=\"");
+-  strcat(response, userp);
+-  strcat(response, "\",realm=\"");
+-  strcat(response, realm);
+-  strcat(response, "\",nonce=\"");
+-  strcat(response, nonce);
+-  strcat(response, "\",cnonce=\"");
+-  strcat(response, cnonce);
+-  strcat(response, "\",nc=");
+-  strcat(response, nonceCount);
+-  strcat(response, ",digest-uri=\"");
+-  strcat(response, uri);
+-  strcat(response, "\",response=");
+-  strcat(response, resp_hash_hex);
++  snprintf(response, sizeof(response),
++           "username=\"%s\",realm=\"%s\",nonce=\"%s\","
++           "cnonce=\"%s\",nc=\"%s\",digest-uri=\"%s\",response=%s",
++           userp, realm, nonce,
++           cnonce, nonceCount, uri, resp_hash_hex);
+ 
+   /* Base64 encode the reply */
+   return Curl_base64_encode(data, response, 0, outptr, outlen);
+-- 
+1.7.1
+
diff --git a/curl.spec b/curl.spec
index 850093f..9f62ec3 100644
--- a/curl.spec
+++ b/curl.spec
@@ -1,7 +1,7 @@
 Summary: A utility for getting files from remote servers (FTP, HTTP, and others)
 Name: curl
 Version: 7.27.0
-Release: 5%{?dist}
+Release: 6%{?dist}
 License: MIT
 Group: Applications/Internet
 Source: http://curl.haxx.se/download/%{name}-%{version}.tar.lzma
@@ -32,6 +32,9 @@ Patch7: 0007-curl-7.27.0-b36f1d26.patch
 # fix error messages for CURLE_SSL_{CACERT,CRL}_BADFILE
 Patch8: 0008-curl-7.27.0-26613d78.patch
 
+# fix buffer overflow when negotiating SASL DIGEST-MD5 auth (CVE-2013-0249)
+patch9: 0009-curl-7.27.0-f206d6c0.patch
+
 # patch making libcurl multilib ready
 Patch101: 0101-curl-7.27.0-multilib.patch
 
@@ -133,6 +136,7 @@ documentation of the library, too.
 %patch6 -p1
 %patch7 -p1
 %patch8 -p1
+%patch9 -p1
 
 # Fedora patches
 %patch101 -p1
@@ -256,6 +260,9 @@ rm -rf $RPM_BUILD_ROOT
 %{_datadir}/aclocal/libcurl.m4
 
 %changelog
+* Wed Feb 06 2013 Kamil Dudka <kdudka at redhat.com> 7.27.0-6
+- fix buffer overflow when negotiating SASL DIGEST-MD5 auth (CVE-2013-0249)
+
 * Tue Jan 15 2013 Kamil Dudka <kdudka at redhat.com> 7.27.0-5
 - do not print misleading NSS error codes
 - update the links to cipher-suites supported by NSS


More information about the scm-commits mailing list