Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [day] [month] [year] [list]
Date: Wed, 13 Jan 2010 10:15:48 -0500
From: "Michael K. Johnson" <johnsonm@...th.com>
To: oss-security <oss-security@...ts.openwall.com>
Subject: [PATCH] memory consumption (DoS) in openssl CVE-2009-4355

Previously, an initialization-related memory leak involving openssl
was given CVE-2008-1678 and worked around in mod_ssl; see for example
https://bugzilla.redhat.com/show_bug.cgi?id=447268
https://issues.apache.org/bugzilla/show_bug.cgi?id=44975
https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/224945
http://svn.apache.org/viewvc?view=rev&revision=654119

However, this did not resolve the general problem, and an rPath
customer recently reproduced essentially the same memory leak via
another pathway.  This new pathway was assigned CVE-2009-4355.
Initially, the suggestion was to fix the leak via modifications
to php or curl in the same way that mod_ssl was previously fixed,
but then Andy Grimm provided a patch to openssl that would not only
resolve the issue for curl/php but also for any other as-yet-unknown
new vectors.  Dr. Stephen Henson, an openssl core team member,
provided a new openssl patch which rPath has confirmed resolves
the issue, and which Dr. Henson is committing to upstream openssl.
Dr. Henson's patch is attached to this email.

The specific symptom of this new pathway is that any vulnerable
system will leak hundreds of KB of memory per SSLv3 connection after
apache has been gracefully restarted (SIGHUP).  Temporary mitigation
strategies include limiting the number of requests that an apache
worker can serve to limit the quantity of leaked memory, and doing
full restarts rather than graceful restarts of apache.

Some discussion regarding this issue is in two issue reports:
https://issues.rpath.com/browse/RPL-3157
https://bugzilla.redhat.com/show_bug.cgi?id=546707

(I cannot make the Red Hat bugzilla report public, but assume
that it will be made public today.)

From: "Dr. Stephen Henson" <steve@...nssl.org>
To: Andy Grimm <agrimm@...th.com>
Cc: Stefan Fritsch <sf@...ian.org>, Kees Cook <kees@...ntu.com>,
        Pierre Joye <pierre.php@...il.com>,
        "Steven M. Christey" <coley@...us.mitre.org>,
        Daniel Stenberg <daniel@...x.se>, curl-security@...x.se,
        secalert@...hat.com, security@...ian.org, security@...e.de,
        security@...ntu.com, Joe Orton <jorton@...hat.com>, security@....net,
        "Michael K. Johnson" <johnsonm@...th.com>,
        Kurt Roeckx <kurt@...ckx.be>
Subject: Re: [PATCH] memory consumption (DoS) vulnerability involving libcurl
Message-ID: <20100111011852.GA14391@...nssl.org>

...

I've attached a patch which uses an alternative technique. The main problem is
that the ex_data free function pointer is removed when
CRYPTO_cleanup_all_ex_data() is called. If the compression structure is
cleaned up directly this problem is avoided:

Index: crypto/comp/c_zlib.c
===================================================================
RCS file: /v/openssl/cvs/openssl/crypto/comp/c_zlib.c,v
retrieving revision 1.22
diff -u -r1.22 c_zlib.c
--- crypto/comp/c_zlib.c	13 Dec 2008 17:19:40 -0000	1.22
+++ crypto/comp/c_zlib.c	8 Jan 2010 23:56:13 -0000
@@ -136,15 +136,6 @@
 
 static int zlib_stateful_ex_idx = -1;
 
-static void zlib_stateful_free_ex_data(void *obj, void *item,
-	CRYPTO_EX_DATA *ad, int ind,long argl, void *argp)
-	{
-	struct zlib_state *state = (struct zlib_state *)item;
-	inflateEnd(&state->istream);
-	deflateEnd(&state->ostream);
-	OPENSSL_free(state);
-	}
-
 static int zlib_stateful_init(COMP_CTX *ctx)
 	{
 	int err;
@@ -188,6 +179,12 @@
 
 static void zlib_stateful_finish(COMP_CTX *ctx)
 	{
+	struct zlib_state *state =
+		(struct zlib_state *)CRYPTO_get_ex_data(&ctx->ex_data,
+			zlib_stateful_ex_idx);
+	inflateEnd(&state->istream);
+	deflateEnd(&state->ostream);
+	OPENSSL_free(state);
 	CRYPTO_free_ex_data(CRYPTO_EX_INDEX_COMP,ctx,&ctx->ex_data);
 	}
 
@@ -402,7 +399,7 @@
 			if (zlib_stateful_ex_idx == -1)
 				zlib_stateful_ex_idx =
 					CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_COMP,
-						0,NULL,NULL,NULL,zlib_stateful_free_ex_data);
+						0,NULL,NULL,NULL,NULL);
 			CRYPTO_w_unlock(CRYPTO_LOCK_COMP);
 			if (zlib_stateful_ex_idx == -1)
 				goto err;

Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org


Powered by blists - more mailing lists

Please check out the Open Source Software Security Wiki, which is counterpart to this mailing list.

Powered by Openwall GNU/*/Linux - Powered by OpenVZ