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" <>
To: oss-security <>
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

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:

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

From: "Dr. Stephen Henson" <>
To: Andy Grimm <>
Cc: Stefan Fritsch <>, Kees Cook <>,
        Pierre Joye <>,
        "Steven M. Christey" <>,
        Daniel Stenberg <>,,,,,, Joe Orton <>,,
        "Michael K. Johnson" <>,
        Kurt Roeckx <>
Subject: Re: [PATCH] memory consumption (DoS) vulnerability involving libcurl
Message-ID: <>


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);
@@ -402,7 +399,7 @@
 			if (zlib_stateful_ex_idx == -1)
 				zlib_stateful_ex_idx =
-						0,NULL,NULL,NULL,zlib_stateful_free_ex_data);
 			if (zlib_stateful_ex_idx == -1)
 				goto err;

Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see:

Powered by blists - more mailing lists

Your e-mail address:

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

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